Deploying to AWS CodeDeploy

Components

The deployment of an artifact to AWS CodeDeploy involves several major components as follows:

  • Application – A name that uniquely identifies the application that you want to deploy.

  • Application RevisionAn archive file containing source content – such as source code, web pages, executable files, and deployment scripts – along with an Application Specification File (AppSpec file). Revisions are stored in Amazon S3 buckets or GitHub repositories.

  • Deployment ConfigurationA set of deployment rules and deployment success and failure conditions that AWS CodeDeploy uses during a deployment.

  • Deployment GroupA set of individual instances. A deployment group contains individually-tagged Amazon EC2 instances, Amazon EC2 instances in Auto Scaling groups, or both.

Workflow

The deployment workflow is illustrated by the following diagram:

The binding between those components is established indirectly and comprises the following activities:

  1. (Optional) Create an application, if it hasn't been provisioned already (be it manually or via CloudFormation) – see the Create Application action of the AWS CodeDeploy Application task

    1. (Optional) Create a deployment group – see the Create Deployment Group action of the AWS CodeDeploy Deployment Group task
      the target instances can be provisioned with AWS CloudFormation for example – see the Create Stack action of the AWS CloudFormation Stack task

    2. Specify a deployment group

    3. (Optional) Specify a deployment configuration

  2. Commit or upload the application source code (the 'Revision') – see the Upload File(s) action of the Amazon S3 Object task

  3. Deploy an application revision for that application – see the Create Deployment action of the AWS CodeDeploy Deployment task

  • the AWS CodeDeploy Agent on each participating instance pulls the revision from the specified Amazon S3 bucket or GitHub repository and starts deploying the contents to that instance, following the instructions in the AppSpec file that's provided

Alternative workflow via CloudFormation

As an alternative to using the AWS CodeDeploy tasks built into Tasks for AWS, it is also possible to provision the CodeDeploy components directly via the AWS CloudFormation Stack task and the corresponding CloudFormation resource types:

A typical workflow based on CloudFormation might look as follows:

  1. Commit or upload the application source code (the 'Revision') – see the Upload File(s) action of the Amazon S3 Object task

  2. Create/Update the CloudFormation stack that provisions the CodeDeploy application and deployment group – see the Create Stack action of the AWS CloudFormation Stack task

    1. You can use the Update stack, if it already exists option to reuse the same Bamboo job for both actions

    2. The deployment is not modeled as a resource of its own, rather as a property of the AWS::CodeDeploy::DeploymentGroup resource that specifies the AWS CodeDeploy application revision that will be deployed to the deployment group.

Frequently Asked Questions (FAQ)