Menu
AWS CodeDeploy
User Guide (API Version 2014-10-06)

Step 2: Deploy the Application to the Auto Scaling Group

In this step, you'll deploy the revision to the single Amazon EC2 instance in the Auto Scaling group.

To create the deployment (CLI)

  1. Call the create-application command to create an application named SimpleDemoApp:

    Copy
    aws deploy create-application --application-name SimpleDemoApp
  2. You should have already created a service role by following the instructions in Step 3: Create a Service Role. The service role will give AWS CodeDeploy permission to access your Amazon EC2 instances to expand (read) their tags. You will need the service role ARN. To get the service role ARN, follow the instructions in Get the Service Role ARN (CLI) .

  3. Now that you have a service role ARN, call the create-deployment-group command to create a deployment group named SimpleDemoDG, associated with the application named SimpleDemoApp, using the Auto Scaling group named CodeDeployDemo-AS-Group and deployment configuration named CodeDeployDefault.OneAtATime, with the specified service role ARN.

    Note

    The create-deployment-group command provides support for creating triggers that result in the sending of Amazon SNS notifications to topic subscribers about specified events in deployments and instances. The command also supports options for automatically rolling back deployments and setting up alarms to stop deployments when monitoring thresholds in Amazon CloudWatch Alarms are met. Commands for these actions are excluded from the sample in this tutorial.

    For Linux, macOS, or Unix:

    Copy
    aws deploy create-deployment-group \ --application-name SimpleDemoApp \ --auto-scaling-groups CodeDeployDemo-AS-Group \ --deployment-group-name SimpleDemoDG \ --deployment-config-name CodeDeployDefault.OneAtATime \ --service-role-arn service-role-arn

    For Windows:

    Copy
    aws deploy create-deployment-group --application-name SimpleDemoApp --auto-scaling-groups CodeDeployDemo-AS-Group --deployment-group-name SimpleDemoDG --deployment-config-name CodeDeployDefault.OneAtATime --service-role-arn service-role-arn
  4. Call the create-deployment command to create a deployment associated with the application named SimpleDemoApp, the deployment configuration named CodeDeployDefault.OneAtATime, the deployment group named SimpleDemoDG, using the revision at the specified location.

    For Amazon Linux and RHEL Amazon EC2 instances, calling from Linux, macOS, or Unix:

    Copy
    aws deploy create-deployment \ --application-name SimpleDemoApp \ --deployment-config-name CodeDeployDefault.OneAtATime \ --deployment-group-name SimpleDemoDG \ --s3-location bucket=bucket,bundleType=zip,key=samples/latest/SampleApp_Linux.zip

    bucket is one of the following:

    • aws-codedeploy-us-east-2 (for the US East (Ohio) region)

    • aws-codedeploy-us-east-1 (for the US East (N. Virginia) region)

    • aws-codedeploy-us-west-1 (for the US West (N. California) region)

    • aws-codedeploy-us-west-2 (for the US West (Oregon) region)

    • aws-codedeploy-ca-central-1 (for the Canada (Central) region)

    • aws-codedeploy-eu-west-1 (for the EU (Ireland) region)

    • aws-codedeploy-eu-west-2 (for the EU (London) region)

    • aws-codedeploy-eu-central-1 (for the EU (Frankfurt) region)

    • aws-codedeploy-ap-northeast-1 (for the Asia Pacific (Tokyo) region)

    • aws-codedeploy-ap-northeast-2 (for the Asia Pacific (Seoul) region)

    • aws-codedeploy-ap-southeast-1 (for the Asia Pacific (Singapore) region)

    • aws-codedeploy-ap-southeast-2 (for the Asia Pacific (Sydney) region)

    • aws-codedeploy-ap-south-1 (for the Asia Pacific (Mumbai) region)

    • aws-codedeploy-sa-east-1 (for the South America (São Paulo) region)

    • aws-codedeploy-cn-north-1 (for the China (Beijing) region)

    For Amazon Linux and RHEL Amazon EC2 instances, calling from Windows:

    Copy
    aws deploy create-deployment --application-name SimpleDemoApp --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name SimpleDemoDG --s3-location bucket=bucket,bundleType=zip,key=samples/latest/SampleApp_Linux.zip

    For Windows Server Amazon EC2 instances, calling from Linux, macOS, or Unix:

    Copy
    aws deploy create-deployment \ --application-name SimpleDemoApp \ --deployment-config-name CodeDeployDefault.OneAtATime \ --deployment-group-name SimpleDemoDG \ --s3-location bucket=bucket,bundleType=zip,key=samples/latest/SampleApp_Windows.zip

    bucket is one of the following:

    • aws-codedeploy-us-east-2 (for the US East (Ohio) region)

    • aws-codedeploy-us-east-1 (for the US East (N. Virginia) region)

    • aws-codedeploy-us-west-1 (for the US West (N. California) region)

    • aws-codedeploy-us-west-2 (for the US West (Oregon) region)

    • aws-codedeploy-ca-central-1 (for the Canada (Central) region)

    • aws-codedeploy-eu-west-1 (for the EU (Ireland) region)

    • aws-codedeploy-eu-west-2 (for the EU (London) region)

    • aws-codedeploy-eu-central-1 (for the EU (Frankfurt) region)

    • aws-codedeploy-ap-northeast-1 (for the Asia Pacific (Tokyo) region)

    • aws-codedeploy-ap-northeast-2 (for the Asia Pacific (Seoul) region)

    • aws-codedeploy-ap-southeast-1 (for the Asia Pacific (Singapore) region)

    • aws-codedeploy-ap-southeast-2 (for the Asia Pacific (Sydney) region)

    • aws-codedeploy-ap-south-1 (for the Asia Pacific (Mumbai) region)

    • aws-codedeploy-sa-east-1 (for the South America (São Paulo) region)

    • aws-codedeploy-cn-north-1 (for the China (Beijing) region)

    For Windows Server Amazon EC2 instances, calling from Windows:

    Copy
    aws deploy create-deployment --application-name SimpleDemoApp --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name SimpleDemoDG --s3-location bucket=bucket,bundleType=zip,key=samples/latest/SampleApp_Windows.zip

    Note

    Currently, AWS CodeDeploy does not provide a sample revision to deploy to Ubuntu Server Amazon EC2 instances. To create a revision on your own, see Working with Application Revisions.

  5. Call the get-deployment command to make sure the deployment was successful.

    Before you call this command, you will need the ID of the deployment, which should have been returned by the call to the create-deployment command. If you need to get the deployment ID again, call the list-deployments command against the application named SimpleDemoApp and the deployment group named SimpleDemoDG:

    Copy
    aws deploy list-deployments --application-name SimpleDemoApp --deployment-group-name SimpleDemoDG --query "deployments" --output text

    Now, call the get-deployment command using the deployment ID:

    Copy
    aws deploy get-deployment --deployment-id deployment-id --query "deploymentInfo.status" --output text

    Do not continue until the returned value is Succeeded.

