Terraform module to create AWS ECS service task .
terrafrom config example:
module "ecs_task_security_group" {
source = "git::https://github.com/mbelousov7/aws-security-group.git?ref=v1.0.0"
vpc_id = var.vpc_id
ingress_rules = var.security_group.ingress_rules
egress_rules = var.security_group.egress_rules
labels = local.labels
}
module "ecs_task_definition" {
source = "git::https://github.com/mbelousov7/aws-ecs-task-definition.git?ref=v1.0.0"
aws_region = var.region
container_name = var.container_name
container_image = var.container_image
task_cpu = var.task_cpu
task_memory = var.task_memory
task_role_policy_arns = local.cloudteam_policy_arns
task_role_policy_statements = var.task_role_policy_statements
labels = local.labels
}
module "ecs_task_service" {
source = "../.."
task_definition_arn = module.ecs_task_definition.task_definition_arn
task_subnet_ids = var.subnet_ids
task_security_group_ids = [module.ecs_task_security_group.id]
labels = local.labels
}
more info see examples/test
terraform run example
cd examples/test
terraform init
terraform plan
No requirements.
Name | Version |
---|---|
aws | n/a |
No modules.
Name | Type |
---|---|
aws_cloudwatch_event_rule.task_stopped_rule | resource |
aws_cloudwatch_log_metric_filter.errors | resource |
aws_cloudwatch_metric_alarm.cpu_utilization | resource |
aws_cloudwatch_metric_alarm.default | resource |
aws_cloudwatch_metric_alarm.memory_utilization | resource |
aws_cloudwatch_metric_alarm.task_count | resource |
aws_ecs_cluster.ecs_cluster | resource |
aws_ecs_service.ecs_service | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
alarm_config | add custom string into alarm descritptioon | string |
"" |
no |
alarm_enable | n/a | bool |
true |
no |
alarm_log_configs | The cloudwatch metrics filters definitions | map |
{ |
no |
alarm_topic_arn | n/a | string |
"" |
no |
assign_public_ip | Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false . Default false |
bool |
false |
no |
aws_ecs_cluster_containerInsights | option to enabled | disabled CloudWatch Container Insights for a cluster | string |
"enabled" |
no |
cpu_utilization_threshold | The maximum percentage of CPU utilization. | number |
80 |
no |
deployment_maximum_percent | n/a | number |
200 |
no |
deployment_minimum_healthy_percent | n/a | number |
100 |
no |
ecs_cluster_arn | provide value if ecs_cluster_new == false | string |
"" |
no |
ecs_cluster_name | optionally define a custom value for the ecs cluster name and tag=Name parameter in aws_ecs_cluster. By default, it is defined as a construction from var.labels |
string |
"" |
no |
ecs_cluster_new | optionally set to false, then no new ecs cluster will be created | bool |
true |
no |
ecs_load_balancers | A list of load balancer config objects for the ECS service; see ecs_service#load_balancer docs | any |
[] |
no |
ecs_service_name | optionally define a custom value for the aws_ecs_service. By default, it is defined as a construction from var.labels |
string |
"" |
no |
labels | Minimum required map of labels(tags) for creating aws resources | object({ |
n/a | yes |
launch_type | The launch type on which to run your service. Valid values are EC2 and FARGATE |
string |
"FARGATE" |
no |
memory_utilization_threshold | The maximum percentage of Memory utilization. | number |
80 |
no |
region | n/a | string |
"us-east-1" |
no |
service_registries | Zero or one service discovery registries for the service. The currently supported service registry is Amazon Route 53 Auto Naming Service - aws_service_discovery_service ;see service_registries docs https://www.terraform.io/docs/providers/aws/r/ecs_service.html#service_registries-1"Service registry is object with required key registry_arn = string and optional keysport = number container_name = string container_port = number |
list(any) |
[] |
no |
tags | Additional tags | map(string) |
{} |
no |
task_count_threshold | The minimum task count threshold | number |
1 |
no |
task_definition_arn | Task definition arn | string |
n/a | yes |
task_desired_count | Number of instances of the task definition to place and keep running. | number |
1 |
no |
task_security_group_ids | Security group IDs to allow in Service network_configuration |
list(string) |
[] |
no |
task_stopped_rule | option to create aws_cloudwatch_event_rule which Trigger when the Fargate task has stopped | bool |
false |
no |
task_subnet_ids | Subnet IDs used in Service network_configuration |
list(string) |
null |
no |
wait_for_steady_state | Terraform will wait for the service to reach a steady state (like aws ecs wait services-stable) before continuing | bool |
true |
no |
Name | Description |
---|---|
aws_ecs_cluster_arn | ecs cluster arn |
aws_ecs_cluster_name | ecs cluster name |
task_stopped_event_rule_name | service task stopped event rule name |