Skip to content

Commit 0977c1d

Browse files
michelmzsGowiemactions-bot
authored
Add support for extraHosts option (#62)
Co-authored-by: Matt Gowie <[email protected]> Co-authored-by: actions-bot <[email protected]>
1 parent 59d8c32 commit 0977c1d

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ Available targets:
131131
| environment | The environment variables to pass to the container. This is a list of maps | object | `null` | no |
132132
| 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 |
133133
| 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 |
134+
| 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 |
134135
| 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 |
135136
| 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 |
136137
| links | List of container names this container can communicate with without port mappings | list(string) | `null` | no |

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
| environment | The environment variables to pass to the container. This is a list of maps | object | `null` | no |
1616
| 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 |
1717
| 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 |
18+
| 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 |
1819
| 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 |
1920
| 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 |
2021
| links | List of container names this container can communicate with without port mappings | list(string) | `null` | no |

examples/complete/fixtures.us-east-2.tfvars

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ log_configuration = {
5050
}
5151

5252
privileged = false
53+
54+
extra_hosts = [{
55+
ipAddress = "127.0.0.1"
56+
hostname = "app.local"
57+
},
58+
]

examples/complete/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ module "container" {
1515
port_mappings = var.port_mappings
1616
log_configuration = var.log_configuration
1717
privileged = var.privileged
18+
extra_hosts = var.extra_hosts
1819
}

examples/complete/variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,12 @@ variable "privileged" {
7373
type = bool
7474
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."
7575
}
76+
77+
variable "extra_hosts" {
78+
type = list(object({
79+
ipAddress = string
80+
hostname = string
81+
}))
82+
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"
83+
default = null
84+
}

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ locals {
6161
startTimeout = var.start_timeout
6262
stopTimeout = var.stop_timeout
6363
systemControls = var.system_controls
64+
extraHosts = var.extra_hosts
6465
}
6566

6667
json_map = jsonencode(local.container_definition)

variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ variable "environment" {
8484
default = null
8585
}
8686

87+
variable "extra_hosts" {
88+
type = list(object({
89+
ipAddress = string
90+
hostname = string
91+
}))
92+
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"
93+
default = null
94+
}
95+
8796
# https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_EnvironmentFile.html
8897
variable "environment_files" {
8998
type = list(object({

0 commit comments

Comments
 (0)