Amazon CloudFormation templates for CodeDeploy reference
This section introduces the Amazon CloudFormation resources, transform, and hook designed to work with CodeDeploy deployments. For a walkthrough of creating a stack update managed by the Amazon CloudFormation hook for CodeDeploy, see Create an Amazon ECS blue/green deployment through Amazon CloudFormation
Note
Amazon CloudFormation hooks are part of the Amazon CloudFormation components for Amazon and are different from CodeDeploy lifecycle event hooks.
In addition to the other methods available to you in CodeDeploy, you can use Amazon CloudFormation templates to perform the following tasks:
-
Create applications.
-
Create deployment groups and specify a target revision.
-
Create deployment configurations.
-
Create Amazon EC2 instances.
Amazon CloudFormation is a service that helps you model and set up your Amazon resources using templates. An Amazon CloudFormation template is a text file whose format complies with the JSON standard. You create a template that describes all of the Amazon resources you want, and Amazon CloudFormation takes care of provisioning and configuring those resources for you.
For more information, see What is Amazon CloudFormation? and Working with Amazon CloudFormation templates in Amazon CloudFormation User Guide.
If you plan to use Amazon CloudFormation templates that are compatible with CodeDeploy in your organization, as an administrator, you must grant access to Amazon CloudFormation and to the Amazon services and actions on which Amazon CloudFormation depends. To grant permissions to create applications, deployment groups, and deployment configurations, add the following policy to the permission set of the users who will work with Amazon CloudFormation:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "cloudformation:*" ], "Resource": "*" } ] }
For more information about policies, see the following topics:
-
To view the policy that must be added to the permission set of users who will create Amazon EC2 instances, see Create an Amazon EC2 instance for CodeDeploy (Amazon CloudFormation template).
-
For information about adding policies to permission sets, see Create a permission set in the IAM User Guide.
-
To learn how to restrict users to a limited set of CodeDeploy actions and resources, see Amazon managed (predefined) policies for CodeDeploy.
The following table shows the actions an Amazon CloudFormation template can perform on your behalf and includes links to more information about the Amazon resource types and their property types you can add to an Amazon CloudFormation template.
Action | Amazon CloudFormation reference | Reference type |
---|---|---|
Create a CodeDeploy application. | AWS::CodeDeploy::application | Amazon CloudFormation resource |
Create and specify the details for a deployment group to be used to deploy your application revisions. ¹ | AWS::CodeDeploy::DeploymentGroup | Amazon CloudFormation resource |
Create a set of deployment rules, deployment success conditions, and deployment failure conditions that CodeDeploy will use during a deployment. | AWS::CodeDeploy::DeploymentConfig | Amazon CloudFormation resource |
Create an Amazon EC2 instance. ² | AWS::EC2::instance | Amazon CloudFormation resource |
Use the Amazon CloudFormation AWS::CodeDeployBlueGreen
transform and AWS::CodeDeploy::BlueGreen hook to manage stack
updates, create resources, and shift traffic for CodeDeploy blue/green
deployments.3 |
AWS::CodeDeployBlueGreen | The AWS::CodeDeployBlueGreen transform is a macro hosted by
Amazon CloudFormation |
AWS::CodeDeploy::BlueGreen | The AWS::CodeDeploy::BlueGreen hook is structured as a
Hook resource in Amazon CloudFormation. The hook includes parameters that
take the place of your CodeDeploy AppSpec file by pointing to designated CodeDeploy
lifecycle event hooks. |
|
¹ If you specify the version of the application revision that you want to be deployed as part of the deployment group, your target revision will be deployed as soon as the provisioning process is complete. For more information about template configuration, see CodeDeploy DeploymentGroup deployment revision S3Location and CodeDeploy DeploymentGroup deployment revision GitHubLocation in the Amazon CloudFormation User Guide. ² We provide templates you can use to create Amazon EC2 instances in the regions in which CodeDeploy is supported. For more information about using these templates, see Create an Amazon EC2 instance for CodeDeploy (Amazon CloudFormation template). 3Only Amazon ECS blue/green deployments are supported by this deployment configuration. For more information about deployment configurations for Amazon ECS blue/green deployments through Amazon CloudFormation, see Deployment configurations for Amazon CloudFormation blue/green deployments (Amazon ECS). For more information about Amazon ECS blue/green deployments through Amazon CloudFormation and how to view your deployment in CodeDeploy, see Create an Amazon ECS blue/green deployment through Amazon CloudFormation. |