To create the deployment (console)

  1. You should have already created a service role by following the instructions in Step 3: Create a Service Role. The service role will give AWS CodeDeploy permission to access your instances to expand (read) their tags. Before you use the AWS CodeDeploy console to deploy your application revision, you will need the service role ARN. To get the service role ARN, follow the instructions in Get the Service Role ARN (Console) .

  2. Now that you have the service role ARN, you can use the AWS CodeDeploy console to deploy your application revision.

    Sign in to the AWS Management Console and open the AWS CodeDeploy console at https://console.aws.amazon.com/codedeploy.

    Note

    Sign in with the same account or IAM user information you used in Getting Started.

  3. If the Applications page does not appear, on the AWS CodeDeploy menu, choose Applications.

  4. Choose Create application.

  5. In the Application name box, type SimpleDemoApp.

  6. In the Deployment group name box, type SimpleDemoDG.

  7. Choose Auto Scaling group from the Tag type drop-down list.

  8. In the box next to Auto Scaling group, type CodeDeployDemo-AS-Group.

  9. From the Deployment configuration drop-down list, choose CodeDeployDefault.OneAtATime.

  10. From the Service role ARN drop-down list, choose the service role ARN.

  11. Choose Create application.

  12. In the Application details page, in the Deployment groups area, next to SimpleDemoDG, choose the arrow to see the deployment group details.

  13. Select the button next to SimpleDemoDG. In the Actions menu, choose Deploy new revision.

  14. In the Repository type area, choose My application is stored in Amazon S3, and then in the Revision location box, type one of the following:

    For Amazon Linux and RHEL Amazon EC2 instances:

    For Amazon EC2 instances launched in the US East (Ohio) Region http://s3-us-east-2.amazonaws.com/aws-codedeploy-us-east-2/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the US East (N. Virginia) Region http://s3.amazonaws.com/aws-codedeploy-us-east-1/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the US West (N. California) Region http://s3-us-west-1.amazonaws.com/aws-codedeploy-us-west-1/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the US West (Oregon) Region http://s3-us-west-2.amazonaws.com/aws-codedeploy-us-west-2/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the Canada (Central) Region http://s3-ca-central-1.amazonaws.com/aws-codedeploy-ca-central-1/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the EU (Ireland) Region http://s3-eu-west-1.amazonaws.com/aws-codedeploy-eu-west-1/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the EU (London) Region http://s3-eu-west-2.amazonaws.com/aws-codedeploy-eu-west-2/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the EU (Frankfurt) Region http://s3-eu-central-1.amazonaws.com/aws-codedeploy-eu-central-1/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the Asia Pacific (Tokyo) Region http://s3-ap-northeast-1.amazonaws.com/aws-codedeploy-ap-northeast-1/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the Asia Pacific (Seoul) Region http://s3-ap-northeast-2.amazonaws.com/aws-codedeploy-ap-northeast-2/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the Asia Pacific (Singapore) Region http://s3-ap-southeast-1.amazonaws.com/aws-codedeploy-ap-southeast-1/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the Asia Pacific (Sydney) Region http://s3-ap-southeast-2.amazonaws.com/aws-codedeploy-ap-southeast-2/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the Asia Pacific (Mumbai) Region http://s3-ap-south-1.amazonaws.com/aws-codedeploy-ap-south-1/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the South America (São Paulo) Region http://s3-sa-east-1.amazonaws.com/aws-codedeploy-sa-east-1/samples/latest/SampleApp_Linux.zip
    For Amazon EC2 instances launched in the China (Beijing) Region https://s3.cn-north-1.amazonaws.com.cn/aws-codedeploy-cn-north-1/samples/latest/SampleApp_Linux.zip

    For Windows Server Amazon EC2 instances:

    For Amazon EC2 instances launched in the US East (Ohio) Region http://s3-us-east-2.amazonaws.com/aws-codedeploy-us-east-2/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the US East (N. Virginia) Region http://s3.amazonaws.com/aws-codedeploy-us-east-1/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the US West (N. California) Region http://s3-us-west-1.amazonaws.com/aws-codedeploy-us-west-1/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the US West (Oregon) Region http://s3-us-west-2.amazonaws.com/aws-codedeploy-us-west-2/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the Canada (Central) Region http://s3-ca-central-1.amazonaws.com/aws-codedeploy-ca-central-1/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the EU (Ireland) Region http://s3-eu-west-1.amazonaws.com/aws-codedeploy-eu-west-1/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the EU (London) Region http://s3-eu-west-2.amazonaws.com/aws-codedeploy-eu-west-1/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the EU (Frankfurt) Region http://s3-eu-central-1.amazonaws.com/aws-codedeploy-eu-central-1/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the Asia Pacific (Tokyo) Region http://s3-ap-northeast-1.amazonaws.com/aws-codedeploy-ap-northeast-1/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the Asia Pacific (Seoul) Region http://s3-ap-northeast-2.amazonaws.com/aws-codedeploy-ap-northeast-2/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the Asia Pacific (Singapore) Region http://s3-ap-southeast-1.amazonaws.com/aws-codedeploy-ap-southeast-1/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the Asia Pacific (Sydney) Region http://s3-ap-southeast-2.amazonaws.com/aws-codedeploy-ap-southeast-2/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the Asia Pacific (Mumbai) Region http://s3-ap-south-1.amazonaws.com/aws-codedeploy-ap-south-1/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the South America (São Paulo) Region http://s3-sa-east-1.amazonaws.com/aws-codedeploy-sa-east-1/samples/latest/SampleApp_Windows.zip
    For Amazon EC2 instances launched in the China (Beijing) Region https://s3.cn-north-1.amazonaws.com.cn/aws-codedeploy-cn-north-1/samples/latest/SampleApp_Windows.zip

    For Ubuntu Server Amazon EC2 instances, type the location of your custom application revision stored in Amazon S3.

  15. Leave the Deployment description box blank.

  16. With CodeDeployDefault.OneAtATime selected in the Deployment configuration drop-down list, choose Deploy.

    Note

    To update the deployment's current status, refresh the page in your browser.

    If Failed appears instead of Succeeded, you may want to try some of the techniques in Monitor and Troubleshoot Your Deployment (using the application name of SimpleDemoApp and the deployment group name of SimpleDemoDG).