Skip to content

Commit

Permalink
Merge pull request #6 from rackspace-infrastructure-automation/0.12_c…
Browse files Browse the repository at this point in the history
…onversion_prework

Prework for terraform 0.12 Upgrade
  • Loading branch information
gdelvalle authored Mar 5, 2020
2 parents cd78889 + d634c07 commit b542c45
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 77 deletions.
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | `<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

Expand Down
21 changes: 10 additions & 11 deletions examples/deploy_group_alb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ 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"

environment = "Production"
resource_name = "Test-SG"
vpc_id = "${module.vpc.vpc_id}"
environment = "Production"
}

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
Expand All @@ -49,35 +49,34 @@ 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"
}]
}

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}"
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}"
}

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}"]
Expand Down
14 changes: 7 additions & 7 deletions examples/deploy_group_clb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ 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"

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.2"
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 = [
{
Expand All @@ -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}"
Expand All @@ -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}"]
Expand Down
16 changes: 8 additions & 8 deletions examples/multiple_deployment_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ 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"

environment = "Production"
resource_name = "Test-SG"
vpc_id = "${module.vpc.vpc_id}"
environment = "Production"
}

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}"
Expand All @@ -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}"
Expand All @@ -66,19 +66,19 @@ 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}"]
environment = "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
autoscaling_groups = ["${module.asg_test.asg_name_list}"]
create_application = false
deployment_config_name = "CodeDeployDefault.AllAtOnce"
environment = "Test"
}
24 changes: 12 additions & 12 deletions main.tf
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
19 changes: 9 additions & 10 deletions tests/test1/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ 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"

environment = "Production"
resource_name = "${random_string.rstring.result}-SG"
vpc_id = "${module.vpc.vpc_id}"
environment = "Production"
}

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
Expand All @@ -61,26 +61,25 @@ 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"
}]
}

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"
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 = [
{
Expand Down
26 changes: 13 additions & 13 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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"
}

0 comments on commit b542c45

Please sign in to comment.