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..e8fdd9d 100644 --- a/examples/deploy_group_alb.tf +++ b/examples/deploy_group_alb.tf @@ -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 @@ -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}"] diff --git a/examples/deploy_group_clb.tf b/examples/deploy_group_clb.tf index 7a41d7d..11e54b9 100644 --- a/examples/deploy_group_clb.tf +++ b/examples/deploy_group_clb.tf @@ -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 = [ { @@ -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..b547cb9 100644 --- a/examples/multiple_deployment_groups.tf +++ b/examples/multiple_deployment_groups.tf @@ -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}" @@ -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,11 +74,11 @@ 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 autoscaling_groups = ["${module.asg_test.asg_name_list}"] + create_application = false deployment_config_name = "CodeDeployDefault.AllAtOnce" environment = "Test" } 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..8f0511f 100644 --- a/tests/test1/main.tf +++ b/tests/test1/main.tf @@ -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 @@ -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 = [ { 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" }