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 = aws_codedeploy_app.aip-smartall-api.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 = aws_codedeploy_app.demo-deploy.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 = aws_codedeploy_app.codedeploy_app_WEB.name
deployment_group_name = "70491-codedeploy-group_WEB"
deployment_config_name = "CodeDeployDefault.AllAtOnce"
service_role_arn = aws_iam_role.codedeploy_role.arn
Parameters
-
app_namerequired - string -
arnoptional computed - string -
autoscaling_groupsoptional - set of string -
compute_platformoptional computed - string -
deployment_config_nameoptional - string -
deployment_group_idoptional computed - string -
deployment_group_namerequired - string -
idoptional computed - string -
service_role_arnrequired - string -
tagsoptional - map from string to string -
alarm_configurationlist block-
alarmsoptional - set of string -
enabledoptional - bool -
ignore_poll_alarm_failureoptional - bool
-
-
auto_rollback_configurationlist block -
blue_green_deployment_configlist block-
deployment_ready_optionlist block-
action_on_timeoutoptional - string -
wait_time_in_minutesoptional - number
-
-
green_fleet_provisioning_optionlist block-
actionoptional - string
-
-
terminate_blue_instances_on_deployment_successlist block-
actionoptional - string -
termination_wait_time_in_minutesoptional - number
-
-
-
deployment_stylelist block-
deployment_optionoptional - string -
deployment_typeoptional - string
-
-
ec2_tag_filterset block -
ec2_tag_setset block-
ec2_tag_filterset block
-
-
ecs_servicelist block-
cluster_namerequired - string -
service_namerequired - string
-
-
load_balancer_infolist block-
elb_infoset block-
nameoptional - string
-
-
target_group_infoset block-
nameoptional - string
-
-
target_group_pair_infolist block-
prod_traffic_routelist block-
listener_arnsrequired - set of string
-
-
target_grouplist block-
namerequired - string
-
-
test_traffic_routelist block-
listener_arnsrequired - set of string
-
-
-
-
on_premises_instance_tag_filterset block -
trigger_configurationset block-
trigger_eventsrequired - set of string -
trigger_namerequired - string -
trigger_target_arnrequired - string
-
Explanation in Terraform Registry
Provides a CodeDeploy Deployment Group for a CodeDeploy Application
NOTE on blue/green deployments: When using
green_fleet_provisioning_optionwith theCOPY_AUTO_SCALING_GROUPaction, 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 asDISCOVER_EXISTINGwith 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.
Parameters
-
AlarmConfigurationoptional - AlarmConfiguration -
ApplicationNamerequired - String -
AutoRollbackConfigurationoptional - AutoRollbackConfiguration -
AutoScalingGroupsoptional - List -
BlueGreenDeploymentConfigurationoptional - BlueGreenDeploymentConfiguration -
Deploymentoptional - Deployment -
DeploymentConfigNameoptional - String -
DeploymentGroupNameoptional - String -
DeploymentStyleoptional - DeploymentStyle -
ECSServicesoptional - List of ECSService -
Ec2TagFiltersoptional - List of EC2TagFilter -
Ec2TagSetoptional - EC2TagSet -
LoadBalancerInfooptional - LoadBalancerInfo -
OnPremisesInstanceTagFiltersoptional - List of TagFilter -
OnPremisesTagSetoptional - OnPremisesTagSet -
ServiceRoleArnrequired - String -
TriggerConfigurationsoptional - List of TriggerConfig
Explanation in CloudFormation Registry
The
AWS::CodeDeploy::DeploymentGroupresource 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 theAWS::CodeDeploy::DeploymentGroupresource. To perform Amazon ECS blue/green deployments, use theAWS::CodeDeploy::BlueGreenhook. 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.