Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,12 @@ Note: By default, network_mode is set to "awsvpc", command is set to null and km
```
module "ecs_task_definition" {
source = "git::https://github.com/TechHoldingLLC/terraform-aws-ecs-task-definition.git?ref=v1.0.3"

name = "demo-ecs-task-definition"
image = "demo-image"
task_cpu = 256
task_memory = 512
command = "npm run start"
port = 80
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
Refer this doc for more information on health check https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-healthcheck.html
health_check = {
command = ["CMD-SHELL", "curl -f http://localhost:${#PORT}${#HEALTH_CHECK_PATH} || exit 1"]
interval = 30
timeout = 5
retries = 2
startPeriod = 0
}
environment_variables = {
TEST = "1"
FOO = "BAR"
}
parameter_path_prefix = "/project/env"
secret_environment_variables = {
SECRET = "remaining_path/to/ssm/variable"
}
cloudwatch_log_retention_in_days = 30

container_definitions = [module.con_def_1.container_definition, module.con_def_2.container_definition]
}
```

13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ No modules.

| Name | Type |
|------|------|
| [aws_cloudwatch_log_group.ecs_task](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
| [aws_ecs_task_definition.task](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition) | resource |
| [aws_iam_role.ecs_task_execution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role.task](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
Expand All @@ -34,17 +33,10 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cloudwatch_log_retention_in_days"></a> [cloudwatch\_log\_retention\_in\_days](#input\_cloudwatch\_log\_retention\_in\_days) | Retention period for cloudwatch log group | `number` | n/a | yes |
| <a name="input_command"></a> [command](#input\_command) | Task command | `string` | `""` | no |
| <a name="input_environment_variables"></a> [environment\_variables](#input\_environment\_variables) | ECS secrets environment variables | `map(string)` | `{}` | no |
| <a name="input_health_check"></a> [health\_check](#input\_health\_check) | task definition health check | `any` | `null` | no |
| <a name="input_image"></a> [image](#input\_image) | ECR image | `string` | n/a | yes |
| <a name="input_container_definitions"></a> [container\_definitions](#input\_container\_definitions) | Additional container definitions (sidecars) to use for the task. | `any` | `[]` | no |
| <a name="input_name"></a> [name](#input\_name) | ECS task definition name | `string` | n/a | yes |
| <a name="input_network_mode"></a> [network\_mode](#input\_network\_mode) | Docker networking mode to use for the containers in the task. The valid values are none, bridge, awsvpc, and host. | `string` | `"awsvpc"` | no |
| <a name="input_parameter_path_prefix"></a> [parameter\_path\_prefix](#input\_parameter\_path\_prefix) | Path prefix for SSM parameter | `string` | `""` | no |
| <a name="input_port"></a> [port](#input\_port) | ECS container port | `number` | `0` | no |
| <a name="input_requires_compatibilities"></a> [requires\_compatibilities](#input\_requires\_compatibilities) | A set of launch types required by the task. The valid values are EC2 and FARGATE. | `list(string)` | <pre>[<br> "FARGATE"<br>]</pre> | no |
| <a name="input_secret_environment_variables"></a> [secret\_environment\_variables](#input\_secret\_environment\_variables) | ECS secrets environment variables | `map(string)` | `{}` | no |
| <a name="input_ssm_kms_alias"></a> [ssm\_kms\_alias](#input\_ssm\_kms\_alias) | SSM kms key alias | `string` | `"alias/aws/ssm"` | no |
| <a name="input_task_cpu"></a> [task\_cpu](#input\_task\_cpu) | ECS fargate task cpu | `number` | n/a | yes |
| <a name="input_task_memory"></a> [task\_memory](#input\_task\_memory) | ECS fargate task memory | `number` | n/a | yes |
Expand All @@ -55,15 +47,12 @@ No modules.
|------|-------------|
| <a name="output_arn"></a> [arn](#output\_arn) | n/a |
| <a name="output_arn_without_revision"></a> [arn\_without\_revision](#output\_arn\_without\_revision) | n/a |
| <a name="output_environment_variables"></a> [environment\_variables](#output\_environment\_variables) | n/a |
| <a name="output_execution_role_arn"></a> [execution\_role\_arn](#output\_execution\_role\_arn) | n/a |
| <a name="output_execution_role_name"></a> [execution\_role\_name](#output\_execution\_role\_name) | n/a |
| <a name="output_log_group_name"></a> [log\_group\_name](#output\_log\_group\_name) | n/a |
| <a name="output_name"></a> [name](#output\_name) | n/a |
| <a name="output_revision"></a> [revision](#output\_revision) | n/a |
| <a name="output_role_arn"></a> [role\_arn](#output\_role\_arn) | n/a |
| <a name="output_role_name"></a> [role\_name](#output\_role\_name) | n/a |
| <a name="output_secret_environment_variables"></a> [secret\_environment\_variables](#output\_secret\_environment\_variables) | n/a |

## License

Expand Down
48 changes: 48 additions & 0 deletions container_definition/EXAMPLE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ECS Container Definition
Below is an examples of calling this module.

Note: By default, cloudwatch logging and log group creation is enabled,command is set to null and kms alias is set to "alias/aws/ssm" in this module.

## Create ECS Container Definition
```
module "ecs_container_definition" {
source = "git::https://github.com/TechHoldingLLC/terraform-aws-ecs-task-definition.git//container_definition"

cpu = 256
memory = 512

name = "demo-ecs-container-definition"
image = "demo-image"

port_mappings = [
{
name = "demo-ecs-container-definition-api"
hostPort = 3000
protocol = "tcp"
containerPort = 3000
}
]
command = "npm start"
# Refer this doc for more information on health check https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-healthcheck.html
health_check = {
command = ["CMD-SHELL", "curl -f http://localhost:${#PORT}${#HEALTH_CHECK_PATH} || exit 1"]
interval = 30
timeout = 5
retries = 2
startPeriod = 0
}
environment_variables = {
TEST = "1"
FOO = "BAR"
}
parameter_path_prefix = "/project/env"
secret_environment_variables = {
SECRET = "remaining_path/to/ssm/variable"
}
cloudwatch_log_retention_in_days = 30

providers = {
aws = aws
}
}
```
Loading