Skip to content

Commit

Permalink
Add support for extraHosts option (#62)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Gowie <gowie.matt@gmail.com>
Co-authored-by: actions-bot <58130806+actions-bot@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 15, 2020
1 parent 59d8c32 commit 0977c1d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Available targets:
| environment | The environment variables to pass to the container. This is a list of maps | object | `null` | no |
| environment_files | One or more files containing the environment variables to pass to the container. This maps to the --env-file option to docker run. The file must be hosted in Amazon S3. This option is only available to tasks using the EC2 launch type. This is a list of maps | object | `null` | no |
| essential | Determines whether all other containers in a task are stopped, if this container fails or stops for any reason. Due to how Terraform type casts booleans in json it is required to double quote this value | bool | `true` | no |
| extra_hosts | A list of hostnames and IP address mappings to append to the /etc/hosts file on the container. This is a list of maps | object | `null` | no |
| firelens_configuration | The FireLens configuration for the container. This is used to specify and configure a log router for container logs. For more details, see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_FirelensConfiguration.html | object | `null` | no |
| healthcheck | A map containing command (string), timeout, interval (duration in seconds), retries (1-10, number of times to retry before marking container unhealthy), and startPeriod (0-300, optional grace period to wait, in seconds, before failed healthchecks count toward retries) | object | `null` | no |
| links | List of container names this container can communicate with without port mappings | list(string) | `null` | no |
Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
| environment | The environment variables to pass to the container. This is a list of maps | object | `null` | no |
| environment_files | One or more files containing the environment variables to pass to the container. This maps to the --env-file option to docker run. The file must be hosted in Amazon S3. This option is only available to tasks using the EC2 launch type. This is a list of maps | object | `null` | no |
| essential | Determines whether all other containers in a task are stopped, if this container fails or stops for any reason. Due to how Terraform type casts booleans in json it is required to double quote this value | bool | `true` | no |
| extra_hosts | A list of hostnames and IP address mappings to append to the /etc/hosts file on the container. This is a list of maps | object | `null` | no |
| firelens_configuration | The FireLens configuration for the container. This is used to specify and configure a log router for container logs. For more details, see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_FirelensConfiguration.html | object | `null` | no |
| healthcheck | A map containing command (string), timeout, interval (duration in seconds), retries (1-10, number of times to retry before marking container unhealthy), and startPeriod (0-300, optional grace period to wait, in seconds, before failed healthchecks count toward retries) | object | `null` | no |
| links | List of container names this container can communicate with without port mappings | list(string) | `null` | no |
Expand Down
6 changes: 6 additions & 0 deletions examples/complete/fixtures.us-east-2.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ log_configuration = {
}

privileged = false

extra_hosts = [{
ipAddress = "127.0.0.1"
hostname = "app.local"
},
]
1 change: 1 addition & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ module "container" {
port_mappings = var.port_mappings
log_configuration = var.log_configuration
privileged = var.privileged
extra_hosts = var.extra_hosts
}
9 changes: 9 additions & 0 deletions examples/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,12 @@ variable "privileged" {
type = bool
description = "When this variable is `true`, the container is given elevated privileges on the host container instance (similar to the root user). This parameter is not supported for Windows containers or tasks using the Fargate launch type."
}

variable "extra_hosts" {
type = list(object({
ipAddress = string
hostname = string
}))
description = "A list of hostnames and IP address mappings to append to the /etc/hosts file on the container. This is a list of maps"
default = null
}
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ locals {
startTimeout = var.start_timeout
stopTimeout = var.stop_timeout
systemControls = var.system_controls
extraHosts = var.extra_hosts
}

json_map = jsonencode(local.container_definition)
Expand Down
9 changes: 9 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ variable "environment" {
default = null
}

variable "extra_hosts" {
type = list(object({
ipAddress = string
hostname = string
}))
description = "A list of hostnames and IP address mappings to append to the /etc/hosts file on the container. This is a list of maps"
default = null
}

# https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_EnvironmentFile.html
variable "environment_files" {
type = list(object({
Expand Down

0 comments on commit 0977c1d

Please sign in to comment.