Skip to content

Assignment 8

Dan Carr edited this page Feb 22, 2017 · 9 revisions

Build The Infrastructure Part 1

Prerequisites

  • Student has Github account
  • Student has an AWS account
  • Student has completed Assignment 7

Concepts Introduced

  • Infrastructure as Code
  • CloudFormation
  • AWS Relational Database Service

Step 0 - Fork or clone the repo

Step 1 - Determine the monthly cost of our infrastructure

Go to:

  • https://calculator.s3.amazonaws.com/index.html
  • Look at the diagram in and estimate the monthly cost of running our infrastructure assuming t1.micro ec2 instances and t1.db.micro RDS instance in a Multi-AZ deployment
  • What are the key cost drivers? How could we decrease costs? What are the tradeoffs?

Step 2 - Modify Master Cloudformation template

In the master.yaml change the following lines denoted with ## marks:

  HomelessRDS:
        Type: AWS::CloudFormation::Stack
        Properties:
            TemplateURL: https://s3-us-west-2.amazonaws.com/cfn-templates-hacko-infra/infrastructure/rds.yaml
            Parameters:
                EnvironmentName: !Ref AWS::StackName
                VPC: !GetAtt VPC.Outputs.VPC
                Subnets: !GetAtt VPC.Outputs.PrivateSubnets
                TheDBIdentifier: '' # Your database Identifier
                TheDBName: '' ## Leave it blank for now
                TheDBUser: '' ## master admin user.  Will use <postgres>
                TheDBPassword: '' ## <PASSWORD>
                TheDBAllocatedStorage: '5'
                TheDBInstanceClass: 'db.t2.micro'
                IsMultiAZDatabase: 'false' # Change this if you want a multi-az deploy
  • Save the file

Step 3 - Launch your master stack

  • Go to the Cloudformation console on AWS
  • Click on Create Stack button
  • Choose Upload a template to S3 and upload master.yaml to temporary bucket
  • Click the Next button
  • Enter a name for your stack
  • Click the Next button
  • Select the I acknowledge that AWS CloudFormation might create IAM resources with custom names checkbox
  • Click the Create button
  • Watch your stack startup Note: This fails on purpose.

Step 4 - Troubleshooting

  • Click on the line with Rollback In Progress Status
  • Look for the error message. Why do you think it failed? Tip Look in the rds.yaml file
  • Fix the error and delete the stack and run through Step 2 again

Step 5 - Watch your infrastructure spin up.

  • Make sure everything completes
  • Explore your AWS console now:
  • VPC
  • Subnets
  • Route Tables
  • Application Load Balancers
  • Relational Database Services (RDS)
  • EC2 Container Services
  • In the Output section of your master stack, look for the service endpoints

Next Step is important in order to avoid excess AWS charges

Step 6 - Teardown Your Infrastructure

  • Go to the Cloudformation Console
  • Find and your master stack name. Hint: it's the one that does not have an infrastructure suffix attached.
  • Select the check box
  • Click the Action button and select Delete Stack
Clone this wiki locally