diff --git a/README.md b/README.md index 5ebcf3a..cc9ddf7 100644 --- a/README.md +++ b/README.md @@ -281,8 +281,9 @@ Available targets: | [codestar\_output\_artifact\_format](#input\_codestar\_output\_artifact\_format) | Output artifact type for Source stage in pipeline. Valid values are "CODE\_ZIP" (default) and "CODEBUILD\_CLONE\_REF". See https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CodestarConnectionSource.html | `string` | `"CODE_ZIP"` | 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,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
| no | | [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | +| [deploy\_stage\_enabled](#input\_deploy\_stage\_enabled) | Set to false to disable the deploy stage | `bool` | `true` | no | | [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
`labels` is a list of labels, in order, to pass to `format()` function.
Label values will be normalized before being passed to `format()` so they will be
identical to how they appear in `id`.
Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no | -| [ecs\_cluster\_name](#input\_ecs\_cluster\_name) | ECS Cluster Name | `string` | n/a | yes | +| [ecs\_cluster\_name](#input\_ecs\_cluster\_name) | ECS Cluster Name, not required if you have deploy stage disabled | `string` | `""` | no | | [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | | [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | | [environment\_variables](#input\_environment\_variables) | A list of maps, that contain the keys 'name', 'value', and 'type' to be used as additional environment variables for the build. Valid types are 'PLAINTEXT', 'PARAMETER\_STORE', or 'SECRETS\_MANAGER' |
list(object(
{
name = string
value = string
type = string
}))
| `[]` | no | @@ -308,7 +309,7 @@ Available targets: | [secondary\_artifact\_bucket\_id](#input\_secondary\_artifact\_bucket\_id) | Optional bucket for secondary artifact deployment. If specified, the buildspec must include a secondary artifacts section which controls the artifacts deployed to the bucket [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) | `string` | `null` | no | | [secondary\_artifact\_encryption\_enabled](#input\_secondary\_artifact\_encryption\_enabled) | If set to true, enable encryption on the secondary artifact bucket | `bool` | `false` | no | | [secondary\_artifact\_identifier](#input\_secondary\_artifact\_identifier) | Identifier for optional secondary artifact deployment. If specified, the identifier must appear in the buildspec as the name of the section which controls the artifacts deployed to the secondary artifact bucket [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) | `string` | `null` | no | -| [service\_name](#input\_service\_name) | ECS Service Name | `string` | n/a | yes | +| [service\_name](#input\_service\_name) | ECS Service Name, not required if you have deploy stage disabled | `string` | `""` | no | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | | [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 7c51802..f6055c5 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -77,8 +77,9 @@ | [codestar\_output\_artifact\_format](#input\_codestar\_output\_artifact\_format) | Output artifact type for Source stage in pipeline. Valid values are "CODE\_ZIP" (default) and "CODEBUILD\_CLONE\_REF". See https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CodestarConnectionSource.html | `string` | `"CODE_ZIP"` | 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,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
| no | | [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | +| [deploy\_stage\_enabled](#input\_deploy\_stage\_enabled) | Set to false to disable the deploy stage | `bool` | `true` | no | | [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
`labels` is a list of labels, in order, to pass to `format()` function.
Label values will be normalized before being passed to `format()` so they will be
identical to how they appear in `id`.
Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no | -| [ecs\_cluster\_name](#input\_ecs\_cluster\_name) | ECS Cluster Name | `string` | n/a | yes | +| [ecs\_cluster\_name](#input\_ecs\_cluster\_name) | ECS Cluster Name, not required if you have deploy stage disabled | `string` | `""` | no | | [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | | [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | | [environment\_variables](#input\_environment\_variables) | A list of maps, that contain the keys 'name', 'value', and 'type' to be used as additional environment variables for the build. Valid types are 'PLAINTEXT', 'PARAMETER\_STORE', or 'SECRETS\_MANAGER' |
list(object(
{
name = string
value = string
type = string
}))
| `[]` | no | @@ -104,7 +105,7 @@ | [secondary\_artifact\_bucket\_id](#input\_secondary\_artifact\_bucket\_id) | Optional bucket for secondary artifact deployment. If specified, the buildspec must include a secondary artifacts section which controls the artifacts deployed to the bucket [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) | `string` | `null` | no | | [secondary\_artifact\_encryption\_enabled](#input\_secondary\_artifact\_encryption\_enabled) | If set to true, enable encryption on the secondary artifact bucket | `bool` | `false` | no | | [secondary\_artifact\_identifier](#input\_secondary\_artifact\_identifier) | Identifier for optional secondary artifact deployment. If specified, the identifier must appear in the buildspec as the name of the section which controls the artifacts deployed to the secondary artifact bucket [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) | `string` | `null` | no | -| [service\_name](#input\_service\_name) | ECS Service Name | `string` | n/a | yes | +| [service\_name](#input\_service\_name) | ECS Service Name, not required if you have deploy stage disabled | `string` | `""` | no | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | | [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no | diff --git a/examples/complete/main.tf b/examples/complete/main.tf index ab37526..c1841c9 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -87,6 +87,7 @@ module "ecs_codepipeline" { ecs_cluster_name = aws_ecs_cluster.default.name service_name = module.ecs_alb_service_task.service_name codebuild_extra_policy_arns = var.codebuild_extra_policy_arns + deploy_stage_enabled = var.deploy_stage_enabled context = module.this.context } diff --git a/examples/complete/variables.tf b/examples/complete/variables.tf index 6f48af7..e783d92 100644 --- a/examples/complete/variables.tf +++ b/examples/complete/variables.tf @@ -203,4 +203,10 @@ variable "codebuild_extra_policy_arns" { type = list(string) default = [] description = "List of ARNs of extra policies to attach to the CodeBuild role" +} + +variable "deploy_stage_enabled" { + type = bool + default = true + description = "Set to false to disable the deploy stage" } \ No newline at end of file diff --git a/main.tf b/main.tf index 2feda47..a665c7b 100644 --- a/main.tf +++ b/main.tf @@ -315,20 +315,24 @@ resource "aws_codepipeline" "default" { } } - stage { - name = "Deploy" - - action { - name = "Deploy" - category = "Deploy" - owner = "AWS" - provider = "ECS" - input_artifacts = ["task"] - version = "1" - - configuration = { - ClusterName = var.ecs_cluster_name - ServiceName = var.service_name + dynamic "stage" { + for_each = var.deploy_stage_enabled ? [1] : [] + + content { + name = "Deploy" + + action { + name = "Deploy" + category = "Deploy" + owner = "AWS" + provider = "ECS" + input_artifacts = ["task"] + version = "1" + + configuration = { + ClusterName = var.ecs_cluster_name + ServiceName = var.service_name + } } } } @@ -398,20 +402,24 @@ resource "aws_codepipeline" "bitbucket" { } } - stage { - name = "Deploy" + dynamic "stage" { + for_each = var.deploy_stage_enabled ? [1] : [] - action { - name = "Deploy" - category = "Deploy" - owner = "AWS" - provider = "ECS" - input_artifacts = ["task"] - version = "1" + content { + name = "Deploy" - configuration = { - ClusterName = var.ecs_cluster_name - ServiceName = var.service_name + action { + name = "Deploy" + category = "Deploy" + owner = "AWS" + provider = "ECS" + input_artifacts = ["task"] + version = "1" + + configuration = { + ClusterName = var.ecs_cluster_name + ServiceName = var.service_name + } } } } diff --git a/variables.tf b/variables.tf index 9b5ff3f..526de48 100644 --- a/variables.tf +++ b/variables.tf @@ -1,11 +1,13 @@ variable "ecs_cluster_name" { type = string - description = "ECS Cluster Name" + description = "ECS Cluster Name, not required if you have deploy stage disabled" + default = "" } variable "service_name" { type = string - description = "ECS Service Name" + description = "ECS Service Name, not required if you have deploy stage disabled" + default = "" } variable "github_oauth_token" { @@ -209,4 +211,10 @@ variable "codebuild_extra_policy_arns" { type = list(string) default = [] description = "List of ARNs of extra policies to attach to the CodeBuild role" +} + +variable "deploy_stage_enabled" { + type = bool + default = true + description = "Set to false to disable the deploy stage" } \ No newline at end of file