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

Step 5: Try the AWS CodeDeploy Create Deployment Walkthrough

This walkthrough guides you through the steps required to deploy a revision to one or more Amazon EC2 instances. For this walkthrough, we assume you have no prior experience with AWS CodeDeploy and have not yet created any resources, such as applications, application revisions, or deployment groups in AWS CodeDeploy .

This walkthrough refers to components and concepts that are unique to AWS CodeDeploy. To familiarize yourself with them before you start, see Key Components.

Video Walkthrough of a Sample AWS CodeDeploy Deployment

This short video (5:01) walks you through a sample AWS CodeDeploy deployment using the AWS CodeDeploy console.

Prerequisites

If you want AWS CodeDeploy to create some sample Amazon EC2 instances, you must have an Amazon EC2 instance key pair. To create an Amazon EC2 instance key pair, follow the instructions in Creating Your Key Pair Using Amazon EC2. Be sure your Amazon EC2 instance key pair is created in one of the regions listed in Region and Endpoints in the AWS General Reference. You must create an Amazon EC2 instance key pair before you start this walkthrough. Otherwise, it will not appear in the Key Pair Name drop-down list on the Instance Settings page.

If you use the AWS CloudFormation template to launch Amazon EC2 instances, the calling IAM user must have access to AWS CloudFormation and AWS services and actions on which AWS CloudFormation depends. If you have not followed the steps in Getting Started to provision the calling IAM user, you must at least attach the following policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "cloudformation:*",
        "codedeploy:*",
        "ec2:*",
        "iam:AddRoleToInstanceProfile",        
        "iam:CreateInstanceProfile",
        "iam:CreateRole",
        "iam:DeleteInstanceProfile",
        "iam:DeleteRole",
        "iam:DeleteRolePolicy",
        "iam:GetRole",
        "iam:PassRole",
        "iam:PutRolePolicy",
        "iam:RemoveRoleFromInstanceProfile"
      ],
      "Resource": "*"
    }
  ]
}

The following portion of the policy is what grants the calling IAM user access to the IAM actions required to create the service role.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "iam:CreateRole",
        "iam:PutRolePolicy"
      ],
      "Resource": "*"
    }
  ]
}       

The following portion of the policy is what grants the calling IAM user permission to create applications and deployment groups and deploy applications.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "codedeploy:*"
      ],
      "Resource": "*"
    }
  ]
}       

Start the Walkthrough

To start the walkthrough:

  1. 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.

  2. If an introductory page appears, choose Get Started Now. If the Applications page appears, in Additional Information, choose Create Deployment Walkthrough.

Step 1: Welcome

Choose Sample Deployment, and then choose Next Step.

Step 2: Instance Settings

If you have Amazon EC2 instances that are already configured for use in AWS CodeDeploy deployments, choose Skip This Step, read and follow the instructions, and then proceed to Step 3: Application Name.

If you want AWS CodeDeploy to launch a new set of Amazon EC2 instances:

  1. Next to Operating System, choose Amazon Linux or Windows Server.

    Important

    You may be billed for the Amazon EC2 instances launched by AWS CodeDeploy, so be sure to terminate them after you've completed the walkthrough. In this walkthrough, an AWS CloudFormation template is used to launch these Amazon EC2 instances. To delete the AWS CloudFormation stack created to launch the Amazon EC2 instances, see Deleting a Stack on the AWS CloudFormation Console. The stack name will start with CodeDeploySampleStack.

  2. From the Key Pair Name drop-down list, choose the Amazon EC2 instance key pair you will use to connect to the Amazon EC2 instances.

    Note

    To create an Amazon EC2 instance key pair, follow the instructions in Creating Your Key Pair Using Amazon EC2. Be sure your key pair is created in one of the regions listed in Region and Endpoints in the AWS General Reference. The new Amazon EC2 instance key pair may not appear in the Key Pair Name drop-down list until you restart the walkthrough.

  3. Leave the defaults for Tag Key and Value. AWS CodeDeploy will use this tag key and value to locate the instances during deployments.

    If you want to override the proposed tag key and value (for example, if you are running through this walkthrough multiple times without terminating any previously created Amazon EC2 instances), we suggest you leave the tag key of Name in the Key box and type a different tag value in the Value box. For information about Amazon EC2 instance tags, see Tagging Your Amazon EC2 Resources.

  4. Choose Launch Instances.

    If you choose See more details in AWS CloudFormation, the AWS CloudFormation console will open in a separate web browser tab. Look for a stack that starts with CodeDeploySampleStack. When CREATE_COMPLETE appears in the Status column, your Amazon EC2 instances have been launched. (This may take several minutes.)

  5. To continue, choose Next Step.

Step 3: Application Name

In the Application Name box, leave the proposed application name or, if you prefer, type a different name, and choose Next Step.

Step 4: Revision

Review the information about our sample application revision, and choose Next Step.

Tip

If you want to examine the content of our sample revision, choose Download Sample Bundle, and follow your web browser's instructions to download and view the content.

