Skip to content

Commit

Permalink
Add ability to add custom tags to cluster and service (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-ylz authored Feb 23, 2024
1 parent f111628 commit 4c45791
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 8 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ No resources.
| <a name="input_asg_volume_size"></a> [asg\_volume\_size](#input\_asg\_volume\_size) | Specify the volume size for the root ebs | `string` | `30` | no |
| <a name="input_asg_wait_for_capacity_timeout"></a> [asg\_wait\_for\_capacity\_timeout](#input\_asg\_wait\_for\_capacity\_timeout) | A maximum duration that Terraform should wait for ASG instances to be healthy before timing out. (See also Waiting for Capacity below.) Setting this to '0' causes Terraform to skip all Capacity Waiting behavior. | `string` | `null` | no |
| <a name="input_assign_public_ip"></a> [assign\_public\_ip](#input\_assign\_public\_ip) | Enable a public IP address for the container | `bool` | `false` | no |
| <a name="input_capacity_providers"></a> [capacity\_providers](#input\_capacity\_providers) | List of short names of one or more capacity providers to associate with the cluster. Valid values also include FARGATE and FARGATE\_SPOT. | `list(string)` | `[]` | no |
| <a name="input_cluster_tags"></a> [cluster\_tags](#input\_cluster\_tags) | tags to be added to ECS cluster | `map(any)` | `{}` | no |
| <a name="input_create_launch_template"></a> [create\_launch\_template](#input\_create\_launch\_template) | Create a launch template | `bool` | `true` | no |
| <a name="input_default_capacity_provider_strategy"></a> [default\_capacity\_provider\_strategy](#input\_default\_capacity\_provider\_strategy) | The capacity provider strategy to use by default for the cluster. Can be one or more. | `list(map(any))` | `[]` | no |
| <a name="input_enable_execute_command"></a> [enable\_execute\_command](#input\_enable\_execute\_command) | Specifies whether to enable Amazon ECS Exec for the tasks within the service | `bool` | `false` | no |
| <a name="input_launch_type"></a> [launch\_type](#input\_launch\_type) | The launch type on which to run your task.(EC2\|FARGATE) | `string` | `"EC2"` | no |
| <a name="input_link_ecs_to_asg_capacity_provider"></a> [link\_ecs\_to\_asg\_capacity\_provider](#input\_link\_ecs\_to\_asg\_capacity\_provider) | Specify whether to link ECS to autoscaling group capacity provider | `bool` | `false` | no |
Expand All @@ -65,11 +68,10 @@ No resources.
| <a name="input_service_scale_out_cooldown"></a> [service\_scale\_out\_cooldown](#input\_service\_scale\_out\_cooldown) | Time between scale out action | `number` | `300` | no |
| <a name="input_service_security_groups"></a> [service\_security\_groups](#input\_service\_security\_groups) | Security group IDs to attach to your ECS Service | `list(string)` | `[]` | no |
| <a name="input_service_subnets"></a> [service\_subnets](#input\_service\_subnets) | Private subnets for ECS | `list(string)` | `[]` | no |
| <a name="input_service_tags"></a> [service\_tags](#input\_service\_tags) | tags to be added to task definitions | `map(any)` | `{}` | no |
| <a name="input_service_target_cpu_value"></a> [service\_target\_cpu\_value](#input\_service\_target\_cpu\_value) | Autoscale when CPU Usage value over the specified value. Must be specified if `enable_cpu_based_autoscaling` is `true`. | `number` | `70` | no |
| <a name="input_service_task_execution_role_arn"></a> [service\_task\_execution\_role\_arn](#input\_service\_task\_execution\_role\_arn) | Default IAM role for ECS execution | `string` | `""` | no |
| <a name="input_service_task_role_arn"></a> [service\_task\_role\_arn](#input\_service\_task\_role\_arn) | Default IAM role for ECS task | `string` | `""` | no |
| <a name="capacity_providers"></a> [capacity\_provider](#default\_capacity\_provider\_strategy) | Capacity providers for ECS Cluster | `list(string)` | `[]` | no |
| <a name="default_capacity_provider_strategy"></a> [default\_capacity\_provider\_strategy](#default\_capacity\_provider\_strategy) | Default capacity provider strategy for ECS Cluster | `list(map(any))` | `[]` | no |
| <a name="input_task_placement_constraints"></a> [task\_placement\_constraints](#input\_task\_placement\_constraints) | The rules that are taken into consideration during task placement. Maximum number of placement\_constraints is 10 | <pre>list(object({<br> type = string<br> expression = string<br> }))</pre> | `[]` | no |

## Outputs
Expand Down
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module "cluster" {

default_capacity_provider_strategy = var.default_capacity_provider_strategy
capacity_providers = var.capacity_providers
tags = var.cluster_tags
}

module "service" {
Expand Down Expand Up @@ -77,7 +78,7 @@ module "service" {
task_placement_constraints = var.task_placement_constraints

capacity_provider_strategy = var.default_capacity_provider_strategy

tags = var.service_tags
}

module "service_cpu_autoscaling_policy" {
Expand Down
2 changes: 1 addition & 1 deletion modules/autoscaling-policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.31.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.38.0 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.31.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.38.0 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/iam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.31.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.38.0 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/service-discovery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.31.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.38.0 |

## Modules

Expand Down
3 changes: 2 additions & 1 deletion modules/service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.31.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.38.0 |

## Modules

Expand All @@ -29,6 +29,7 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_assign_public_ip"></a> [assign\_public\_ip](#input\_assign\_public\_ip) | Flag for enabling/disabling public IP for ECS Containers | `bool` | `false` | no |
| <a name="input_capacity_provider_strategy"></a> [capacity\_provider\_strategy](#input\_capacity\_provider\_strategy) | The capacity provider strategy to use by ecs service. Can be one or more. | `list(map(any))` | `[]` | no |
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | Cluster ID | `string` | n/a | yes |
| <a name="input_container_definitions"></a> [container\_definitions](#input\_container\_definitions) | A list of container definitions in JSON format that describe the different containers that make up your task | `string` | n/a | yes |
| <a name="input_deployment_circuit_breaker"></a> [deployment\_circuit\_breaker](#input\_deployment\_circuit\_breaker) | Configuration block for deployment circuit breaker | `any` | `{}` | no |
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ variable "link_ecs_to_asg_capacity_provider" {
default = false
}

variable "cluster_tags" {
type = map(any)
default = {}
description = "tags to be added to ECS cluster"
}

##############################
# ECS - service
##############################
Expand Down Expand Up @@ -83,6 +89,12 @@ variable "enable_execute_command" {
default = false
}

variable "service_tags" {
type = map(any)
default = {}
description = "tags to be added to task definitions"
}

################################################################################
# Autoscaling group
################################################################################
Expand Down

0 comments on commit 4c45791

Please sign in to comment.