Skip to content

This terraform module is an AWS ECS Application Module for Workers without Application Load Balancer (ALB).

License

Notifications You must be signed in to change notification settings

divipayhq/terraform-aws-ecs-app-worker

 
 

Repository files navigation

terraform-aws-ecs-app-worker

Lint Status LICENSE

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
  • 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)

Requirements

Name Version
terraform >= 0.12.0

Providers

Name Version
aws n/a

Inputs

Name Description Type Default Required
alarm_sns_topics Alarm topics to create and alert on ECS service metrics list [] 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
desired_count Number of containers (tasks) to run number 1 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({
field = string
expression = string
}))
[] no
placement_constraints Rules that are taken into consideration during task placement. Maximum number of placement_constraints is 10.
list(object({
type = string
expression = string
}))
[] no
security_groups The security groups associated with the task or service any null no
service_role_arn Existing service role ARN created by ECS cluster module any n/a yes
subnets The subnets associated with the task or service. (REQUIRED IF 'LAUCH_TYPE' IS FARGATE) any null no
task_role_arn Existing task role ARN created by ECS cluster module any n/a yes
vpc_id VPC ID to deploy this app to any n/a yes

Outputs

Name Description
aws_cloudwatch_log_group_arn n/a
aws_cloudwatch_log_group_name n/a

Authors

Module managed by DNX Solutions.

License

Apache 2 Licensed. See LICENSE for full details.

About

This terraform module is an AWS ECS Application Module for Workers without Application Load Balancer (ALB).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 100.0%