From 607212b61fb926c095596c8ddd9cc0ed9e7afee6 Mon Sep 17 00:00:00 2001 From: nitrocode Date: Tue, 3 Aug 2021 10:57:17 -0400 Subject: [PATCH] Tag codedeploy group and app (#4) * Tag codedeploy group and app * Auto Format * Corrected readme module source * Auto Format Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com> --- README.md | 119 +++++++++++++++++++++++----------------------- README.yaml | 9 ++-- docs/terraform.md | 100 +++++++++++++++++++------------------- main.tf | 26 ++++++---- 4 files changed, 132 insertions(+), 122 deletions(-) diff --git a/README.md b/README.md index 3709b68..9da43bf 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # terraform-aws-code-deploy [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-code-deploy.svg)](https://github.com/cloudposse/terraform-aws-code-deploy/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) [![Discourse Forum](https://img.shields.io/discourse/https/ask.sweetops.com/posts.svg)](https://ask.sweetops.com/) @@ -29,7 +30,6 @@ Terraform module to provision AWS Code Deploy app and group. - --- This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps. @@ -60,7 +60,6 @@ We literally have [*hundreds of terraform modules*][terraform_modules] that are - ## Security & Compliance [](https://bridgecrew.io/) Security scanning is graciously provided by Bridgecrew. Bridgecrew is the leading fully hosted, cloud-native solution providing continuous Terraform security and compliance. @@ -100,9 +99,10 @@ For automated tests of the complete example using [bats](https://github.com/bats (which tests and deploys the example on AWS), see [test](test). ```hcl -module "example" { - source = "https://github.com/cloudposse/terraform-aws-code-deploy.git?ref=master" - example = "Hello world!" +module "example" { + source = "cloudposse/code-deploy/aws" + # Cloud Posse recommends pinning every module to a specific version + # version = "x.x.x" } ``` @@ -133,79 +133,79 @@ Available targets: | Name | Version | |------|---------| -| terraform | >= 0.13 | -| aws | >= 2.0 | -| local | >= 1.2 | +| [terraform](#requirement\_terraform) | >= 0.13 | +| [aws](#requirement\_aws) | >= 2.0 | +| [local](#requirement\_local) | >= 1.2 | ## Providers | Name | Version | |------|---------| -| aws | >= 2.0 | +| [aws](#provider\_aws) | >= 2.0 | ## Modules | Name | Source | Version | |------|--------|---------| -| sns_topic | cloudposse/sns-topic/aws | 0.16.0 | -| this | cloudposse/label/null | 0.24.1 | +| [sns\_topic](#module\_sns\_topic) | cloudposse/sns-topic/aws | 0.16.0 | +| [this](#module\_this) | cloudposse/label/null | 0.24.1 | ## Resources -| Name | -|------| -| [aws_codedeploy_app](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_app) | -| [aws_codedeploy_deployment_config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_config) | -| [aws_codedeploy_deployment_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group) | -| [aws_iam_policy_document](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | -| [aws_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | -| [aws_iam_role_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | +| Name | Type | +|------|------| +| [aws_codedeploy_app.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_app) | resource | +| [aws_codedeploy_deployment_config.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_config) | resource | +| [aws_codedeploy_deployment_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group) | resource | +| [aws_iam_role.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | +| [aws_iam_role_policy_attachment.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | +| [aws_iam_policy_document.assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no | -| alarm\_configuration | Configuration of deployment to stop when a CloudWatch alarm detects that a metric has fallen below or exceeded a defined threshold.
alarms:
A list of alarms configured for the deployment group.
ignore\_poll\_alarm\_failure:
Indicates whether a deployment should continue if information about the current state of alarms cannot be retrieved from CloudWatch. |
object({
alarms = list(string)
ignore_poll_alarm_failure = bool
})
| `null` | no | -| attributes | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no | -| auto\_rollback\_configuration\_events | The event type or types that trigger a rollback. Supported types are `DEPLOYMENT_FAILURE` and `DEPLOYMENT_STOP_ON_ALARM`. | `string` | `"DEPLOYMENT_FAILURE"` | no | -| autoscaling\_groups | A list of Autoscaling Groups associated with the deployment group. | `list(string)` | `[]` | no | -| blue\_green\_deployment\_config | Configuration block of the blue/green deployment options for a deployment group,
see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group#blue_green_deployment_config | `any` | `null` | no | -| compute\_platform | The compute platform can either be `ECS`, `Lambda`, or `Server` | `string` | `"ECS"` | no | -| context | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` |
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
}
| no | -| create\_default\_service\_role | Whether to create default IAM role ARN that allows deployments. | `bool` | `true` | no | -| create\_default\_sns\_topic | Whether to create default SNS topic through which notifications are sent. | `bool` | `true` | no | -| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | -| deployment\_style | Configuration of the type of deployment, either in-place or blue/green,
you want to run and whether to route deployment traffic behind a load balancer.