If you chose Skip This Step in Step 2: Instance Settings, from the Revision Type drop-down list, choose the type of application revision that corresponds to the Amazon EC2 instances type (Amazon Linux or Windows Server).

Step 5: Deployment Group

  1. In the Deployment Group Name box, leave the proposed deployment group name or, if you prefer, type a different name.

  2. The key and value of the key-value pair you specified in the Instance Settings page (for example, Name and CodeDeployDemo) should appear.

    If you chose Skip This Step in Step 2: Instance Settings, in Add Instances, overwrite the values of the Key and Value boxes with the key and value of the key-value pair for your Amazon EC2 instances.

    Optionally, if your Amazon EC2 instances have multiple key-value pairs, you can type them into the blank row. A new blank row appears so you can add another key-value pair. You can add up to 10 key-value pairs. Choose the remove icon to remove a key-value pair from the list.

    Tip

    AWS CodeDeploy displays the number of instances that match each key-value pair. To view instances in the Amazon EC2 console, click the number.

    If you are using our AWS CloudFormation template to launch new Amazon EC2 instances, and the number is larger than you're expecting, choose Cancel, start the walkthrough from the beginning, and in Step 2: Instance Settings, specify a tag value different from the default . (Be sure to delete the AWS CloudFormation stack to terminate the Amazon EC2 instances.)

    If you are using your own Amazon EC2 instances, add a new tag key and value to your Amazon EC2 instances, and then specify a tag key and value different from the default in Add Instances.

  3. If you have an Auto Scaling group to add to the deployment group, choose Search by Auto Scaling Group Names, and then type the Auto Scaling group name. You can add up to 10 Auto Scaling groups. Choose the remove icon to remove an Auto Scaling group from the list.

    Tip

    AWS CodeDeploy displays the number of Amazon EC2 instances that match each Auto Scaling group name. To view instances in the Amazon EC2 console, click the number.

  4. Choose Next Step.

Step 6: Service Role

Choose Create a new service role or Use an existing service role.

If you are using this walkthrough for the first time, we recommend you choose Create a new service role, choose Next Step to accept the default name, and then proceed to Step 7: Deployment Configuration.

If you already have a service role, choose Use an existing service role, choose it from the Role Name drop-down list, and then choose Next Step.

Step 7: Deployment Configuration

  1. To use a built-in configuration for this deployment, choose Default Deployment Configurations. To create your own configuration for this deployment, choose Create Custom Deployment Configuration.

  2. If you chose Default Deployment Configurations and want to use a configuration different from the one selected, next to the desired configuration, choose Select. Choose Next Step, and proceed to Step 8: Review.

  3. If you chose Create Custom Deployment Configuration:

    1. In the Deployment Config Name box, type a unique name for the configuration.

    2. Use the Number or Percentage box to type either the number or percentage of total Amazon EC2 instances that should be available during the deployment.

    3. Choose Next Step.

Step 8: Review

  1. If you need to make changes, choose one of the Edit links. After you've made your changes, choose Next Step until you return to the Step 8: Review page, and then choose Deploy Now.

  2. Choose the Refresh button next to the table to get deployment status. To get information about the deployment, see View Instance Details (Console).

  3. Our sample revision deploys a single web page to each instance. You can use your web browser to verify the deployment was successful by going to http://PublicDNS for each instance (for example, http://ec2-01-234-567-890.compute-1.amazonaws.com). The web page will display a message of congratulations.

    To get the public DNS value, in the Amazon EC2 console, choose the Amazon EC2 instance. On the Description tab, look for the value in Public DNS.

Clean Up

To avoid future charges, you must clean up the resources used in this walkthrough. If you used our AWS CloudFormation template to launch Amazon EC2 instances, delete the AWS CloudFormation stack. This will terminate the instances and their associated resources.

If you launched your own Amazon EC2 instances just for this walkthrough, you should terminate them. Optionally, you can delete the deployment component records associated with this walkthrough from the AWS CodeDeploy console.

To delete the AWS CloudFormation stack

  1. Sign in to the AWS Management Console and open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation/.

  2. In the Stack Name column, select the box for the stack starting with CodeDeploySampleStack.

  3. Choose Delete Stack.

  4. When prompted, choose Yes, Delete. The Amazon EC2 instances will be terminated. The associated IAM instance profile and service role will be deleted.

To terminate Amazon EC2 instances

  1. Sign in to the AWS Management Console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, under Instances, choose Instances.

  3. Select the box for each Amazon EC2 instance to terminate.

  4. Choose Actions, point to Instance State, and then choose Terminate.

  5. When prompted, choose Yes, Terminate.

To delete AWS CodeDeploy deployment component records

  1. 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.

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

  3. On the Applications page, choose the application to delete.

  4. At the bottom of the Application details page, choose Delete application.

  5. When prompted, type the name of the application, and then choose Delete.

    All records about the application and its associated deployment groups, revisions, and deployments will be deleted.