Terraform-aws-ecs-app-worker is an AWS ECS Application Module for Workers without Application Load Balancer(ALB).
This module is designed to be used with DNXLabs/terraform-aws-ecs
(https://github.com/DNXLabs/terraform-aws-ecs).
The following resources will be created:
- Cloudwatch Metrics alarm - Provides a CloudWatch Metric Alarm resource.
- High memory
- High cpu
- IAM roles - The cloudwatch event needs an IAM Role to run the ECS task definition. A role is created and a policy will be granted via IAM policy.
- ECS task definition - A task definition is required to run Docker containers in Amazon ECS. Some of the parameters you can specify in a task definition include:
- Image - Docker image to deploy.
- Default value is "dnxsolutions/nginx-hello:latest"
- CPU - Hard limit of the CPU for the container
- Default Value = 0
- Memory - Hard memory of the container
- Default Value = 512
- Name - Name of the ECS Service
- Set log configuration
- Image - Docker image to deploy.
- ECS Task-scheduler activated by cloudwatch events
In addition you have the option to create or not :
- Simple Notification Service (SNS) topics - Alarm topics to create and alert on ECS service metrics. Leaving empty disables all alarms.
- Cloudwatch Log Groups
- You can specify the number of days you want to retain log events in the specified log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653.
- Export to a S3 Bucket - Whether to mark the log group to export to an S3 bucket (needs the module terraform-aws-log-exporter (https://github.com/DNXLabs/terraform-aws-log-exporter) to be deployed in the account/region)
Name | Version |
---|---|
terraform | >= 0.13.0 |
Name | Version |
---|---|
aws | n/a |
Name | Description | Type | Default | Required |
---|---|---|---|---|
alarm_prefix | String prefix for cloudwatch alarms. (Optional, leave blank to use iam_account_alias) | string |
"" |
no |
alarm_sns_topics | Alarm topics to create and alert on ECS service metrics | list |
[] |
no |
autoscaling_cpu | Enables autoscaling based on average CPU tracking | bool |
false |
no |
autoscaling_custom | Set one or more app autoscaling by customized metric | list(object({ |
[] |
no |
autoscaling_max | Max number of containers to scale with autoscaling | number |
4 |
no |
autoscaling_memory | Enables autoscaling based on average Memory tracking | bool |
false |
no |
autoscaling_min | Min number of containers to scale with autoscaling | number |
1 |
no |
autoscaling_scale_in_cooldown | Cooldown in seconds to wait between scale in events | number |
300 |
no |
autoscaling_scale_out_cooldown | Cooldown in seconds to wait between scale out events | number |
300 |
no |
autoscaling_target_cpu | Target average CPU percentage to track for autoscaling | number |
50 |
no |
autoscaling_target_memory | Target average Memory percentage to track for autoscaling | number |
90 |
no |
cloudwatch_logs_export | Whether to mark the log group to export to an S3 bucket (needs terraform-aws-log-exporter to be deployed in the account/region) | bool |
false |
no |
cloudwatch_logs_retention | Specifies the number of days you want to retain log events in the specified log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653. | number |
120 |
no |
cluster_name | n/a | string |
"Name of existing ECS Cluster to deploy this app to" |
no |
cpu | Hard limit for CPU for the container | string |
"0" |
no |
deployment_maximum_percent | Deployment maximum percentage | string |
"100" |
no |
deployment_minimum_healthy_percent | Deployment minumum health percentage | string |
"0" |
no |
desired_count | Number of containers (tasks) to run | number |
1 |
no |
enable_schedule | Enables schedule to shut down and start up instances outside business hours. | bool |
false |
no |
fargate_spot | Set true to use FARGATE_SPOT capacity provider by default (only when launch_type=FARGATE) | bool |
false |
no |
image | Docker image to deploy (can be a placeholder) | string |
"dnxsolutions/nginx-hello:latest" |
no |
launch_type | The launch type on which to run your service. The valid values are EC2 and FARGATE. Defaults to EC2. | string |
"EC2" |
no |
log_subscription_filter_destination_arn | Destination for log subscription filter (required when log_subscription_filter_enabled=true) | string |
"" |
no |
log_subscription_filter_enabled | Enable cloudwatch log subscription filter | bool |
false |
no |
log_subscription_filter_filter_pattern | Filter pattern for log subscription filter | string |
"" |
no |
log_subscription_filter_role_arn | Role to use for log subscription filter (required when log_subscription_filter_enabled=true) | string |
"" |
no |
memory | Hard memory of the container | string |
"512" |
no |
name | Name of your ECS service | any |
n/a | yes |
network_mode | The Docker networking mode to use for the containers in the task. The valid values are none, bridge, awsvpc, and host. (REQUIRED IF 'LAUCH_TYPE' IS FARGATE) | any |
null |
no |
ordered_placement_strategy | Service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. The maximum number of ordered_placement_strategy blocks is 5. | list(object({ |
[] |
no |
placement_constraints | Rules that are taken into consideration during task placement. Maximum number of placement_constraints is 10. | list(object({ |
[] |
no |
schedule_cron_start | Cron expression to define when to trigger a start of the auto-scaling group. E.g. 'cron(00 21 ? * SUN-THU *)' to start at 8am UTC time. | string |
"" |
no |
schedule_cron_stop | Cron expression to define when to trigger a stop of the auto-scaling group. E.g. 'cron(00 09 ? * MON-FRI *)' to start at 8am UTC time | string |
"" |
no |
security_groups | The security groups associated with the task or service | any |
null |
no |
subnets | The subnets associated with the task or service. (REQUIRED IF 'LAUCH_TYPE' IS FARGATE) | any |
null |
no |
task_role_policies | Custom policies to be added on the task role | list |
[] |
no |
task_role_policies_managed | AWS Managed policies to be added on the task role. | list |
[] |
no |
vpc_id | VPC ID to deploy this app to | any |
n/a | yes |
without_capacity_provider | Launch service without capacity provider | bool |
false |
no |
tags | A map of tags to add to service | map(string) |
{} |
no |
Name | Description |
---|---|
aws_cloudwatch_log_group_arn | n/a |
aws_cloudwatch_log_group_name | n/a |
Module managed by DNX Solutions.
Apache 2 Licensed. See LICENSE for full details.