From 1bd18bd7f33435a390a9eff46511aa7efbc82f75 Mon Sep 17 00:00:00 2001 From: Giovanni Del Valle Date: Wed, 4 Mar 2020 18:23:04 -0600 Subject: [PATCH 1/3] reference updates --- README.md | 38 +++++++++++++++----------- examples/deploy_group_alb.tf | 10 +++---- examples/deploy_group_clb.tf | 10 +++---- examples/multiple_deployment_groups.tf | 12 ++++---- main.tf | 24 ++++++++-------- tests/test1/main.tf | 8 +++--- 6 files changed, 54 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 2f7246a..c532a2b 100644 --- a/README.md +++ b/README.md @@ -6,33 +6,39 @@ This module creates a CodeDeploy deployment group and optionally a CodeDeploy ap ``` module "codedeploy_prod" { -source = "../codedeploy" + source = "../codedeploy" - application_name = "MyCodeDeployApp" - autoscaling_groups = ["${module.asg_prod.asg_name_list}"] - environment = "Prod" + application_name = "MyCodeDeployApp" + autoscaling_groups = ["${module.asg_prod.asg_name_list}"] + environment = "Prod" } ``` Full working references are available at [examples](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 thereferences are completely removed. +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. + +## Providers + +| Name | Version | +|------|---------| +| aws | n/a | ## 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 | `` | 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. | string | `"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 | +|------|-------------|------|---------|:-----:| +| 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` | `[]` | 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. | `string` | `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 diff --git a/examples/deploy_group_alb.tf b/examples/deploy_group_alb.tf index 00b7bb3..90adc04 100644 --- a/examples/deploy_group_alb.tf +++ b/examples/deploy_group_alb.tf @@ -24,13 +24,13 @@ data "aws_ami" "amz_linux_2" { } module "vpc" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork//?ref=v0.0.4" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork//?ref=v0.0.10" vpc_name = "Test1VPC" } module "security_groups" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=v0.0.5" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=v0.0.6" resource_name = "Test-SG" vpc_id = "${module.vpc.vpc_id}" @@ -38,7 +38,7 @@ module "security_groups" { } module "alb" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-alb//?ref=v0.0.6" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-alb//?ref=v0.0.11" alb_name = "CodeDeployExample-ALB" create_logging_bucket = false @@ -62,7 +62,7 @@ module "alb" { } module "asg" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_asg//?ref=v0.0.6" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_asg//?ref=v0.0.24" ec2_os = "amazon" image_id = "${data.aws_ami.amz_linux_2.image_id}" @@ -77,7 +77,7 @@ module "asg" { } module "codedeploy" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-codedeploy//?ref=v0.0.1" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-codedeploy//?ref=v0.0.3" application_name = "MyCodeDeployApp" autoscaling_groups = ["${module.asg.asg_name_list}"] diff --git a/examples/deploy_group_clb.tf b/examples/deploy_group_clb.tf index 7a41d7d..81fce3b 100644 --- a/examples/deploy_group_clb.tf +++ b/examples/deploy_group_clb.tf @@ -24,13 +24,13 @@ data "aws_ami" "amz_linux_2" { } module "vpc" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork//?ref=v0.0.4" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork//?ref=v0.0.10" vpc_name = "Test1VPC" } module "security_groups" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=v0.0.5" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=v0.0.6" resource_name = "Test-SG" vpc_id = "${module.vpc.vpc_id}" @@ -38,7 +38,7 @@ module "security_groups" { } module "clb" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-clb//?ref=v0.0.2" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-clb//?ref=v0.0.8" clb_name = "CodeDeployExample-CLB" instances = [] @@ -57,7 +57,7 @@ module "clb" { } module "asg" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_asg//?ref=v0.0.6" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_asg//?ref=v0.0.24" ec2_os = "amazon" image_id = "${data.aws_ami.amz_linux_2.image_id}" @@ -72,7 +72,7 @@ module "asg" { } module "codedeploy" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-codedeploy//?ref=v0.0.1" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-codedeploy//?ref=v0.0.3" application_name = "MyCodeDeployApp" autoscaling_groups = ["${module.asg.asg_name_list}"] diff --git a/examples/multiple_deployment_groups.tf b/examples/multiple_deployment_groups.tf index 5aac9ca..7ae650f 100644 --- a/examples/multiple_deployment_groups.tf +++ b/examples/multiple_deployment_groups.tf @@ -24,13 +24,13 @@ data "aws_ami" "amz_linux_2" { } module "vpc" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork//?ref=v0.0.4" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork//?ref=v0.0.10" vpc_name = "Test1VPC" } module "security_groups" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=v0.0.5" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=v0.0.6" resource_name = "Test-SG" vpc_id = "${module.vpc.vpc_id}" @@ -38,7 +38,7 @@ module "security_groups" { } module "asg_prod" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_asg//?ref=v0.0.6" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_asg//?ref=v0.0.24" ec2_os = "amazon" image_id = "${data.aws_ami.amz_linux_2.image_id}" @@ -52,7 +52,7 @@ module "asg_prod" { } module "asg_test" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_asg//?ref=v0.0.6" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_asg//?ref=v0.0.24" ec2_os = "amazon" image_id = "${data.aws_ami.amz_linux_2.image_id}" @@ -66,7 +66,7 @@ module "asg_test" { } module "codedeploy_prod" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-codedeploy//?ref=v0.0.1" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-codedeploy//?ref=v0.0.3" application_name = "MyCodeDeployApp" autoscaling_groups = ["${module.asg_prod.asg_name_list}"] @@ -74,7 +74,7 @@ module "codedeploy_prod" { } module "codedeploy_test" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-codedeploy//?ref=v0.0.1" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-codedeploy//?ref=v0.0.3" application_name = "${module.codedeploy_prod.application_name}" create_application = false diff --git a/main.tf b/main.tf index b58b187..821c974 100644 --- a/main.tf +++ b/main.tf @@ -1,24 +1,24 @@ -/** +/* * # aws-terraform-codedeploy * - *This module creates a CodeDeploy deployment group and optionally a CodeDeploy application. + * This module creates a CodeDeploy deployment group and optionally a CodeDeploy application. * - *## Basic Usage + * ## Basic Usage * - *``` - *module "codedeploy_prod" { - *source = "../codedeploy" + * ``` + * module "codedeploy_prod" { + * source = "../codedeploy" * - * application_name = "MyCodeDeployApp" - * autoscaling_groups = ["${module.asg_prod.asg_name_list}"] - * environment = "Prod" - *} - *``` + * application_name = "MyCodeDeployApp" + * autoscaling_groups = ["${module.asg_prod.asg_name_list}"] + * environment = "Prod" + * } + * ``` * * Full working references are available at [examples](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 thereferences are completely removed. + * 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. */ locals { diff --git a/tests/test1/main.tf b/tests/test1/main.tf index 5dcda92..58a0fd3 100644 --- a/tests/test1/main.tf +++ b/tests/test1/main.tf @@ -36,13 +36,13 @@ data "aws_ami" "amz_linux_2" { } module "vpc" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork//?ref=tf_v0.11" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork//?ref=v0.0.10" vpc_name = "${random_string.rstring.result}-VPC" } module "security_groups" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=tf_v0.11" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=v0.0.6" resource_name = "${random_string.rstring.result}-SG" vpc_id = "${module.vpc.vpc_id}" @@ -50,7 +50,7 @@ module "security_groups" { } module "alb" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-alb//?ref=tf_v0.11" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-alb//?ref=v0.0.11" alb_name = "${random_string.rstring.result}-ALB" create_logging_bucket = false @@ -74,7 +74,7 @@ module "alb" { } module "clb" { - source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-clb//?ref=master" + source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-clb//?ref=v0.0.8" clb_name = "${random_string.rstring.result}-CLB" instances = [] From 9b2b68af04d61612180ad49c969dae6af2263c99 Mon Sep 17 00:00:00 2001 From: Giovanni Del Valle Date: Wed, 4 Mar 2020 18:37:59 -0600 Subject: [PATCH 2/3] sort variables --- variables.tf | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/variables.tf b/variables.tf index d342467..39e6c5c 100644 --- a/variables.tf +++ b/variables.tf @@ -5,14 +5,8 @@ variable "application_name" { variable "autoscaling_groups" { description = "A List of Autoscaling Group names to associate with the Deployment Group" - type = "list" default = [] -} - -variable "create_application" { - description = "Boolean variable controlling if a new CodeDeploy application should be created." - type = "string" - default = true + type = "list" } variable "clb_name" { @@ -21,38 +15,44 @@ variable "clb_name" { default = "" } +variable "create_application" { + description = "Boolean variable controlling if a new CodeDeploy application should be created." + default = true + type = "string" +} + variable "deployment_config_name" { description = "CodeDeploy Deployment Config Name to use as the default for this Deployment Group. Valid values include 'CodeDeployDefault.OneAtATime', 'CodeDeployDefault.HalfAtATime', and 'CodeDeployDefault.AllAtOnce'" - type = "string" default = "CodeDeployDefault.OneAtATime" + type = "string" } variable "deployment_group_name" { description = "CodeDeploy Deployment Group Name. If omitted, name will be based on Application Group and Environment" - type = "string" default = "" + type = "string" } variable "ec2_tag_key" { description = "Tag key for the Deployment Groups EC2 Tag Filter. If omitted, no EC2 Tag Filter will be applied." - type = "string" default = "" + type = "string" } variable "ec2_tag_value" { description = "Tag value for the Deployment Groups EC2 Tag Filter." - type = "string" default = "" + type = "string" } variable "environment" { description = "Application environment for which this infrastructure is being created. e.g. Development/Production." - type = "string" default = "Production" + type = "string" } variable "target_group_name" { description = "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." - type = "string" default = "" + type = "string" } From d634c07e7b55d0cde5d4cf96548f5b8f85581117 Mon Sep 17 00:00:00 2001 From: Giovanni Del Valle Date: Wed, 4 Mar 2020 21:18:00 -0600 Subject: [PATCH 3/3] more sorting --- examples/deploy_group_alb.tf | 11 +++++------ examples/deploy_group_clb.tf | 4 ++-- examples/multiple_deployment_groups.tf | 4 ++-- tests/test1/main.tf | 11 +++++------ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/examples/deploy_group_alb.tf b/examples/deploy_group_alb.tf index 90adc04..e8fdd9d 100644 --- a/examples/deploy_group_alb.tf +++ b/examples/deploy_group_alb.tf @@ -32,9 +32,9 @@ module "vpc" { module "security_groups" { source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=v0.0.6" + environment = "Production" resource_name = "Test-SG" vpc_id = "${module.vpc.vpc_id}" - environment = "Production" } module "alb" { @@ -49,15 +49,14 @@ module "alb" { vpc_id = "${module.vpc.vpc_id}" http_listeners = [{ - port = 80 - + port = 80 protocol = "HTTP" }] target_groups = [{ - "name" = "CodeDeployExample-TargetGroup" - "backend_protocol" = "HTTP" "backend_port" = 80 + "backend_protocol" = "HTTP" + "name" = "CodeDeployExample-TargetGroup" }] } @@ -69,9 +68,9 @@ module "asg" { install_codedeploy_agent = "True" instance_type = "t2.micro" resource_name = "CodeDeployExample" - security_group_list = ["${module.security_groups.private_web_security_group_id}"] scaling_max = "2" scaling_min = "1" + security_group_list = ["${module.security_groups.private_web_security_group_id}"] subnets = ["${element(module.vpc.public_subnets, 0)}", "${element(module.vpc.public_subnets, 1)}"] target_group_arns = "${module.alb.target_group_arns}" } diff --git a/examples/deploy_group_clb.tf b/examples/deploy_group_clb.tf index 81fce3b..11e54b9 100644 --- a/examples/deploy_group_clb.tf +++ b/examples/deploy_group_clb.tf @@ -32,19 +32,19 @@ module "vpc" { module "security_groups" { source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=v0.0.6" + environment = "Production" resource_name = "Test-SG" vpc_id = "${module.vpc.vpc_id}" - environment = "Production" } module "clb" { source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-clb//?ref=v0.0.8" + connection_draining_timeout = 300 clb_name = "CodeDeployExample-CLB" instances = [] security_groups = ["${module.security_groups.public_web_security_group_id}"] subnets = "${module.vpc.public_subnets}" - connection_draining_timeout = 300 listeners = [ { diff --git a/examples/multiple_deployment_groups.tf b/examples/multiple_deployment_groups.tf index 7ae650f..b547cb9 100644 --- a/examples/multiple_deployment_groups.tf +++ b/examples/multiple_deployment_groups.tf @@ -32,9 +32,9 @@ module "vpc" { module "security_groups" { source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=v0.0.6" + environment = "Production" resource_name = "Test-SG" vpc_id = "${module.vpc.vpc_id}" - environment = "Production" } module "asg_prod" { @@ -77,8 +77,8 @@ module "codedeploy_test" { source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-codedeploy//?ref=v0.0.3" application_name = "${module.codedeploy_prod.application_name}" - create_application = false autoscaling_groups = ["${module.asg_test.asg_name_list}"] + create_application = false deployment_config_name = "CodeDeployDefault.AllAtOnce" environment = "Test" } diff --git a/tests/test1/main.tf b/tests/test1/main.tf index 58a0fd3..8f0511f 100644 --- a/tests/test1/main.tf +++ b/tests/test1/main.tf @@ -44,9 +44,9 @@ module "vpc" { module "security_groups" { source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-security_group//?ref=v0.0.6" + environment = "Production" resource_name = "${random_string.rstring.result}-SG" vpc_id = "${module.vpc.vpc_id}" - environment = "Production" } module "alb" { @@ -61,15 +61,14 @@ module "alb" { vpc_id = "${module.vpc.vpc_id}" http_listeners = [{ - port = 80 - + port = 80 protocol = "HTTP" }] target_groups = [{ - "name" = "${random_string.rstring.result}-TargetGroup" - "backend_protocol" = "HTTP" "backend_port" = 80 + "backend_protocol" = "HTTP" + "name" = "${random_string.rstring.result}-TargetGroup" }] } @@ -77,10 +76,10 @@ module "clb" { source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-clb//?ref=v0.0.8" clb_name = "${random_string.rstring.result}-CLB" + connection_draining_timeout = 300 instances = [] security_groups = ["${module.security_groups.public_web_security_group_id}"] subnets = "${module.vpc.public_subnets}" - connection_draining_timeout = 300 listeners = [ {