diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index bed3c96..07b38d2 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -12,3 +12,6 @@
# Cloud Posse must review any changes to GitHub actions
.github/* @cloudposse/engineering
+
+# Cloud Posse must review any changes to standard context definition
+**/context.tf @cloudposse/engineering
diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml
index e21fbfe..ccc27be 100644
--- a/.github/workflows/auto-release.yml
+++ b/.github/workflows/auto-release.yml
@@ -3,17 +3,17 @@ name: auto-release
on:
push:
branches:
- - master
+ - master
jobs:
semver:
runs-on: ubuntu-latest
steps:
- # Drafts your next Release notes as Pull Requests are merged into "master"
- - uses: release-drafter/release-drafter@v5
- with:
- publish: true
- prerelease: false
- config-name: auto-release.yml
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ # Drafts your next Release notes as Pull Requests are merged into "master"
+ - uses: release-drafter/release-drafter@v5
+ with:
+ publish: true
+ prerelease: false
+ config-name: auto-release.yml
+ env:
+ GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
diff --git a/README.md b/README.md
index 9a8e352..b1720da 100644
--- a/README.md
+++ b/README.md
@@ -177,24 +177,25 @@ Available targets:
| Name | Version |
|------|---------|
| terraform | >= 0.12.0 |
-| aws | ~> 2.0 |
-| local | ~> 1.2 |
-| null | ~> 2.0 |
-| random | ~> 2.1 |
-| template | ~> 2.0 |
+| aws | >= 2.0 |
+| local | >= 1.2 |
+| null | >= 2.0 |
+| random | >= 2.1 |
+| template | >= 2.0 |
## Providers
| Name | Version |
|------|---------|
-| aws | ~> 2.0 |
-| random | ~> 2.1 |
+| aws | >= 2.0 |
+| random | >= 2.1 |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
-| attributes | Additional attributes (\_e.g.\_ "1") | `list(string)` | `[]` | no |
+| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
+| attributes | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no |
| aws\_account\_id | AWS Account ID. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | `""` | no |
| badge\_enabled | Generates a publicly-accessible URL for the projects build badge. Available as badge\_url attribute when enabled | `bool` | `false` | no |
| branch | Branch of the GitHub repository, _e.g._ `master` | `string` | n/a | yes |
@@ -204,29 +205,33 @@ Available targets:
| buildspec | Declaration to use for building the project. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) | `string` | `""` | no |
| cache\_type | The type of storage that will be used for the AWS CodeBuild project cache. Valid values: NO\_CACHE, LOCAL, and S3. Defaults to S3. If cache\_type is S3, it will create an S3 bucket for storing codebuild cache inside | `string` | `"S3"` | no |
| codestar\_connection\_arn | CodeStar connection ARN required for Bitbucket integration with CodePipeline | `string` | `""` | no |
-| delimiter | Delimiter between `namespace`, `stage`, `name` and `attributes` | `string` | `"-"` | 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. |
object({
enabled = bool
namespace = string
environment = string
stage = string
name = string
delimiter = string
attributes = list(string)
tags = map(string)
additional_tag_map = map(string)
regex_replace_chars = string
label_order = list(string)
id_length_limit = number
})
| {
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_order": [],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
}
| 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 |
| ecs\_cluster\_name | ECS Cluster Name | `string` | n/a | yes |
-| enabled | Enable `CodePipeline` creation | `bool` | `true` | no |
-| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | `string` | `""` | 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 |
| environment\_variables | A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build | list(object(
{
name = string
value = string
}))
| `[]` | no |
| github\_anonymous | Github Anonymous API (if `true`, token must not be set as GITHUB\_TOKEN or `github_token`) | `bool` | `false` | no |
| github\_oauth\_token | GitHub OAuth Token with permissions to access private repositories | `string` | `""` | no |
| github\_webhook\_events | A list of events which should trigger the webhook. See a list of [available events](https://developer.github.com/v3/activity/events/types/) | `list(string)` | [
"push"
]
| no |
| github\_webhooks\_token | GitHub OAuth Token with permissions to create webhooks. If not provided, can be sourced from the `GITHUB_TOKEN` environment variable | `string` | `""` | no |
+| id\_length\_limit | Limit `id` to this many characters.
Set to `0` for unlimited length.
Set to `null` for default, which is `0`.
Does not affect `id_full`. | `number` | `null` | no |
| image\_repo\_name | ECR repository name to store the Docker image built by this module. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | n/a | yes |
| image\_tag | Docker image tag in the ECR repository, e.g. 'latest'. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | `"latest"` | 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 |
| local\_cache\_modes | Specifies settings that AWS CodeBuild uses to store and reuse build dependencies. Valid values: LOCAL\_SOURCE\_CACHE, LOCAL\_DOCKER\_LAYER\_CACHE, and LOCAL\_CUSTOM\_CACHE | `list(string)` | `[]` | no |
-| name | Name of the application | `string` | n/a | yes |
-| namespace | Namespace (e.g. `eg` or `cp`) | `string` | `""` | 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 |
| poll\_source\_changes | Periodically check the location of your source content and run the pipeline if changes are detected | `bool` | `false` | no |
| privileged\_mode | If set to true, enables running the Docker daemon inside a Docker container on the CodeBuild instance. Used when building Docker images | `bool` | `false` | 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 |
| region | AWS Region, e.g. us-east-1. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | n/a | yes |
| repo\_name | GitHub repository name of the application to be built and deployed to ECS | `string` | n/a | yes |
| repo\_owner | GitHub Organization or Username | `string` | n/a | yes |
| s3\_bucket\_force\_destroy | A boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without error | `bool` | `false` | no |
| service\_name | ECS Service Name | `string` | n/a | yes |
-| stage | Stage (e.g. `prod`, `dev`, `staging`) | `string` | `""` | no |
-| tags | Additional tags (\_e.g.\_ { BusinessUnit : ABC }) | `map(string)` | `{}` | 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 |
| webhook\_authentication | The type of authentication to use. One of IP, GITHUB\_HMAC, or UNAUTHENTICATED | `string` | `"GITHUB_HMAC"` | no |
| webhook\_enabled | Set to false to prevent the module from creating any webhook resources | `bool` | `true` | no |
| webhook\_filter\_json\_path | The JSON path to filter on | `string` | `"$.ref"` | no |
@@ -411,8 +416,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
### Contributors
-| [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]
[Andriy Knysh][aknysh_homepage] | [![Sarkis Varozian][sarkis_avatar]][sarkis_homepage]
[Sarkis Varozian][sarkis_homepage] |
-|---|---|---|---|
+| [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]
[Andriy Knysh][aknysh_homepage] | [![Sarkis Varozian][sarkis_avatar]][sarkis_homepage]
[Sarkis Varozian][sarkis_homepage] | [![Joe Niland][joe-niland_avatar]][joe-niland_homepage]
[Joe Niland][joe-niland_homepage] |
+|---|---|---|---|---|
[osterman_homepage]: https://github.com/osterman
[osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png
@@ -422,6 +427,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
[aknysh_avatar]: https://img.cloudposse.com/150x150/https://github.com/aknysh.png
[sarkis_homepage]: https://github.com/sarkis
[sarkis_avatar]: https://img.cloudposse.com/150x150/https://github.com/sarkis.png
+ [joe-niland_homepage]: https://github.com/joe-niland
+ [joe-niland_avatar]: https://img.cloudposse.com/150x150/https://github.com/joe-niland.png
[![README Footer][readme_footer_img]][readme_footer_link]
[![Beacon][beacon]][website]
diff --git a/README.yaml b/README.yaml
index 45948f3..8cff681 100644
--- a/README.yaml
+++ b/README.yaml
@@ -171,3 +171,5 @@ contributors:
github: "aknysh"
- name: "Sarkis Varozian"
github: "sarkis"
+ - name: "Joe Niland"
+ github: "joe-niland"
diff --git a/context.tf b/context.tf
new file mode 100644
index 0000000..64630e4
--- /dev/null
+++ b/context.tf
@@ -0,0 +1,167 @@
+#
+# ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label
+# All other instances of this file should be a copy of that one
+#
+#
+# Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf
+# and then place it in your Terraform module to automatically get
+# Cloud Posse's standard configuration inputs suitable for passing
+# to Cloud Posse modules.
+#
+# Modules should access the whole context as `module.this.context`
+# to get the input variables with nulls for defaults,
+# for example `context = module.this.context`,
+# and access individual variables as `module.this.`,
+# with final values filled in.
+#
+# For example, when using defaults, `module.this.context.delimiter`
+# will be null, and `module.this.delimiter` will be `-` (hyphen).
+#
+
+module "this" {
+ source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.21.0"
+
+ enabled = var.enabled
+ namespace = var.namespace
+ environment = var.environment
+ stage = var.stage
+ name = var.name
+ delimiter = var.delimiter
+ attributes = var.attributes
+ tags = var.tags
+ additional_tag_map = var.additional_tag_map
+ label_order = var.label_order
+ regex_replace_chars = var.regex_replace_chars
+ id_length_limit = var.id_length_limit
+
+ context = var.context
+}
+
+# Copy contents of cloudposse/terraform-null-label/variables.tf here
+
+variable "context" {
+ type = object({
+ enabled = bool
+ namespace = string
+ environment = string
+ stage = string
+ name = string
+ delimiter = string
+ attributes = list(string)
+ tags = map(string)
+ additional_tag_map = map(string)
+ regex_replace_chars = string
+ label_order = list(string)
+ id_length_limit = number
+ })
+ default = {
+ enabled = true
+ namespace = null
+ environment = null
+ stage = null
+ name = null
+ delimiter = null
+ attributes = []
+ tags = {}
+ additional_tag_map = {}
+ regex_replace_chars = null
+ label_order = []
+ id_length_limit = null
+ }
+ description = <<-EOT
+ 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.
+ EOT
+}
+
+variable "enabled" {
+ type = bool
+ default = null
+ description = "Set to false to prevent the module from creating any resources"
+}
+
+variable "namespace" {
+ type = string
+ default = null
+ description = "Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'"
+}
+
+variable "environment" {
+ type = string
+ default = null
+ description = "Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT'"
+}
+
+variable "stage" {
+ type = string
+ default = null
+ description = "Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release'"
+}
+
+variable "name" {
+ type = string
+ default = null
+ description = "Solution name, e.g. 'app' or 'jenkins'"
+}
+
+variable "delimiter" {
+ type = string
+ default = null
+ description = <<-EOT
+ Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.
+ Defaults to `-` (hyphen). Set to `""` to use no delimiter at all.
+ EOT
+}
+
+variable "attributes" {
+ type = list(string)
+ default = []
+ description = "Additional attributes (e.g. `1`)"
+}
+
+variable "tags" {
+ type = map(string)
+ default = {}
+ description = "Additional tags (e.g. `map('BusinessUnit','XYZ')`"
+}
+
+variable "additional_tag_map" {
+ type = map(string)
+ default = {}
+ description = "Additional tags for appending to tags_as_list_of_maps. Not added to `tags`."
+}
+
+variable "label_order" {
+ type = list(string)
+ default = null
+ description = <<-EOT
+ 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.
+ EOT
+}
+
+variable "regex_replace_chars" {
+ type = string
+ default = null
+ description = <<-EOT
+ 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.
+ EOT
+}
+
+variable "id_length_limit" {
+ type = number
+ default = null
+ description = <<-EOT
+ Limit `id` to this many characters.
+ Set to `0` for unlimited length.
+ Set to `null` for default, which is `0`.
+ Does not affect `id_full`.
+ EOT
+}
+
+#### End of copy of cloudposse/terraform-null-label/variables.tf
\ No newline at end of file
diff --git a/docs/terraform.md b/docs/terraform.md
index 069cb34..b1e1167 100644
--- a/docs/terraform.md
+++ b/docs/terraform.md
@@ -4,24 +4,25 @@
| Name | Version |
|------|---------|
| terraform | >= 0.12.0 |
-| aws | ~> 2.0 |
-| local | ~> 1.2 |
-| null | ~> 2.0 |
-| random | ~> 2.1 |
-| template | ~> 2.0 |
+| aws | >= 2.0 |
+| local | >= 1.2 |
+| null | >= 2.0 |
+| random | >= 2.1 |
+| template | >= 2.0 |
## Providers
| Name | Version |
|------|---------|
-| aws | ~> 2.0 |
-| random | ~> 2.1 |
+| aws | >= 2.0 |
+| random | >= 2.1 |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
-| attributes | Additional attributes (\_e.g.\_ "1") | `list(string)` | `[]` | no |
+| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
+| attributes | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no |
| aws\_account\_id | AWS Account ID. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | `""` | no |
| badge\_enabled | Generates a publicly-accessible URL for the projects build badge. Available as badge\_url attribute when enabled | `bool` | `false` | no |
| branch | Branch of the GitHub repository, _e.g._ `master` | `string` | n/a | yes |
@@ -31,29 +32,33 @@
| buildspec | Declaration to use for building the project. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) | `string` | `""` | no |
| cache\_type | The type of storage that will be used for the AWS CodeBuild project cache. Valid values: NO\_CACHE, LOCAL, and S3. Defaults to S3. If cache\_type is S3, it will create an S3 bucket for storing codebuild cache inside | `string` | `"S3"` | no |
| codestar\_connection\_arn | CodeStar connection ARN required for Bitbucket integration with CodePipeline | `string` | `""` | no |
-| delimiter | Delimiter between `namespace`, `stage`, `name` and `attributes` | `string` | `"-"` | 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. | object({
enabled = bool
namespace = string
environment = string
stage = string
name = string
delimiter = string
attributes = list(string)
tags = map(string)
additional_tag_map = map(string)
regex_replace_chars = string
label_order = list(string)
id_length_limit = number
})
| {
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_order": [],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
}
| 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 |
| ecs\_cluster\_name | ECS Cluster Name | `string` | n/a | yes |
-| enabled | Enable `CodePipeline` creation | `bool` | `true` | no |
-| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | `string` | `""` | 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 |
| environment\_variables | A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build | list(object(
{
name = string
value = string
}))
| `[]` | no |
| github\_anonymous | Github Anonymous API (if `true`, token must not be set as GITHUB\_TOKEN or `github_token`) | `bool` | `false` | no |
| github\_oauth\_token | GitHub OAuth Token with permissions to access private repositories | `string` | `""` | no |
| github\_webhook\_events | A list of events which should trigger the webhook. See a list of [available events](https://developer.github.com/v3/activity/events/types/) | `list(string)` | [
"push"
]
| no |
| github\_webhooks\_token | GitHub OAuth Token with permissions to create webhooks. If not provided, can be sourced from the `GITHUB_TOKEN` environment variable | `string` | `""` | no |
+| id\_length\_limit | Limit `id` to this many characters.
Set to `0` for unlimited length.
Set to `null` for default, which is `0`.
Does not affect `id_full`. | `number` | `null` | no |
| image\_repo\_name | ECR repository name to store the Docker image built by this module. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | n/a | yes |
| image\_tag | Docker image tag in the ECR repository, e.g. 'latest'. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | `"latest"` | 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 |
| local\_cache\_modes | Specifies settings that AWS CodeBuild uses to store and reuse build dependencies. Valid values: LOCAL\_SOURCE\_CACHE, LOCAL\_DOCKER\_LAYER\_CACHE, and LOCAL\_CUSTOM\_CACHE | `list(string)` | `[]` | no |
-| name | Name of the application | `string` | n/a | yes |
-| namespace | Namespace (e.g. `eg` or `cp`) | `string` | `""` | 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 |
| poll\_source\_changes | Periodically check the location of your source content and run the pipeline if changes are detected | `bool` | `false` | no |
| privileged\_mode | If set to true, enables running the Docker daemon inside a Docker container on the CodeBuild instance. Used when building Docker images | `bool` | `false` | 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 |
| region | AWS Region, e.g. us-east-1. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | n/a | yes |
| repo\_name | GitHub repository name of the application to be built and deployed to ECS | `string` | n/a | yes |
| repo\_owner | GitHub Organization or Username | `string` | n/a | yes |
| s3\_bucket\_force\_destroy | A boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without error | `bool` | `false` | no |
| service\_name | ECS Service Name | `string` | n/a | yes |
-| stage | Stage (e.g. `prod`, `dev`, `staging`) | `string` | `""` | no |
-| tags | Additional tags (\_e.g.\_ { BusinessUnit : ABC }) | `map(string)` | `{}` | 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 |
| webhook\_authentication | The type of authentication to use. One of IP, GITHUB\_HMAC, or UNAUTHENTICATED | `string` | `"GITHUB_HMAC"` | no |
| webhook\_enabled | Set to false to prevent the module from creating any webhook resources | `bool` | `true` | no |
| webhook\_filter\_json\_path | The JSON path to filter on | `string` | `"$.ref"` | no |
diff --git a/examples/complete/context.tf b/examples/complete/context.tf
new file mode 100644
index 0000000..64630e4
--- /dev/null
+++ b/examples/complete/context.tf
@@ -0,0 +1,167 @@
+#
+# ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label
+# All other instances of this file should be a copy of that one
+#
+#
+# Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf
+# and then place it in your Terraform module to automatically get
+# Cloud Posse's standard configuration inputs suitable for passing
+# to Cloud Posse modules.
+#
+# Modules should access the whole context as `module.this.context`
+# to get the input variables with nulls for defaults,
+# for example `context = module.this.context`,
+# and access individual variables as `module.this.`,
+# with final values filled in.
+#
+# For example, when using defaults, `module.this.context.delimiter`
+# will be null, and `module.this.delimiter` will be `-` (hyphen).
+#
+
+module "this" {
+ source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.21.0"
+
+ enabled = var.enabled
+ namespace = var.namespace
+ environment = var.environment
+ stage = var.stage
+ name = var.name
+ delimiter = var.delimiter
+ attributes = var.attributes
+ tags = var.tags
+ additional_tag_map = var.additional_tag_map
+ label_order = var.label_order
+ regex_replace_chars = var.regex_replace_chars
+ id_length_limit = var.id_length_limit
+
+ context = var.context
+}
+
+# Copy contents of cloudposse/terraform-null-label/variables.tf here
+
+variable "context" {
+ type = object({
+ enabled = bool
+ namespace = string
+ environment = string
+ stage = string
+ name = string
+ delimiter = string
+ attributes = list(string)
+ tags = map(string)
+ additional_tag_map = map(string)
+ regex_replace_chars = string
+ label_order = list(string)
+ id_length_limit = number
+ })
+ default = {
+ enabled = true
+ namespace = null
+ environment = null
+ stage = null
+ name = null
+ delimiter = null
+ attributes = []
+ tags = {}
+ additional_tag_map = {}
+ regex_replace_chars = null
+ label_order = []
+ id_length_limit = null
+ }
+ description = <<-EOT
+ 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.
+ EOT
+}
+
+variable "enabled" {
+ type = bool
+ default = null
+ description = "Set to false to prevent the module from creating any resources"
+}
+
+variable "namespace" {
+ type = string
+ default = null
+ description = "Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'"
+}
+
+variable "environment" {
+ type = string
+ default = null
+ description = "Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT'"
+}
+
+variable "stage" {
+ type = string
+ default = null
+ description = "Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release'"
+}
+
+variable "name" {
+ type = string
+ default = null
+ description = "Solution name, e.g. 'app' or 'jenkins'"
+}
+
+variable "delimiter" {
+ type = string
+ default = null
+ description = <<-EOT
+ Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.
+ Defaults to `-` (hyphen). Set to `""` to use no delimiter at all.
+ EOT
+}
+
+variable "attributes" {
+ type = list(string)
+ default = []
+ description = "Additional attributes (e.g. `1`)"
+}
+
+variable "tags" {
+ type = map(string)
+ default = {}
+ description = "Additional tags (e.g. `map('BusinessUnit','XYZ')`"
+}
+
+variable "additional_tag_map" {
+ type = map(string)
+ default = {}
+ description = "Additional tags for appending to tags_as_list_of_maps. Not added to `tags`."
+}
+
+variable "label_order" {
+ type = list(string)
+ default = null
+ description = <<-EOT
+ 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.
+ EOT
+}
+
+variable "regex_replace_chars" {
+ type = string
+ default = null
+ description = <<-EOT
+ 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.
+ EOT
+}
+
+variable "id_length_limit" {
+ type = number
+ default = null
+ description = <<-EOT
+ Limit `id` to this many characters.
+ Set to `0` for unlimited length.
+ Set to `null` for default, which is `0`.
+ Does not affect `id_full`.
+ EOT
+}
+
+#### End of copy of cloudposse/terraform-null-label/variables.tf
\ No newline at end of file
diff --git a/examples/complete/main.tf b/examples/complete/main.tf
index 1c43fd6..e89f833 100644
--- a/examples/complete/main.tf
+++ b/examples/complete/main.tf
@@ -2,47 +2,26 @@ provider "aws" {
region = var.region
}
-module "label" {
- source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0"
- namespace = var.namespace
- environment = var.environment
- stage = var.stage
- name = var.name
- delimiter = var.delimiter
- attributes = var.attributes
- tags = var.tags
-}
-
module "vpc" {
- source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.16.1"
- namespace = var.namespace
- stage = var.stage
- name = var.name
- delimiter = var.delimiter
- attributes = var.attributes
+ source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.18.0"
cidr_block = var.vpc_cidr_block
- tags = var.tags
+ context = module.this.context
}
module "subnets" {
- source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.26.0"
+ source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.31.0"
availability_zones = var.availability_zones
- namespace = var.namespace
- stage = var.stage
- name = var.name
- attributes = var.attributes
- delimiter = var.delimiter
vpc_id = module.vpc.vpc_id
igw_id = module.vpc.igw_id
cidr_block = module.vpc.vpc_cidr_block
nat_gateway_enabled = true
nat_instance_enabled = false
- tags = var.tags
+ context = module.this.context
}
resource "aws_ecs_cluster" "default" {
- name = module.label.id
- tags = module.label.tags
+ name = module.this.id
+ tags = module.this.tags
}
module "container_definition" {
@@ -59,12 +38,12 @@ module "container_definition" {
}
module "ecs_alb_service_task" {
- source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.39.0"
- namespace = var.namespace
- stage = var.stage
- name = var.name
- attributes = var.attributes
- delimiter = var.delimiter
+ source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.40.2"
+ namespace = module.this.namespace
+ stage = module.this.stage
+ name = module.this.name
+ attributes = module.this.attributes
+ delimiter = module.this.delimiter
alb_security_group = module.vpc.vpc_default_security_group_id
container_definition_json = module.container_definition.json_map_encoded_list
ecs_cluster_arn = aws_ecs_cluster.default.arn
@@ -72,7 +51,7 @@ module "ecs_alb_service_task" {
vpc_id = module.vpc.vpc_id
security_group_ids = [module.vpc.vpc_default_security_group_id]
subnet_ids = module.subnets.public_subnet_ids
- tags = var.tags
+ tags = module.this.tags
ignore_changes_task_definition = var.ignore_changes_task_definition
network_mode = var.network_mode
assign_public_ip = var.assign_public_ip
@@ -87,10 +66,6 @@ module "ecs_alb_service_task" {
module "ecs_codepipeline" {
source = "../../"
- namespace = var.namespace
- environment = var.environment
- stage = var.stage
- name = var.name
region = var.region
github_oauth_token = var.github_oauth_token
repo_owner = var.repo_owner
@@ -108,4 +83,5 @@ module "ecs_codepipeline" {
environment_variables = var.environment_variables
ecs_cluster_name = aws_ecs_cluster.default.name
service_name = module.ecs_alb_service_task.service_name
+ context = module.this.context
}
diff --git a/examples/complete/variables.tf b/examples/complete/variables.tf
index 1111f12..1354fb8 100644
--- a/examples/complete/variables.tf
+++ b/examples/complete/variables.tf
@@ -13,45 +13,6 @@ variable "vpc_cidr_block" {
description = "VPC CIDR block"
}
-variable "namespace" {
- type = string
- description = "Namespace (e.g. `eg` or `cp`)"
-}
-
-variable "environment" {
- type = string
- default = ""
- description = "Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT'"
-}
-
-variable "stage" {
- type = string
- description = "Stage (e.g. `prod`, `dev`, `staging`)"
-}
-
-variable "name" {
- type = string
- description = "Name of the application"
-}
-
-variable "delimiter" {
- type = string
- default = "-"
- description = "Delimiter between `namespace`, `stage`, `name` and `attributes`"
-}
-
-variable "attributes" {
- type = list(string)
- description = "Additional attributes (_e.g._ \"1\")"
- default = []
-}
-
-variable "tags" {
- type = map(string)
- description = "Additional tags (_e.g._ { BusinessUnit : ABC })"
- default = {}
-}
-
variable "ecs_launch_type" {
type = string
description = "ECS launch type"
diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf
index 287fdab..231179c 100644
--- a/examples/complete/versions.tf
+++ b/examples/complete/versions.tf
@@ -2,10 +2,10 @@ terraform {
required_version = ">= 0.12.0"
required_providers {
- aws = "~> 2.0"
- template = "~> 2.0"
- local = "~> 1.2"
- random = "~> 2.1"
- null = "~> 2.0"
+ aws = ">= 2.0"
+ template = ">= 2.0"
+ local = ">= 1.2"
+ random = ">= 2.1"
+ null = ">= 2.0"
}
}
diff --git a/main.tf b/main.tf
index 1465097..69e1b9f 100644
--- a/main.tf
+++ b/main.tf
@@ -1,17 +1,11 @@
module "codepipeline_label" {
- source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0"
- enabled = var.enabled
- attributes = compact(concat(var.attributes, ["codepipeline"]))
- delimiter = var.delimiter
- name = var.name
- namespace = var.namespace
- environment = var.environment
- stage = var.stage
- tags = var.tags
+ source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.21.0"
+ attributes = compact(concat(var.attributes, ["codepipeline"]))
+ context = module.this.context
}
resource "aws_s3_bucket" "default" {
- count = var.enabled ? 1 : 0
+ count = module.this.enabled ? 1 : 0
bucket = module.codepipeline_label.id
acl = "private"
force_destroy = var.s3_bucket_force_destroy
@@ -19,19 +13,13 @@ resource "aws_s3_bucket" "default" {
}
module "codepipeline_assume_role_label" {
- source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0"
- enabled = var.enabled
- attributes = compact(concat(var.attributes, ["codepipeline", "assume"]))
- delimiter = var.delimiter
- name = var.name
- namespace = var.namespace
- environment = var.environment
- stage = var.stage
- tags = var.tags
+ source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.21.0"
+ context = module.this.context
+ attributes = compact(concat(var.attributes, ["codepipeline", "assume"]))
}
resource "aws_iam_role" "default" {
- count = var.enabled ? 1 : 0
+ count = module.this.enabled ? 1 : 0
name = module.codepipeline_assume_role_label.id
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
@@ -54,13 +42,13 @@ data "aws_iam_policy_document" "assume_role" {
}
resource "aws_iam_role_policy_attachment" "default" {
- count = var.enabled ? 1 : 0
+ count = module.this.enabled ? 1 : 0
role = join("", aws_iam_role.default.*.id)
policy_arn = join("", aws_iam_policy.default.*.arn)
}
resource "aws_iam_policy" "default" {
- count = var.enabled ? 1 : 0
+ count = module.this.enabled ? 1 : 0
name = module.codepipeline_label.id
policy = data.aws_iam_policy_document.default.json
}
@@ -89,31 +77,25 @@ data "aws_iam_policy_document" "default" {
}
resource "aws_iam_role_policy_attachment" "s3" {
- count = var.enabled ? 1 : 0
+ count = module.this.enabled ? 1 : 0
role = join("", aws_iam_role.default.*.id)
policy_arn = join("", aws_iam_policy.s3.*.arn)
}
module "codepipeline_s3_policy_label" {
- source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0"
- enabled = var.enabled
- attributes = compact(concat(var.attributes, ["codepipeline", "s3"]))
- delimiter = var.delimiter
- name = var.name
- namespace = var.namespace
- environment = var.environment
- stage = var.stage
- tags = var.tags
+ source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.21.0"
+ attributes = compact(concat(var.attributes, ["codepipeline", "s3"]))
+ context = module.this.context
}
resource "aws_iam_policy" "s3" {
- count = var.enabled ? 1 : 0
+ count = module.this.enabled ? 1 : 0
name = module.codepipeline_s3_policy_label.id
policy = join("", data.aws_iam_policy_document.s3.*.json)
}
data "aws_iam_policy_document" "s3" {
- count = var.enabled ? 1 : 0
+ count = module.this.enabled ? 1 : 0
statement {
sid = ""
@@ -135,25 +117,19 @@ data "aws_iam_policy_document" "s3" {
}
resource "aws_iam_role_policy_attachment" "codebuild" {
- count = var.enabled ? 1 : 0
+ count = module.this.enabled ? 1 : 0
role = join("", aws_iam_role.default.*.id)
policy_arn = join("", aws_iam_policy.codebuild.*.arn)
}
module "codebuild_label" {
- source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0"
- enabled = var.enabled
- attributes = compact(concat(var.attributes, ["codebuild"]))
- delimiter = var.delimiter
- name = var.name
- namespace = var.namespace
- environment = var.environment
- stage = var.stage
- tags = var.tags
+ source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.21.0"
+ attributes = compact(concat(var.attributes, ["codebuild"]))
+ context = module.this.context
}
resource "aws_iam_policy" "codebuild" {
- count = var.enabled ? 1 : 0
+ count = module.this.enabled ? 1 : 0
name = module.codebuild_label.id
policy = data.aws_iam_policy_document.codebuild.json
}
@@ -173,31 +149,26 @@ data "aws_iam_policy_document" "codebuild" {
# https://docs.aws.amazon.com/codepipeline/latest/userguide/connections-permissions.html
resource "aws_iam_role_policy_attachment" "codestar" {
- count = var.enabled && var.codestar_connection_arn != "" ? 1 : 0
+ count = module.this.enabled && var.codestar_connection_arn != "" ? 1 : 0
role = join("", aws_iam_role.default.*.id)
policy_arn = join("", aws_iam_policy.codestar.*.arn)
}
module "codestar_label" {
- source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0"
- enabled = var.enabled && var.codestar_connection_arn != ""
- attributes = compact(concat(var.attributes, ["codestar"]))
- delimiter = var.delimiter
- name = var.name
- namespace = var.namespace
- environment = var.environment
- stage = var.stage
- tags = var.tags
+ source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0"
+ enabled = module.this.enabled && var.codestar_connection_arn != ""
+ attributes = compact(concat(var.attributes, ["codestar"]))
+ context = module.this.context
}
resource "aws_iam_policy" "codestar" {
- count = var.enabled && var.codestar_connection_arn != "" ? 1 : 0
+ count = module.this.enabled && var.codestar_connection_arn != "" ? 1 : 0
name = module.codestar_label.id
policy = join("", data.aws_iam_policy_document.codestar.*.json)
}
data "aws_iam_policy_document" "codestar" {
- count = var.enabled && var.codestar_connection_arn != "" ? 1 : 0
+ count = module.this.enabled && var.codestar_connection_arn != "" ? 1 : 0
statement {
sid = ""
@@ -226,18 +197,18 @@ data "aws_region" "default" {
}
module "codebuild" {
- source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=tags/0.23.0"
- enabled = var.enabled
- namespace = var.namespace
- name = var.name
- stage = var.stage
+ source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=tags/0.25.0"
+ enabled = module.this.enabled
+ namespace = module.this.namespace
+ name = module.this.name
+ stage = module.this.stage
build_image = var.build_image
build_compute_type = var.build_compute_type
build_timeout = var.build_timeout
buildspec = var.buildspec
- delimiter = var.delimiter
- attributes = concat(var.attributes, ["build"])
- tags = var.tags
+ delimiter = module.this.delimiter
+ attributes = concat(module.this.attributes, ["build"])
+ tags = module.this.tags
privileged_mode = var.privileged_mode
aws_region = var.region != "" ? var.region : data.aws_region.default.name
aws_account_id = var.aws_account_id != "" ? var.aws_account_id : data.aws_caller_identity.default.account_id
@@ -251,13 +222,13 @@ module "codebuild" {
}
resource "aws_iam_role_policy_attachment" "codebuild_s3" {
- count = var.enabled ? 1 : 0
+ count = module.this.enabled ? 1 : 0
role = module.codebuild.role_id
policy_arn = join("", aws_iam_policy.s3.*.arn)
}
resource "aws_codepipeline" "default" {
- count = var.enabled && var.github_oauth_token != "" ? 1 : 0
+ count = module.this.enabled && var.github_oauth_token != "" ? 1 : 0
name = module.codepipeline_label.id
role_arn = join("", aws_iam_role.default.*.arn)
@@ -332,14 +303,14 @@ resource "aws_codepipeline" "default" {
}
lifecycle {
- # prevent github OAuthToken from causing updates, since it's removed from state file
+ # prevent github OAuthToken from causing updates, since it's removed from state file
ignore_changes = [stage[0].action[0].configuration]
}
}
# https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CodestarConnectionSource.html#action-reference-CodestarConnectionSource-example
resource "aws_codepipeline" "bitbucket" {
- count = var.enabled && var.codestar_connection_arn != "" ? 1 : 0
+ count = module.this.enabled && var.codestar_connection_arn != "" ? 1 : 0
name = module.codepipeline_label.id
role_arn = join("", aws_iam_role.default.*.arn)
@@ -415,7 +386,7 @@ resource "aws_codepipeline" "bitbucket" {
}
resource "random_string" "webhook_secret" {
- count = var.enabled && var.webhook_enabled ? 1 : 0
+ count = module.this.enabled && var.webhook_enabled ? 1 : 0
length = 32
# Special characters are not allowed in webhook secret (AWS silently ignores webhook callbacks)
@@ -428,7 +399,7 @@ locals {
}
resource "aws_codepipeline_webhook" "webhook" {
- count = var.enabled && var.webhook_enabled ? 1 : 0
+ count = module.this.enabled && var.webhook_enabled ? 1 : 0
name = module.codepipeline_label.id
authentication = var.webhook_authentication
target_action = var.webhook_target_action
@@ -446,7 +417,7 @@ resource "aws_codepipeline_webhook" "webhook" {
module "github_webhooks" {
source = "git::https://github.com/cloudposse/terraform-github-repository-webhooks.git?ref=tags/0.10.0"
- enabled = var.enabled && var.webhook_enabled ? true : false
+ enabled = module.this.enabled && var.webhook_enabled ? true : false
github_anonymous = var.github_anonymous
github_organization = var.repo_owner
github_repositories = [var.repo_name]
diff --git a/variables.tf b/variables.tf
index c042da5..32b1e79 100644
--- a/variables.tf
+++ b/variables.tf
@@ -1,50 +1,3 @@
-variable "namespace" {
- type = string
- description = "Namespace (e.g. `eg` or `cp`)"
- default = ""
-}
-
-variable "environment" {
- type = string
- default = ""
- description = "Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT'"
-}
-
-variable "stage" {
- type = string
- description = "Stage (e.g. `prod`, `dev`, `staging`)"
- default = ""
-}
-
-variable "name" {
- type = string
- description = "Name of the application"
-}
-
-variable "delimiter" {
- type = string
- default = "-"
- description = "Delimiter between `namespace`, `stage`, `name` and `attributes`"
-}
-
-variable "attributes" {
- type = list(string)
- description = "Additional attributes (_e.g._ \"1\")"
- default = []
-}
-
-variable "tags" {
- type = map(string)
- description = "Additional tags (_e.g._ { BusinessUnit : ABC })"
- default = {}
-}
-
-variable "enabled" {
- type = bool
- default = true
- description = "Enable `CodePipeline` creation"
-}
-
variable "ecs_cluster_name" {
type = string
description = "ECS Cluster Name"
diff --git a/versions.tf b/versions.tf
index 287fdab..231179c 100644
--- a/versions.tf
+++ b/versions.tf
@@ -2,10 +2,10 @@ terraform {
required_version = ">= 0.12.0"
required_providers {
- aws = "~> 2.0"
- template = "~> 2.0"
- local = "~> 1.2"
- random = "~> 2.1"
- null = "~> 2.0"
+ aws = ">= 2.0"
+ template = ">= 2.0"
+ local = ">= 1.2"
+ random = ">= 2.1"
+ null = ">= 2.0"
}
}