AWS CodeDeploy Deployment Group

This page shows how to write Terraform and CloudFormation for CodeDeploy Deployment Group and write them securely.

aws_codedeploy_deployment_group (Terraform)

The Deployment Group in CodeDeploy can be configured in Terraform with the resource name aws_codedeploy_deployment_group. The following sections describe 4 examples of how to use the resource and its parameters.

Example Usage from GitHub
resource "aws_codedeploy_deployment_group" "dev" {
  deployment_group_name  = "dev"
  app_name               = var.app_name
  service_role_arn       = var.service_role
  deployment_config_name = "CodeDeployDefault.AllAtOnce"
resource "aws_codedeploy_deployment_group" "aip-smartall-api-deploy-group" {
  deployment_group_name   = "prd-aip-deploy-group"
  deployment_config_name  = "CodeDeployDefault.AllAtOnce"
  app_name                =
  service_role_arn        = data.aws_iam_role.prd-com-codedeploy-role.arn
  autoscaling_groups      = [ "prd-aip-smartall-api-ag"]
resource "aws_codedeploy_deployment_group" "demo-dev-deploy-group" {
  app_name              =
  deployment_group_name = "demo-dev-deploy-group"
  service_role_arn      = aws_iam_role.code-deploy.arn

  ec2_tag_set {
resource "aws_codedeploy_deployment_group" "codedeploy_group_WEB" {
    app_name =
    deployment_group_name = "70491-codedeploy-group_WEB"
    deployment_config_name = "CodeDeployDefault.AllAtOnce"
    service_role_arn = aws_iam_role.codedeploy_role.arn

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).


Explanation in Terraform Registry

Provides a CodeDeploy Deployment Group for a CodeDeploy Application

NOTE on blue/green deployments: When using green_fleet_provisioning_option with the COPY_AUTO_SCALING_GROUP action, CodeDeploy will create a new ASG with a different name. This ASG is not managed by terraform and will conflict with existing configuration and state. You may want to use a different approach to managing deployments that involve multiple ASG, such as DISCOVER_EXISTING with separate blue and green ASG.

AWS::CodeDeploy::DeploymentGroup (CloudFormation)

The DeploymentGroup in CodeDeploy can be configured in CloudFormation with the resource name AWS::CodeDeploy::DeploymentGroup. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.


Explanation in CloudFormation Registry

The AWS::CodeDeploy::DeploymentGroup resource creates an AWS CodeDeploy deployment group that specifies which instances your application revisions are deployed to, along with other deployment options. For more information, see CreateDeploymentGroup in the CodeDeploy API Reference. Note Amazon ECS blue/green deployments through CodeDeploy do not use the AWS::CodeDeploy::DeploymentGroup resource. To perform Amazon ECS blue/green deployments, use the AWS::CodeDeploy::BlueGreen hook. See Perform Amazon ECS blue/green deployments through CodeDeploy using AWS CloudFormation for more information.

Frequently asked questions

What is AWS CodeDeploy Deployment Group?

AWS CodeDeploy Deployment Group is a resource for CodeDeploy of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS CodeDeploy Deployment Group?

For Terraform, the ChicagoWorldcon/infrastructure, pe-woongjin/wjtb-code-deploy-tf and kujalk/CI-CD-pipeline-AWS source code examples are useful. See the Terraform Example section for further details.