Skip to content

rackspace-infrastructure-automation/aws-terraform-codedeploy

Repository files navigation

aws-terraform-codedeploy

This module creates a CodeDeploy deployment group and optionally a CodeDeploy application.

Basic Usage

module "codedeploy_prod" {
  source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-codedeploy//?ref=v0.12.0"

  application_name   = "MyCodeDeployApp"
  autoscaling_groups = ["myASG"]
  environment        = "Prod"
}

Full working references are available at examples

Limitations

AWS APIs do not properly clear out the load_balancer_info field of a deployment group after removing the CLB\Target group reference. This results in the Deployment Group trying to apply the change on every update. We hope this behavior to be resolved after adapting Terraform v0.12. In the meantime, a new Deployment Group should be created if the load balancer information must be removed. This issue does not occur when replacing the referenced CLB or Target Group, or when switching between CLB and Target Groups, only when the references are completely removed.

Terraform 0.12 upgrade

Several changes were required while adding terraform 0.12 compatibility. The following changes should be
made when upgrading from a previous release to version 0.12.0 or higher.

Terraform State File

Several resources were updated with new logical names, better meet current Rackspace style guides.
The following statements can be used to update existing resources. In each command, <MODULE_NAME>
should be replaced with the logic name used where the module is referenced.

terraform state mv module.<MODULE_NAME>.aws_iam_role_policy_attachment.AWSCodeDeployRole module.<MODULE_NAME>.aws_iam_role_policy_attachment.code_deploy_policy_attachment

Providers

Name Version
aws >= 2.7.0

Inputs

Name Description Type Default Required
application_name CodeDeploy Application Name. If an existing Application is being associated, 'create_application' should be set to false string n/a yes
autoscaling_groups A List of Autoscaling Group names to associate with the Deployment Group list(string) [] no
clb_name The name of the CLB to associate with this Deployment Group. If associated, the instances will be taken out of service while the application is deployed. This variable cannot be used in conjunction with target_group_name. string "" no
create_application Boolean variable controlling if a new CodeDeploy application should be created. bool true no
deployment_config_name CodeDeploy Deployment Config Name to use as the default for this Deployment Group. Valid values include 'CodeDeployDefault.OneAtATime', 'CodeDeployDefault.HalfAtATime', and 'CodeDeployDefault.AllAtOnce' string "CodeDeployDefault.OneAtATime" no
deployment_group_name CodeDeploy Deployment Group Name. If omitted, name will be based on Application Group and Environment string "" no
ec2_tag_key Tag key for the Deployment Groups EC2 Tag Filter. If omitted, no EC2 Tag Filter will be applied. string "" no
ec2_tag_value Tag value for the Deployment Groups EC2 Tag Filter. string "" no
environment Application environment for which this infrastructure is being created. e.g. Development/Production. string "Production" no
target_group_name The name of the Target Group to associate with this Deployment Group. If associated, the instances will be taken out of service while the application is deployed. This variable cannot be used in conjunction with clb_name. string "" no

Outputs

Name Description
application_name CodeDeploy Application Name
deployment_group_iam_role IAM Role associated to the CodeDeploy Deployment Group
deployment_group_iam_role_arn IAM Role associated to the CodeDeploy Deployment Group
deployment_group_name CodeDeploy Application Name