Deploy the Infrastructure and Application

You will create a multi-tier architecture using AWS and run a simple service on it. The service is a web server running on Amazon EC2 fronted by an Elastic Load Balancer reverse-proxy, with a data store on Amazon Relational Database Service (RDS).

ThreeTierArchitecture

1.1 Log into the AWS console

If you are attending an in-person workshop and were provided with an AWS account by the instructor:

Click here for instructions to access your assigned AWS account:

If you are using your own AWS account:

Click here for instructions to use your own AWS account:

1.2 Checking for existing service-linked roles

If you are attending an in-person workshop and were provided with an AWS account by the instructor: Skip this step and go directly to step Create the “deployment machine” .

If you are using your own AWS account: Follow these steps , and then return here and resume with the following instructions.

1.3 Create the “deployment machine”

Here you will build a state machine using AWS Step Functions and AWS Lambda that orchestrates the deployment of the multi-tier infrastructure. This is not the service infrastructure itself, but meta-infrastructure we use to build the actual infrastructure.

Learn more: After the lab see this blog post on how AWS Step Functions and AWS CodePipelines can work together to deploy your infrastructure

  1. Decide which deployment option you will use for this lab. It can be run as single region or multi region (two region) deployment.

    • single region is faster to get up and running
    • multi region enables you to test some additional aspects of cross-regional resilience.
    • Decide on one of these options, then in later steps choose the appropriate instructions for the option you have chosen. If you are attending an in-person workshop, your instructor will specify which to use.
  2. Get the CloudFormation template: Download the appropriate file (You can right-click then choose download; or you can right click and copy the link to use with wget)

  3. Ensure you have selected the Ohio region. This region is also known as us-east-2, which you will see referenced throughout this lab. SelectOhio

  4. Go to the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation and click “Create Stack:” Images/CreateStackButton

  5. Leave “Prepare template” setting as-is

    • 1 - For “Template source” select “Upload a template file”
    • 2 - Specify the CloudFormation template you downloaded CFNSFromDownloadedFile
  6. Click the “Next” button. For “Stack name” enter:

     DeployResiliencyWorkshop
    

    CFNStackName-ohio

  7. On the same screen, for “Parameters” enter the appropriate values:

  8. Click the “Next” button.

    • On the “Configure stack options” page, click “Next” again
    • On the “Review DeployResiliencyWorkshop” page, scroll to the bottom and tick the checkbox “I acknowledge that AWS CloudFormation might create IAM resources.”
    • Click the “Create stack” button. CFNIamCapabilities
  9. This will take you to the CloudFormation stack status page, showing the stack creation in progress.
    StackCreationStarted
    This will take approximately a minute to deploy. When it shows status CREATE_COMPLETE, then you are finished with this step.

1.4 Deploy infrastructure and run the service

  1. Go to the AWS Step Function console at https://console.aws.amazon.com/states

  2. On the Step Functions dashboard, you will see “State Machines” and you will have a new one named “DeploymentMachine-random characters.” Click on that state machine. This will bring up an execution console. Click on the “Start execution” button. ExecutionStart-ohio

  3. On the “New execution” dialog, for “Enter an execution name” delete the auto-generated name and replace it with: BuildResiliency

  4. Then for “Input” enter JSON that will be used to supply parameter values to the Lambdas in the workflow.

    • single region uses the following values:

      {
        "log_level": "DEBUG",
        "region_name": "us-east-2",
        "cfn_region": "us-east-2",
        "cfn_bucket": "aws-well-architected-labs-ohio",
        "folder": "Reliability/",
        "workshop": "300-ResiliencyofEC2RDSandS3",
        "boot_bucket": "aws-well-architected-labs-ohio",
        "boot_prefix": "Reliability/",
        "websiteimage" : "https://s3.us-east-2.amazonaws.com/arc327-well-architected-for-reliability/Cirque_of_the_Towers.jpg"
      }
      
    • multi region uses the values here

    • Note: for websiteimage you can supply an alternate link to a public-read-only image in an S3 bucket you control. This will allow you to run S3 resiliency tests as part of the lab

    • Then click the “Start Execution” button.

      ExecutionInput-ohio

  5. The “deployment machine” is now deploying the infrastructure and service you will use for resiliency testing.

    Time until you can start…Single regionMulti region
    EC2 failure injection test15-20 min15-20 min
    RDS and AZ failure injection tests20-25 min40-45 min
    Multi-region failure injection testsNA50-55 min
    Total deployment time20-25 min50-55 min
  6. You can watch the state machine as it executes by clicking the icon to expand the visual workflow to the full screen.
    StateMachineExecuting

  7. You can also watch the CloudFormation stacks as they are created and transition from CREATE_IN_PROGRESS to CREATE_COMPLETE. DeploymentStacksInProgress

  8. Note: If you are in a workshop, the instructor will share background and technical information while your service is deployed.

  9. You can start the first test (EC2 failure injection testing) when the web tier has been deployed in the Ohio region. Look for the WaitForWebApp step (for single region) or WaitForWebApp1 step (for multi region) to have completed successfully. This will look something like this on the visual workflow.

    StepFunctionWebAppDeployed

1.5 View website for test web service

  1. Go to the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation.

    • click on the WebServersforResiliencyTesting stack
    • click on the “Outputs” tab
    • For the Key WebSiteURL copy the value. This is the URL of your test web service. CFNComplete
  2. Click the value and it will bring up the website:
    DemoWebsite

(image will vary depending on what you supplied for websiteimage)