Skip to content

Commit 8998443

Browse files
authored
feat: upgrade module to support Terraform 0.12.x (#24)
* chore: upgrade module to Terraform 0.12.x * fix: update tests to use latest Terraform version BREAKING CHANGE: This module no longer supports Terraform versions 0.11.x. Please upgrade your version of Terraform and run the `0.12upgrade` command. Visit the following URL for more information: https://www.terraform.io/docs/commands/0.12upgrade.html * fix: change Terraform download URL to latest in CI
1 parent 23dc0da commit 8998443

File tree

10 files changed

+216
-227
lines changed

10 files changed

+216
-227
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ jobs:
88
- go/save-cache
99
- run:
1010
command: |
11-
wget --quiet https://releases.hashicorp.com/terraform/0.11.14/terraform_0.11.14_linux_amd64.zip
12-
sudo unzip terraform_0.11.14_linux_amd64.zip -d /usr/local/bin
11+
wget --quiet https://releases.hashicorp.com/terraform/0.12.23/terraform_0.12.23_linux_amd64.zip
12+
sudo unzip terraform_0.12.23_linux_amd64.zip -d /usr/local/bin
1313
name: Install Terraform
1414
- go/test
1515
release:

README.md

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -102,55 +102,62 @@ Invoking the commands defined below creates an ECS task definition with the foll
102102
By default, this module creates a task definition with a single container definition. To create a task definition with multiple container definitions, refer to the documentation of the [`merge`](modules/merge) module.
103103

104104
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
105+
## Providers
106+
107+
| Name | Version |
108+
|------|---------|
109+
| aws | n/a |
110+
| template | n/a |
111+
105112
## Inputs
106113

107114
| Name | Description | Type | Default | Required |
108-
|------|-------------|:----:|:-----:|:-----:|
109-
| command | The command that is passed to the container | list | `[]` | no |
110-
| cpu | The number of cpu units reserved for the container | string | `"0"` | no |
111-
| disableNetworking | When this parameter is true, networking is disabled within the container | string | `"false"` | no |
112-
| dnsSearchDomains | A list of DNS search domains that are presented to the container | list | `[]` | no |
113-
| dnsServers | A list of DNS servers that are presented to the container | list | `[]` | no |
114-
| dockerLabels | A key/value map of labels to add to the container | map | `{}` | no |
115-
| dockerSecurityOptions | A list of strings to provide custom labels for SELinux and AppArmor multi-level security systems | list | `[]` | no |
116-
| entryPoint | The entry point that is passed to the container | list | `[]` | no |
117-
| environment | The environment variables to pass to a container | list | `[]` | no |
118-
| essential | If the essential parameter of a container is marked as true, and that container fails or stops for any reason, all other containers that are part of the task are stopped | string | `"true"` | no |
119-
| execution\_role\_arn | The Amazon Resource Name (ARN) of the task execution role that the Amazon ECS container agent and the Docker daemon can assume | string | `""` | no |
120-
| extraHosts | A list of hostnames and IP address mappings to append to the /etc/hosts file on the container | list | `[]` | no |
121-
| family | You must specify a family for a task definition, which allows you to track multiple versions of the same task definition | string | n/a | yes |
122-
| healthCheck | The health check command and associated configuration parameters for the container | map | `{}` | no |
123-
| hostname | The hostname to use for your container | string | `""` | no |
124-
| image | The image used to start a container | string | `""` | no |
125-
| interactive | When this parameter is true, this allows you to deploy containerized applications that require stdin or a tty to be allocated | string | `"false"` | no |
126-
| ipc\_mode | The IPC resource namespace to use for the containers in the task | string | `"host"` | no |
127-
| links | The link parameter allows containers to communicate with each other without the need for port mappings | list | `[]` | no |
128-
| linuxParameters | Linux-specific modifications that are applied to the container, such as Linux KernelCapabilities | map | `{}` | no |
129-
| logConfiguration | The log configuration specification for the container | map | `{}` | no |
130-
| memory | The hard limit (in MiB) of memory to present to the container | string | `"0"` | no |
131-
| memoryReservation | The soft limit (in MiB) of memory to reserve for the container | string | `"0"` | no |
132-
| mountPoints | The mount points for data volumes in your container | list | `[]` | no |
133-
| name | The name of a container | string | `""` | no |
134-
| network\_mode | The Docker networking mode to use for the containers in the task | string | `"bridge"` | no |
135-
| pid\_mode | The process namespace to use for the containers in the task | string | `"host"` | no |
136-
| placement\_constraints | An array of placement constraint objects to use for the task | list | `[]` | no |
137-
| portMappings | The list of port mappings for the container | list | `[]` | no |
138-
| privileged | When this parameter is true, the container is given elevated privileges on the host container instance (similar to the root user) | string | `"false"` | no |
139-
| pseudoTerminal | When this parameter is true, a TTY is allocated | string | `"false"` | no |
140-
| readonlyRootFilesystem | When this parameter is true, the container is given read-only access to its root file system | string | `"false"` | no |
141-
| register\_task\_definition | Registers a new task definition from the supplied family and containerDefinitions | string | `"true"` | no |
142-
| repositoryCredentials | The private repository authentication credentials to use | map | `{}` | no |
143-
| requires\_compatibilities | The launch type required by the task | list | `[]` | no |
144-
| resourceRequirements | The type and amount of a resource to assign to a container | list | `[]` | no |
145-
| secrets | The secrets to pass to the container | list | `[]` | no |
146-
| systemControls | A list of namespaced kernel parameters to set in the container | list | `[]` | no |
147-
| tags | The metadata that you apply to the task definition to help you categorize and organize them | map | `{}` | no |
148-
| task\_role\_arn | The short name or full Amazon Resource Name (ARN) of the IAM role that containers in this task can assume | string | `""` | no |
149-
| ulimits | A list of ulimits to set in the container | list | `[]` | no |
150-
| user | The user name to use inside the container | string | `""` | no |
151-
| volumes | A list of volume definitions in JSON format that containers in your task may use | list | `[]` | no |
152-
| volumesFrom | Data volumes to mount from another container | list | `[]` | no |
153-
| workingDirectory | The working directory in which to run commands inside the container | string | `""` | no |
115+
|------|-------------|------|---------|:-----:|
116+
| command | The command that is passed to the container | `list(string)` | `[]` | no |
117+
| cpu | The number of cpu units reserved for the container | `number` | `0` | no |
118+
| disableNetworking | When this parameter is true, networking is disabled within the container | `bool` | `false` | no |
119+
| dnsSearchDomains | A list of DNS search domains that are presented to the container | `list(string)` | `[]` | no |
120+
| dnsServers | A list of DNS servers that are presented to the container | `list(string)` | `[]` | no |
121+
| dockerLabels | A key/value map of labels to add to the container | `map(string)` | `{}` | no |
122+
| dockerSecurityOptions | A list of strings to provide custom labels for SELinux and AppArmor multi-level security systems | `list(string)` | `[]` | no |
123+
| entryPoint | The entry point that is passed to the container | `list(string)` | `[]` | no |
124+
| environment | The environment variables to pass to a container | `list(map(string))` | `[]` | no |
125+
| essential | If the essential parameter of a container is marked as true, and that container fails or stops for any reason, all other containers that are part of the task are stopped | `bool` | `true` | no |
126+
| execution\_role\_arn | The Amazon Resource Name (ARN) of the task execution role that the Amazon ECS container agent and the Docker daemon can assume | `string` | `""` | no |
127+
| extraHosts | A list of hostnames and IP address mappings to append to the /etc/hosts file on the container | `list(string)` | `[]` | no |
128+
| family | You must specify a family for a task definition, which allows you to track multiple versions of the same task definition | `any` | n/a | yes |
129+
| healthCheck | The health check command and associated configuration parameters for the container | `any` | `{}` | no |
130+
| hostname | The hostname to use for your container | `string` | `""` | no |
131+
| image | The image used to start a container | `string` | `""` | no |
132+
| interactive | When this parameter is true, this allows you to deploy containerized applications that require stdin or a tty to be allocated | `bool` | `false` | no |
133+
| ipc\_mode | The IPC resource namespace to use for the containers in the task | `string` | `"host"` | no |
134+
| links | The link parameter allows containers to communicate with each other without the need for port mappings | `list(string)` | `[]` | no |
135+
| linuxParameters | Linux-specific modifications that are applied to the container, such as Linux KernelCapabilities | `any` | `{}` | no |
136+
| logConfiguration | The log configuration specification for the container | `map(string)` | `{}` | no |
137+
| memory | The hard limit (in MiB) of memory to present to the container | `number` | `0` | no |
138+
| memoryReservation | The soft limit (in MiB) of memory to reserve for the container | `number` | `0` | no |
139+
| mountPoints | The mount points for data volumes in your container | `list(any)` | `[]` | no |
140+
| name | The name of a container | `string` | `""` | no |
141+
| network\_mode | The Docker networking mode to use for the containers in the task | `string` | `"bridge"` | no |
142+
| pid\_mode | The process namespace to use for the containers in the task | `string` | `"host"` | no |
143+
| placement\_constraints | An array of placement constraint objects to use for the task | `list(string)` | `[]` | no |
144+
| portMappings | The list of port mappings for the container | `list(any)` | `[]` | no |
145+
| privileged | When this parameter is true, the container is given elevated privileges on the host container instance (similar to the root user) | `bool` | `false` | no |
146+
| pseudoTerminal | When this parameter is true, a TTY is allocated | `bool` | `false` | no |
147+
| readonlyRootFilesystem | When this parameter is true, the container is given read-only access to its root file system | `bool` | `false` | no |
148+
| register\_task\_definition | Registers a new task definition from the supplied family and containerDefinitions | `bool` | `true` | no |
149+
| repositoryCredentials | The private repository authentication credentials to use | `map(string)` | `{}` | no |
150+
| requires\_compatibilities | The launch type required by the task | `list(string)` | `[]` | no |
151+
| resourceRequirements | The type and amount of a resource to assign to a container | `list(string)` | `[]` | no |
152+
| secrets | The secrets to pass to the container | `list(string)` | `[]` | no |
153+
| systemControls | A list of namespaced kernel parameters to set in the container | `list(string)` | `[]` | no |
154+
| tags | The metadata that you apply to the task definition to help you categorize and organize them | `map(string)` | `{}` | no |
155+
| task\_role\_arn | The short name or full Amazon Resource Name (ARN) of the IAM role that containers in this task can assume | `string` | `""` | no |
156+
| ulimits | A list of ulimits to set in the container | `list(any)` | `[]` | no |
157+
| user | The user name to use inside the container | `string` | `""` | no |
158+
| volumes | A list of volume definitions in JSON format that containers in your task may use | `list(any)` | `[]` | no |
159+
| volumesFrom | Data volumes to mount from another container | `list(string)` | `[]` | no |
160+
| workingDirectory | The working directory in which to run commands inside the container | `string` | `""` | no |
154161

155162
## Outputs
156163

examples/ecs_update_service.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
#
99
# $ terraform taint null_resource.update-service
1010

11-
provider "aws" {}
11+
provider "aws" {
12+
region = "us-east-1"
13+
version = "~> 2.0"
14+
}
1215

1316
module "mongo-task-definition" {
1417
source = "github.com/mongodb/terraform-aws-ecs-task-definition"
@@ -28,12 +31,12 @@ module "mongo-task-definition" {
2831
resource "aws_ecs_service" "mongo" {
2932
cluster = "mongo"
3033
name = "mongo"
31-
task_definition = "${module.mongo-task-definition.arn}"
34+
task_definition = module.mongo-task-definition.arn
3235
}
3336

3437
resource "null_resource" "update-service" {
3538
triggers = {
36-
arn = "${module.mongo-task-definition.arn}"
39+
arn = module.mongo-task-definition.arn
3740
}
3841

3942
provisioner "local-exec" {

examples/terraform-task-definition-multiple-containers/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ module "merged" {
3838
source = "../../modules/merge"
3939

4040
container_definitions = [
41-
"${module.mongodb.container_definitions}",
42-
"${module.redis.container_definitions}",
41+
module.mongodb.container_definitions,
42+
module.redis.container_definitions,
4343
]
4444
}
4545

4646
resource "aws_ecs_task_definition" "ecs_task_definition" {
47-
container_definitions = "${module.merged.container_definitions}"
47+
container_definitions = module.merged.container_definitions
4848
family = "app"
4949
}

0 commit comments

Comments
 (0)