|
| 1 | +<!-- |
| 2 | +
|
| 3 | +
|
| 4 | +
|
| 5 | +
|
| 6 | +
|
| 7 | +
|
| 8 | +
|
| 9 | +
|
| 10 | +
|
| 11 | +
|
| 12 | +
|
| 13 | +
|
| 14 | +
|
| 15 | +
|
| 16 | + ** DO NOT EDIT THIS FILE |
| 17 | + ** |
| 18 | + ** This file was automatically generated by the `build-harness`. |
| 19 | + ** 1) Make all changes to `README.yaml` |
| 20 | + ** 2) Run `make init` (you only need to do this once) |
| 21 | + ** 3) Run`make readme` to rebuild this file. |
| 22 | + ** |
| 23 | + ** (We maintain HUNDREDS of open source projects. This is how we maintain our sanity.) |
| 24 | + ** |
| 25 | +
|
| 26 | +
|
| 27 | +
|
| 28 | +
|
| 29 | +
|
| 30 | +
|
| 31 | +
|
| 32 | +
|
| 33 | +
|
| 34 | +
|
| 35 | +
|
| 36 | +
|
| 37 | +
|
| 38 | +
|
| 39 | +
|
| 40 | + --> |
| 41 | + |
| 42 | +# terraform-container-datadog |
| 43 | + |
| 44 | + |
| 45 | +Terraform module to generate well-formed JSON documents that are passed to the `aws_ecs_task_definition` Terraform resource as [container definitions](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definitions). |
| 46 | + |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +## Usage |
| 60 | + |
| 61 | + |
| 62 | +**IMPORTANT:** The `main` branch is used in `source` just as an example. In your code, do not pin to `main` because there may be breaking changes between releases. |
| 63 | +Instead pin to the release tag (e.g. `?ref=tags/x.y.z`) of one of our [latest releases](https://github.com/SemanticSugar/terraform-container-datadog/releases). |
| 64 | + |
| 65 | + |
| 66 | +This module is meant to be used as output only, meaning it will be used to create outputs which are consumed as a parameter by Terraform resources or other modules. |
| 67 | + |
| 68 | +For complete examples, see |
| 69 | +- [complete](examples/complete) |
| 70 | + |
| 71 | +For a complete example with automated tests, see [examples/complete](examples/complete) with `bats` and `Terratest` for the example [test](test). |
| 72 | + |
| 73 | +```hcl |
| 74 | +locals { |
| 75 | + # can also be set to terraform.workspace |
| 76 | + env = "staging" |
| 77 | +
|
| 78 | + container_port = 8080 |
| 79 | +} |
| 80 | +
|
| 81 | +module "datadog_container" { |
| 82 | + # this can and should be pinned to a release tag using ?ref=tags/x.y.z |
| 83 | + source = "[email protected]:SemanticSugar/terraform-container-datadog.git?ref=main" |
| 84 | +
|
| 85 | + dd_tags = "env:${local.env}" |
| 86 | +
|
| 87 | + # example dockerlabels |
| 88 | + # https://docs.datadoghq.com/integrations/faq/integration-setup-ecs-fargate/?tab=rediswebui |
| 89 | + docker_labels = { |
| 90 | + # container port has to be manually set |
| 91 | + "com.datadoghq.ad.instances" = jsonencode([ |
| 92 | + { |
| 93 | + host = "%%host%%" |
| 94 | + port = local.container_port |
| 95 | + } |
| 96 | + ]) |
| 97 | + # check_names is for integrations |
| 98 | + "com.datadoghq.ad.check_names" = jsonencode( |
| 99 | + [ |
| 100 | + "supervisord" |
| 101 | + ] |
| 102 | + ) |
| 103 | + # usually empty |
| 104 | + "com.datadoghq.ad.init_configs" = jsonencode( |
| 105 | + [{}] |
| 106 | + ) |
| 107 | + } |
| 108 | +} |
| 109 | +
|
| 110 | +module "task" { |
| 111 | + source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.31.0" |
| 112 | +
|
| 113 | + name = local.container_name |
| 114 | +
|
| 115 | + container_definition_json = jsonencode([ |
| 116 | + module.datadog_container.json_map, |
| 117 | + ]) |
| 118 | +
|
| 119 | + # ... |
| 120 | +} |
| 121 | +``` |
| 122 | + |
| 123 | +To build the `README.md`, use either |
| 124 | + |
| 125 | +`direnv` to load the environment variable and run |
| 126 | + |
| 127 | +```bash |
| 128 | +make init |
| 129 | +make readme |
| 130 | +``` |
| 131 | + |
| 132 | +or |
| 133 | + |
| 134 | +```bash |
| 135 | +make init |
| 136 | +README_TEMPLATE_FILE=docs/README.md.gotmpl make readme |
| 137 | +``` |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | +## Makefile Targets |
| 145 | +``` |
| 146 | +Available targets: |
| 147 | +
|
| 148 | + help Help screen |
| 149 | + help/all Display help for all targets |
| 150 | + help/short This help short screen |
| 151 | +
|
| 152 | +``` |
| 153 | +## Requirements |
| 154 | + |
| 155 | +| Name | Version | |
| 156 | +|------|---------| |
| 157 | +| terraform | ~> 0.12.0 | |
| 158 | +| local | ~> 1.2 | |
| 159 | + |
| 160 | +## Providers |
| 161 | + |
| 162 | +| Name | Version | |
| 163 | +|------|---------| |
| 164 | +| aws | n/a | |
| 165 | +| aws.us-east-1 | n/a | |
| 166 | + |
| 167 | +## Inputs |
| 168 | + |
| 169 | +| Name | Description | Type | Default | Required | |
| 170 | +|------|-------------|------|---------|:--------:| |
| 171 | +| api\_key | Use a different API key than the default one in dev-infra/dd\_api\_key/sre\_scripts/secret.b64 | `string` | `""` | no | |
| 172 | +| apm\_enabled | Set to true to add `DD_APM_ENABLED` environment variable | `bool` | `true` | no | |
| 173 | +| apm\_non\_local\_traffic | Set to true to add `DD_APM_NON_LOCAL_TRAFFIC` environment variable | `bool` | `true` | no | |
| 174 | +| command | The command that is passed to the container | `list(string)` | `null` | no | |
| 175 | +| container\_cpu | The number of cpu units to reserve for the container. This is optional for tasks using Fargate launch type and the total amount of container\_cpu of all containers in a task will need to be lower than the task-level cpu value | `number` | `192` | no | |
| 176 | +| container\_definition | Container definition overrides which allows for extra keys or overriding existing keys. | `map` | `{}` | no | |
| 177 | +| container\_depends\_on | The dependencies defined for container startup and shutdown. A container can contain multiple dependencies. When a dependency is defined for container startup, for container shutdown it is reversed. The condition can be one of START, COMPLETE, SUCCESS or HEALTHY | <pre>list(object({<br> containerName = string<br> condition = string<br> }))</pre> | `null` | no | |
| 178 | +| container\_image | The image used to start the container. Images in the Docker Hub registry available by default | `string` | `"datadog/agent:latest"` | no | |
| 179 | +| container\_memory | The amount of memory (in MiB) to allow the container to use. This is a hard limit, if the container attempts to exceed the container\_memory, the container is killed. This field is optional for Fargate launch type and the total amount of container\_memory of all containers in a task will need to be lower than the task memory value | `number` | `192` | no | |
| 180 | +| container\_memory\_reservation | The amount of memory (in MiB) to reserve for the container. If container needs to exceed this threshold, it can do so up to the set container\_memory hard limit | `number` | `null` | no | |
| 181 | +| container\_name | The name of the container. Up to 255 characters ([a-z], [A-Z], [0-9], -, \_ allowed) | `string` | `"datadog-agent"` | no | |
| 182 | +| dd\_tags | The datadog tags for the metrics and service map expressed as a colon and comma separated string. Ex: `labelname1:value1,labelname2:value2` | `string` | `""` | no | |
| 183 | +| dns\_search\_domains | Container DNS search domains. A list of DNS search domains that are presented to the container | `list(string)` | `null` | no | |
| 184 | +| dns\_servers | Container DNS servers. This is a list of strings specifying the IP addresses of the DNS servers | `list(string)` | `null` | no | |
| 185 | +| docker\_labels | The configuration options to send to the `docker_labels` | `map(string)` | `null` | no | |
| 186 | +| docker\_labels\_check\_names | The integrations for the `com.datadoghq.ad.check_names`. Useful if `var.docker_labels` is undefined. | `list` | `[]` | no | |
| 187 | +| docker\_labels\_container\_port | The container port for the `com.datadoghq.ad.instances`. Useful if `var.docker_labels` is undefined. | `number` | `8080` | no | |
| 188 | +| docker\_labels\_init\_configs | The integrations for the `com.datadoghq.ad.init_configs`. Useful if `var.docker_labels` is undefined. | `list` | <pre>[<br> {}<br>]</pre> | no | |
| 189 | +| ecs\_fargate | Set to true to add `ECS_FARGATE` environment variable | `bool` | `true` | no | |
| 190 | +| entrypoint | The entry point that is passed to the container | `list(string)` | `null` | no | |
| 191 | +| 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 | <pre>list(object({<br> value = string<br> type = string<br> }))</pre> | `null` | no | |
| 192 | +| 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 | |
| 193 | +| 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 | <pre>list(object({<br> ipAddress = string<br> hostname = string<br> }))</pre> | `null` | no | |
| 194 | +| 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 | <pre>object({<br> type = string<br> options = map(string)<br> })</pre> | `null` | no | |
| 195 | +| 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) | <pre>object({<br> command = list(string)<br> retries = number<br> timeout = number<br> interval = number<br> startPeriod = number<br> })</pre> | <pre>{<br> "command": [<br> "CMD-SHELL",<br> "agent health"<br> ],<br> "interval": 30,<br> "retries": 3,<br> "startPeriod": 0,<br> "timeout": 5<br>}</pre> | no | |
| 196 | +| links | List of container names this container can communicate with without port mappings | `list(string)` | `null` | no | |
| 197 | +| linux\_parameters | Linux-specific modifications that are applied to the container, such as Linux kernel capabilities. For more details, see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_LinuxParameters.html | <pre>object({<br> capabilities = object({<br> add = list(string)<br> drop = list(string)<br> })<br> devices = list(object({<br> containerPath = string<br> hostPath = string<br> permissions = list(string)<br> }))<br> initProcessEnabled = bool<br> maxSwap = number<br> sharedMemorySize = number<br> swappiness = number<br> tmpfs = list(object({<br> containerPath = string<br> mountOptions = list(string)<br> size = number<br> }))<br> })</pre> | `null` | no | |
| 198 | +| log\_configuration | Log configuration options to send to a custom log driver for the container. For more details, see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_LogConfiguration.html | `any` | `null` | no | |
| 199 | +| logging\_group\_name | If logging to cloudwatch, this will be the cloudwatch log group name | `string` | `""` | no | |
| 200 | +| map\_environment | The environment variables to pass to the container. This is a map of string: {key: value}, environment override map\_environment | `map(string)` | `{}` | no | |
| 201 | +| mount\_points | Container mount points. This is a list of maps, where each map should contain a `containerPath` and `sourceVolume`. The `readOnly` key is optional. | `list` | `[]` | no | |
| 202 | +| port\_mappings | The port mappings to configure for the container. This is a list of maps. Each map should contain "containerPort", "hostPort", and "protocol", where "protocol" is one of "tcp" or "udp". If using containers in a task with the awsvpc or host network mode, the hostPort can either be left blank or set to the same value as the containerPort | <pre>list(object({<br> containerPort = number<br> hostPort = number<br> protocol = string<br> }))</pre> | <pre>[<br> {<br> "containerPort": 8126,<br> "hostPort": 8126,<br> "protocol": "tcp"<br> },<br> {<br> "containerPort": 8125,<br> "hostPort": 8125,<br> "protocol": "udp"<br> }<br>]</pre> | no | |
| 203 | +| privileged | 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. | `bool` | `null` | no | |
| 204 | +| process\_agent\_enabled | Set to true to add `DD_PROCESS_AGENT_ENABLED` environment variable | `bool` | `true` | no | |
| 205 | +| readonly\_root\_filesystem | Determines whether a container is given read-only access to its root filesystem. Due to how Terraform type casts booleans in json it is required to double quote this value | `bool` | `false` | no | |
| 206 | +| repository\_credentials | Container repository credentials; required when using a private repo. This map currently supports a single key; "credentialsParameter", which should be the ARN of a Secrets Manager's secret holding the credentials | `map(string)` | `null` | no | |
| 207 | +| secrets | The secrets to pass to the container. This is a list of maps | <pre>list(object({<br> name = string<br> valueFrom = string<br> }))</pre> | `null` | no | |
| 208 | +| start\_timeout | Time duration (in seconds) to wait before giving up on resolving dependencies for a container | `number` | `null` | no | |
| 209 | +| stop\_timeout | Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own | `number` | `null` | no | |
| 210 | +| system\_controls | A list of namespaced kernel parameters to set in the container, mapping to the --sysctl option to docker run. This is a list of maps: { namespace = "", value = ""} | `list(map(string))` | `null` | no | |
| 211 | +| ulimits | Container ulimit settings. This is a list of maps, where each map should contain "name", "hardLimit" and "softLimit" | <pre>list(object({<br> name = string<br> hardLimit = number<br> softLimit = number<br> }))</pre> | `null` | no | |
| 212 | +| user | The user to run as inside the container. Can be any of these formats: user, user:group, uid, uid:gid, user:gid, uid:group. The default (null) will use the container's configured `USER` directive or root if not set. | `string` | `null` | no | |
| 213 | +| volumes\_from | A list of VolumesFrom maps which contain "sourceContainer" (name of the container that has the volumes to mount) and "readOnly" (whether the container can write to the volume) | <pre>list(object({<br> sourceContainer = string<br> readOnly = bool<br> }))</pre> | `[]` | no | |
| 214 | +| working\_directory | The working directory to run commands inside the container | `string` | `null` | no | |
| 215 | + |
| 216 | +## Outputs |
| 217 | + |
| 218 | +| Name | Description | |
| 219 | +|------|-------------| |
| 220 | +| json | String type of container definition | |
| 221 | +| json\_map | Map type of container definition | |
| 222 | + |
| 223 | + |
| 224 | + |
| 225 | + |
| 226 | +## Related Projects |
| 227 | + |
| 228 | +Check out these related projects. |
| 229 | + |
| 230 | +- [terraform-aws-ecs-container-definition](https://github.com/cloudposse/terraform-aws-ecs-container-definition) - Terraform module to generate well-formed JSON documents (container definitions) that are passed to the aws_ecs_task_definition Terraform resource |
| 231 | + |
| 232 | + |
| 233 | + |
| 234 | + |
| 235 | + |
| 236 | + |
| 237 | + |
| 238 | + |
| 239 | + |
| 240 | + |
| 241 | + |
| 242 | + |
| 243 | + |
0 commit comments