deployment\_option:
Indicates whether to route deployment traffic behind a load balancer.
Possible values: `WITH_TRAFFIC_CONTROL`, `WITHOUT_TRAFFIC_CONTROL`.
deployment\_type:
Indicates whether to run an in-place deployment or a blue/green deployment.
Possible values: `IN_PLACE`, `BLUE_GREEN`. |
object({
deployment_option = string
deployment_type = string
})
| `null` | no | -| ec2\_tag\_filter | A list of sets of tag filters. If multiple tag groups are specified,
any instance that matches to at least one tag filter of every tag group is selected.

key:
The key of the tag filter.
type:
The type of the tag filter, either `KEY_ONLY`, `VALUE_ONLY`, or `KEY_AND_VALUE`.
value:
The value of the tag filter. |
list(object({
key = string
type = string
value = string
}))
| `null` | no | -| ecs\_service | Configuration block(s) of the ECS services for a deployment group.

cluster\_name:
The name of the ECS cluster.
service\_name:
The name of the ECS service. |
list(object({
cluster_name = string
service_name = string
}))
| `null` | no | -| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no | -| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | -| id\_length\_limit | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for default, which is `0`.
Does not affect `id_full`. | `number` | `null` | no | -| label\_key\_case | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no | -| label\_order | The naming order of the id output and Name tag.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no | -| label\_value\_case | The letter case of output label values (also used in `tags` and `id`).
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Default value: `lower`. | `string` | `null` | no | -| load\_balancer\_info | Single configuration block of the load balancer to use in a blue/green deployment,
see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group#load_balancer_info | `map(any)` | `null` | no | -| minimum\_healthy\_hosts | type:
The type can either be `FLEET_PERCENT` or `HOST_COUNT`.
value:
The value when the type is `FLEET_PERCENT` represents the minimum number of healthy instances
as a percentage of the total number of instances in the deployment.
When the type is `HOST_COUNT`, the value represents the minimum number of healthy instances as an absolute value. |
object({
type = string
value = number
})
| `null` | no | -| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no | -| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no | -| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | -| service\_role\_arn | The service IAM role ARN that allows deployments. | `string` | `null` | no | -| sns\_topic\_arn | The ARN of the SNS topic through which notifications are sent. | `string` | `null` | no | -| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | -| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no | -| traffic\_routing\_config | type:
Type of traffic routing config. One of `TimeBasedCanary`, `TimeBasedLinear`, `AllAtOnce`.
interval:
The number of minutes between the first and second traffic shifts of a deployment.
percentage:
The percentage of traffic to shift in the first increment of a deployment. |
object({
type = string
interval = number
percentage = number
})
| `null` | no | -| trigger\_events | The event type or types for which notifications are triggered.
Some values that are supported:
`DeploymentStart`, `DeploymentSuccess`, `DeploymentFailure`, `DeploymentStop`,
`DeploymentRollback`, `InstanceStart`, `InstanceSuccess`, `InstanceFailure`.
See the CodeDeploy documentation for all possible values.
http://docs.aws.amazon.com/codedeploy/latest/userguide/monitoring-sns-event-notifications-create-trigger.html | `list(string)` |
[
"DeploymentFailure"
]
| no | +| [additional\_tag\_map](#input\_additional\_tag\_map) | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no | +| [alarm\_configuration](#input\_alarm\_configuration) | Configuration of deployment to stop when a CloudWatch alarm detects that a metric has fallen below or exceeded a defined threshold.
alarms:
A list of alarms configured for the deployment group.
ignore\_poll\_alarm\_failure:
Indicates whether a deployment should continue if information about the current state of alarms cannot be retrieved from CloudWatch. |
object({
alarms = list(string)
ignore_poll_alarm_failure = bool
})
| `null` | no | +| [attributes](#input\_attributes) | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no | +| [auto\_rollback\_configuration\_events](#input\_auto\_rollback\_configuration\_events) | The event type or types that trigger a rollback. Supported types are `DEPLOYMENT_FAILURE` and `DEPLOYMENT_STOP_ON_ALARM`. | `string` | `"DEPLOYMENT_FAILURE"` | no | +| [autoscaling\_groups](#input\_autoscaling\_groups) | A list of Autoscaling Groups associated with the deployment group. | `list(string)` | `[]` | no | +| [blue\_green\_deployment\_config](#input\_blue\_green\_deployment\_config) | Configuration block of the blue/green deployment options for a deployment group,
see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group#blue_green_deployment_config | `any` | `null` | no | +| [compute\_platform](#input\_compute\_platform) | The compute platform can either be `ECS`, `Lambda`, or `Server` | `string` | `"ECS"` | no | +| [context](#input\_context) | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` |
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
}
| no | +| [create\_default\_service\_role](#input\_create\_default\_service\_role) | Whether to create default IAM role ARN that allows deployments. | `bool` | `true` | no | +| [create\_default\_sns\_topic](#input\_create\_default\_sns\_topic) | Whether to create default SNS topic through which notifications are sent. | `bool` | `true` | no | +| [delimiter](#input\_delimiter) | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | +| [deployment\_style](#input\_deployment\_style) | Configuration of the type of deployment, either in-place or blue/green,
you want to run and whether to route deployment traffic behind a load balancer.

deployment\_option:
Indicates whether to route deployment traffic behind a load balancer.
Possible values: `WITH_TRAFFIC_CONTROL`, `WITHOUT_TRAFFIC_CONTROL`.
deployment\_type:
Indicates whether to run an in-place deployment or a blue/green deployment.
Possible values: `IN_PLACE`, `BLUE_GREEN`. |
object({
deployment_option = string
deployment_type = string
})
| `null` | no | +| [ec2\_tag\_filter](#input\_ec2\_tag\_filter) | A list of sets of tag filters. If multiple tag groups are specified,
any instance that matches to at least one tag filter of every tag group is selected.

key:
The key of the tag filter.
type:
The type of the tag filter, either `KEY_ONLY`, `VALUE_ONLY`, or `KEY_AND_VALUE`.
value:
The value of the tag filter. |
list(object({
key = string
type = string
value = string
}))
| `null` | no | +| [ecs\_service](#input\_ecs\_service) | Configuration block(s) of the ECS services for a deployment group.

cluster\_name:
The name of the ECS cluster.
service\_name:
The name of the ECS service. |
list(object({
cluster_name = string
service_name = string
}))
| `null` | no | +| [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | +| [environment](#input\_environment) | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | +| [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for default, which is `0`.
Does not affect `id_full`. | `number` | `null` | no | +| [label\_key\_case](#input\_label\_key\_case) | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no | +| [label\_order](#input\_label\_order) | The naming order of the id output and Name tag.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no | +| [label\_value\_case](#input\_label\_value\_case) | The letter case of output label values (also used in `tags` and `id`).
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Default value: `lower`. | `string` | `null` | no | +| [load\_balancer\_info](#input\_load\_balancer\_info) | Single configuration block of the load balancer to use in a blue/green deployment,
see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group#load_balancer_info | `map(any)` | `null` | no | +| [minimum\_healthy\_hosts](#input\_minimum\_healthy\_hosts) | type:
The type can either be `FLEET_PERCENT` or `HOST_COUNT`.
value:
The value when the type is `FLEET_PERCENT` represents the minimum number of healthy instances
as a percentage of the total number of instances in the deployment.
When the type is `HOST_COUNT`, the value represents the minimum number of healthy instances as an absolute value. |
object({
type = string
value = number
})
| `null` | no | +| [name](#input\_name) | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no | +| [namespace](#input\_namespace) | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no | +| [regex\_replace\_chars](#input\_regex\_replace\_chars) | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | +| [service\_role\_arn](#input\_service\_role\_arn) | The service IAM role ARN that allows deployments. | `string` | `null` | no | +| [sns\_topic\_arn](#input\_sns\_topic\_arn) | The ARN of the SNS topic through which notifications are sent. | `string` | `null` | no | +| [stage](#input\_stage) | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | +| [tags](#input\_tags) | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no | +| [traffic\_routing\_config](#input\_traffic\_routing\_config) | type:
Type of traffic routing config. One of `TimeBasedCanary`, `TimeBasedLinear`, `AllAtOnce`.
interval:
The number of minutes between the first and second traffic shifts of a deployment.
percentage:
The percentage of traffic to shift in the first increment of a deployment. |
object({
type = string
interval = number
percentage = number
})
| `null` | no | +| [trigger\_events](#input\_trigger\_events) | The event type or types for which notifications are triggered.
Some values that are supported:
`DeploymentStart`, `DeploymentSuccess`, `DeploymentFailure`, `DeploymentStop`,
`DeploymentRollback`, `InstanceStart`, `InstanceSuccess`, `InstanceFailure`.
See the CodeDeploy documentation for all possible values.
http://docs.aws.amazon.com/codedeploy/latest/userguide/monitoring-sns-event-notifications-create-trigger.html | `list(string)` |
[
"DeploymentFailure"
]
| no | ## Outputs | Name | Description | |------|-------------| -| deployment\_config\_id | The deployment config ID. | -| deployment\_config\_name | The deployment group's config name. | -| group\_id | The application group ID. | -| id | The application ID. | -| name | The application's name. | +| [deployment\_config\_id](#output\_deployment\_config\_id) | The deployment config ID. | +| [deployment\_config\_name](#output\_deployment\_config\_name) | The deployment group's config name. | +| [group\_id](#output\_group\_id) | The application group ID. | +| [id](#output\_id) | The application ID. | +| [name](#output\_name) | The application's name. | @@ -217,6 +217,7 @@ Like this project? Please give it a ★ on [our GitHub](https://github.com/cloud Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =) + ## Related Projects Check out these related projects. @@ -229,8 +230,6 @@ Check out these related projects. - [terraform-aws-code-deploy](https://github.com/cloudposse/terraform-aws-code-deploy) - %!s() - - ## References For additional context, refer to some of these links. @@ -371,12 +370,14 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply ### Contributors -| [![Vladimir Syromyatnikov][SweetOps_avatar]][SweetOps_homepage]
[Vladimir Syromyatnikov][SweetOps_homepage] | -|---| +| [![Vladimir Syromyatnikov][SweetOps_avatar]][SweetOps_homepage]
[Vladimir Syromyatnikov][SweetOps_homepage] | [![RB][nitrocode_avatar]][nitrocode_homepage]
[RB][nitrocode_homepage] | +|---|---| [SweetOps_homepage]: https://github.com/SweetOps [SweetOps_avatar]: https://img.cloudposse.com/150x150/https://github.com/SweetOps.png + [nitrocode_homepage]: https://github.com/nitrocode + [nitrocode_avatar]: https://img.cloudposse.com/150x150/https://github.com/nitrocode.png [![README Footer][readme_footer_img]][readme_footer_link] [![Beacon][beacon]][website] diff --git a/README.yaml b/README.yaml index 829bb55..7c2880d 100644 --- a/README.yaml +++ b/README.yaml @@ -79,9 +79,10 @@ usage: |- (which tests and deploys the example on AWS), see [test](test). ```hcl - module "example" { - source = "https://github.com/cloudposse/terraform-aws-code-deploy.git?ref=master" - example = "Hello world!" + module "example" { + source = "cloudposse/code-deploy/aws" + # Cloud Posse recommends pinning every module to a specific version + # version = "x.x.x" } ``` @@ -103,3 +104,5 @@ include: contributors: - name: Vladimir Syromyatnikov github: SweetOps +- name: RB + github: nitrocode diff --git a/docs/terraform.md b/docs/terraform.md index 08e6d92..b24b365 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -3,77 +3,77 @@ | Name | Version | |------|---------| -| terraform | >= 0.13 | -| aws | >= 2.0 | -| local | >= 1.2 | +| [terraform](#requirement\_terraform) | >= 0.13 | +| [aws](#requirement\_aws) | >= 2.0 | +| [local](#requirement\_local) | >= 1.2 | ## Providers | Name | Version | |------|---------| -| aws | >= 2.0 | +| [aws](#provider\_aws) | >= 2.0 | ## Modules | Name | Source | Version | |------|--------|---------| -| sns_topic | cloudposse/sns-topic/aws | 0.16.0 | -| this | cloudposse/label/null | 0.24.1 | +| [sns\_topic](#module\_sns\_topic) | cloudposse/sns-topic/aws | 0.16.0 | +| [this](#module\_this) | cloudposse/label/null | 0.24.1 | ## Resources -| Name | -|------| -| [aws_codedeploy_app](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_app) | -| [aws_codedeploy_deployment_config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_config) | -| [aws_codedeploy_deployment_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group) | -| [aws_iam_policy_document](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | -| [aws_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | -| [aws_iam_role_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | +| Name | Type | +|------|------| +| [aws_codedeploy_app.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_app) | resource | +| [aws_codedeploy_deployment_config.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_config) | resource | +| [aws_codedeploy_deployment_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group) | resource | +| [aws_iam_role.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | +| [aws_iam_role_policy_attachment.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | +| [aws_iam_policy_document.assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no | -| alarm\_configuration | Configuration of deployment to stop when a CloudWatch alarm detects that a metric has fallen below or exceeded a defined threshold.
alarms:
A list of alarms configured for the deployment group.
ignore\_poll\_alarm\_failure:
Indicates whether a deployment should continue if information about the current state of alarms cannot be retrieved from CloudWatch. |
object({
alarms = list(string)
ignore_poll_alarm_failure = bool
})
| `null` | no | -| attributes | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no | -| auto\_rollback\_configuration\_events | The event type or types that trigger a rollback. Supported types are `DEPLOYMENT_FAILURE` and `DEPLOYMENT_STOP_ON_ALARM`. | `string` | `"DEPLOYMENT_FAILURE"` | no | -| autoscaling\_groups | A list of Autoscaling Groups associated with the deployment group. | `list(string)` | `[]` | no | -| blue\_green\_deployment\_config | Configuration block of the blue/green deployment options for a deployment group,
see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group#blue_green_deployment_config | `any` | `null` | no | -| compute\_platform | The compute platform can either be `ECS`, `Lambda`, or `Server` | `string` | `"ECS"` | no | -| context | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` |
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
}
| no | -| create\_default\_service\_role | Whether to create default IAM role ARN that allows deployments. | `bool` | `true` | no | -| create\_default\_sns\_topic | Whether to create default SNS topic through which notifications are sent. | `bool` | `true` | no | -| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | -| deployment\_style | Configuration of the type of deployment, either in-place or blue/green,
you want to run and whether to route deployment traffic behind a load balancer.

deployment\_option:
Indicates whether to route deployment traffic behind a load balancer.
Possible values: `WITH_TRAFFIC_CONTROL`, `WITHOUT_TRAFFIC_CONTROL`.
deployment\_type:
Indicates whether to run an in-place deployment or a blue/green deployment.
Possible values: `IN_PLACE`, `BLUE_GREEN`. |
object({
deployment_option = string
deployment_type = string
})
| `null` | no | -| ec2\_tag\_filter | A list of sets of tag filters. If multiple tag groups are specified,
any instance that matches to at least one tag filter of every tag group is selected.

key:
The key of the tag filter.
type:
The type of the tag filter, either `KEY_ONLY`, `VALUE_ONLY`, or `KEY_AND_VALUE`.
value:
The value of the tag filter. |
list(object({
key = string
type = string
value = string
}))
| `null` | no | -| ecs\_service | Configuration block(s) of the ECS services for a deployment group.

cluster\_name:
The name of the ECS cluster.
service\_name:
The name of the ECS service. |
list(object({
cluster_name = string
service_name = string
}))
| `null` | no | -| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no | -| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | -| id\_length\_limit | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for default, which is `0`.
Does not affect `id_full`. | `number` | `null` | no | -| label\_key\_case | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no | -| label\_order | The naming order of the id output and Name tag.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no | -| label\_value\_case | The letter case of output label values (also used in `tags` and `id`).
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Default value: `lower`. | `string` | `null` | no | -| load\_balancer\_info | Single configuration block of the load balancer to use in a blue/green deployment,
see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group#load_balancer_info | `map(any)` | `null` | no | -| minimum\_healthy\_hosts | type:
The type can either be `FLEET_PERCENT` or `HOST_COUNT`.
value:
The value when the type is `FLEET_PERCENT` represents the minimum number of healthy instances
as a percentage of the total number of instances in the deployment.
When the type is `HOST_COUNT`, the value represents the minimum number of healthy instances as an absolute value. |
object({
type = string
value = number
})
| `null` | no | -| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no | -| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no | -| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | -| service\_role\_arn | The service IAM role ARN that allows deployments. | `string` | `null` | no | -| sns\_topic\_arn | The ARN of the SNS topic through which notifications are sent. | `string` | `null` | no | -| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | -| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no | -| traffic\_routing\_config | type:
Type of traffic routing config. One of `TimeBasedCanary`, `TimeBasedLinear`, `AllAtOnce`.
interval:
The number of minutes between the first and second traffic shifts of a deployment.
percentage:
The percentage of traffic to shift in the first increment of a deployment. |
object({
type = string
interval = number
percentage = number
})
| `null` | no | -| trigger\_events | The event type or types for which notifications are triggered.
Some values that are supported:
`DeploymentStart`, `DeploymentSuccess`, `DeploymentFailure`, `DeploymentStop`,
`DeploymentRollback`, `InstanceStart`, `InstanceSuccess`, `InstanceFailure`.
See the CodeDeploy documentation for all possible values.
http://docs.aws.amazon.com/codedeploy/latest/userguide/monitoring-sns-event-notifications-create-trigger.html | `list(string)` |
[
"DeploymentFailure"
]
| no | +| [additional\_tag\_map](#input\_additional\_tag\_map) | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no | +| [alarm\_configuration](#input\_alarm\_configuration) | Configuration of deployment to stop when a CloudWatch alarm detects that a metric has fallen below or exceeded a defined threshold.
alarms:
A list of alarms configured for the deployment group.
ignore\_poll\_alarm\_failure:
Indicates whether a deployment should continue if information about the current state of alarms cannot be retrieved from CloudWatch. |
object({
alarms = list(string)
ignore_poll_alarm_failure = bool
})
| `null` | no | +| [attributes](#input\_attributes) | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no | +| [auto\_rollback\_configuration\_events](#input\_auto\_rollback\_configuration\_events) | The event type or types that trigger a rollback. Supported types are `DEPLOYMENT_FAILURE` and `DEPLOYMENT_STOP_ON_ALARM`. | `string` | `"DEPLOYMENT_FAILURE"` | no | +| [autoscaling\_groups](#input\_autoscaling\_groups) | A list of Autoscaling Groups associated with the deployment group. | `list(string)` | `[]` | no | +| [blue\_green\_deployment\_config](#input\_blue\_green\_deployment\_config) | Configuration block of the blue/green deployment options for a deployment group,
see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group#blue_green_deployment_config | `any` | `null` | no | +| [compute\_platform](#input\_compute\_platform) | The compute platform can either be `ECS`, `Lambda`, or `Server` | `string` | `"ECS"` | no | +| [context](#input\_context) | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` |
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
}
| no | +| [create\_default\_service\_role](#input\_create\_default\_service\_role) | Whether to create default IAM role ARN that allows deployments. | `bool` | `true` | no | +| [create\_default\_sns\_topic](#input\_create\_default\_sns\_topic) | Whether to create default SNS topic through which notifications are sent. | `bool` | `true` | no | +| [delimiter](#input\_delimiter) | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | +| [deployment\_style](#input\_deployment\_style) | Configuration of the type of deployment, either in-place or blue/green,
you want to run and whether to route deployment traffic behind a load balancer.

deployment\_option:
Indicates whether to route deployment traffic behind a load balancer.
Possible values: `WITH_TRAFFIC_CONTROL`, `WITHOUT_TRAFFIC_CONTROL`.
deployment\_type:
Indicates whether to run an in-place deployment or a blue/green deployment.
Possible values: `IN_PLACE`, `BLUE_GREEN`. |
object({
deployment_option = string
deployment_type = string
})
| `null` | no | +| [ec2\_tag\_filter](#input\_ec2\_tag\_filter) | A list of sets of tag filters. If multiple tag groups are specified,
any instance that matches to at least one tag filter of every tag group is selected.

key:
The key of the tag filter.
type:
The type of the tag filter, either `KEY_ONLY`, `VALUE_ONLY`, or `KEY_AND_VALUE`.
value:
The value of the tag filter. |
list(object({
key = string
type = string
value = string
}))
| `null` | no | +| [ecs\_service](#input\_ecs\_service) | Configuration block(s) of the ECS services for a deployment group.

cluster\_name:
The name of the ECS cluster.
service\_name:
The name of the ECS service. |
list(object({
cluster_name = string
service_name = string
}))
| `null` | no | +| [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | +| [environment](#input\_environment) | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | +| [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for default, which is `0`.
Does not affect `id_full`. | `number` | `null` | no | +| [label\_key\_case](#input\_label\_key\_case) | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no | +| [label\_order](#input\_label\_order) | The naming order of the id output and Name tag.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no | +| [label\_value\_case](#input\_label\_value\_case) | The letter case of output label values (also used in `tags` and `id`).
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Default value: `lower`. | `string` | `null` | no | +| [load\_balancer\_info](#input\_load\_balancer\_info) | Single configuration block of the load balancer to use in a blue/green deployment,
see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group#load_balancer_info | `map(any)` | `null` | no | +| [minimum\_healthy\_hosts](#input\_minimum\_healthy\_hosts) | type:
The type can either be `FLEET_PERCENT` or `HOST_COUNT`.
value:
The value when the type is `FLEET_PERCENT` represents the minimum number of healthy instances
as a percentage of the total number of instances in the deployment.
When the type is `HOST_COUNT`, the value represents the minimum number of healthy instances as an absolute value. |
object({
type = string
value = number
})
| `null` | no | +| [name](#input\_name) | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no | +| [namespace](#input\_namespace) | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no | +| [regex\_replace\_chars](#input\_regex\_replace\_chars) | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | +| [service\_role\_arn](#input\_service\_role\_arn) | The service IAM role ARN that allows deployments. | `string` | `null` | no | +| [sns\_topic\_arn](#input\_sns\_topic\_arn) | The ARN of the SNS topic through which notifications are sent. | `string` | `null` | no | +| [stage](#input\_stage) | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | +| [tags](#input\_tags) | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no | +| [traffic\_routing\_config](#input\_traffic\_routing\_config) | type:
Type of traffic routing config. One of `TimeBasedCanary`, `TimeBasedLinear`, `AllAtOnce`.
interval:
The number of minutes between the first and second traffic shifts of a deployment.
percentage:
The percentage of traffic to shift in the first increment of a deployment. |
object({
type = string
interval = number
percentage = number
})
| `null` | no | +| [trigger\_events](#input\_trigger\_events) | The event type or types for which notifications are triggered.
Some values that are supported:
`DeploymentStart`, `DeploymentSuccess`, `DeploymentFailure`, `DeploymentStop`,
`DeploymentRollback`, `InstanceStart`, `InstanceSuccess`, `InstanceFailure`.
See the CodeDeploy documentation for all possible values.
http://docs.aws.amazon.com/codedeploy/latest/userguide/monitoring-sns-event-notifications-create-trigger.html | `list(string)` |
[
"DeploymentFailure"
]
| no | ## Outputs | Name | Description | |------|-------------| -| deployment\_config\_id | The deployment config ID. | -| deployment\_config\_name | The deployment group's config name. | -| group\_id | The application group ID. | -| id | The application ID. | -| name | The application's name. | +| [deployment\_config\_id](#output\_deployment\_config\_id) | The deployment config ID. | +| [deployment\_config\_name](#output\_deployment\_config\_name) | The deployment group's config name. | +| [group\_id](#output\_group\_id) | The application group ID. | +| [id](#output\_id) | The application ID. | +| [name](#output\_name) | The application's name. | diff --git a/main.tf b/main.tf index 3a435a7..7a6e0b7 100644 --- a/main.tf +++ b/main.tf @@ -1,15 +1,17 @@ locals { - count = module.this.enabled ? 1 : 0 - id = module.this.enabled ? join("", aws_codedeploy_app.default.*.id) : null - name = module.this.enabled ? join("", aws_codedeploy_app.default.*.name) : null - group_id = module.this.enabled ? join("", aws_codedeploy_deployment_group.default.*.id) : null - deployment_config_name = module.this.enabled ? join("", aws_codedeploy_deployment_config.default.*.id) : null - deployment_config_id = module.this.enabled ? join("", aws_codedeploy_deployment_config.default.*.deployment_config_id) : null - auto_rollback_configuration_enabled = module.this.enabled && var.auto_rollback_configuration_events != null && length(var.auto_rollback_configuration_events) > 0 - alarm_configuration_enabled = module.this.enabled && var.alarm_configuration != null - default_sns_topic_enabled = module.this.enabled && var.create_default_sns_topic ? true : false + enabled = module.this.enabled + + count = local.enabled ? 1 : 0 + id = local.enabled ? join("", aws_codedeploy_app.default.*.id) : null + name = local.enabled ? join("", aws_codedeploy_app.default.*.name) : null + group_id = local.enabled ? join("", aws_codedeploy_deployment_group.default.*.id) : null + deployment_config_name = local.enabled ? join("", aws_codedeploy_deployment_config.default.*.id) : null + deployment_config_id = local.enabled ? join("", aws_codedeploy_deployment_config.default.*.deployment_config_id) : null + auto_rollback_configuration_enabled = local.enabled && var.auto_rollback_configuration_events != null && length(var.auto_rollback_configuration_events) > 0 + alarm_configuration_enabled = local.enabled && var.alarm_configuration != null + default_sns_topic_enabled = local.enabled && var.create_default_sns_topic sns_topic_arn = local.default_sns_topic_enabled ? module.sns_topic.sns_topic.arn : var.sns_topic_arn - default_service_role_enabled = module.this.enabled && var.create_default_service_role ? true : false + default_service_role_enabled = local.enabled && var.create_default_service_role default_service_role_count = local.default_service_role_enabled ? 1 : 0 service_role_arn = local.default_service_role_enabled ? join("", aws_iam_role.default.*.arn) : var.service_role_arn default_policy_name = { @@ -58,6 +60,8 @@ resource "aws_codedeploy_app" "default" { count = local.count name = module.this.id compute_platform = var.compute_platform + + tags = module.this.tags } resource "aws_codedeploy_deployment_config" "default" { @@ -266,4 +270,6 @@ resource "aws_codedeploy_deployment_group" "default" { trigger_target_arn = local.sns_topic_arn } } + + tags = module.this.tags }