Skip to content

elasticscale/terraform-aws-fargate-vertiscale

Repository files navigation

Description

This module automatically vertically scales AWS Fargate tasks when they run out memory due to an OOM Exception. It uses two Lambda functions to monitor for RunTask commands and for ECS stopped tasks. When it encounteres an OOM error it will restart the tasks automatically with double the memory.

Your tasks have to be idempotent for this to work!

For more debugging steps check out the elasticscale blog.

About ElasticScale

ElasticScale is a Solutions Architecture as a Service focusing on start-ups and scale-ups. For a fixed monthly subscription fee, we handle all your AWS workloads. Some services include:

  • Migrating existing workloads to AWS
  • Implementing the Zero Trust security model
  • Integrating DevOps principles within your organization
  • Moving to infrastructure automation (Terraform)
  • Complying with ISO27001 regulations within AWS

You can pause the subscription at any time and have direct access to certified AWS professionals.

Check out our website for more information.

ElasticScale logo

Requirements

Name Version
aws 5.6.2

Providers

Name Version
archive 2.4.0
aws 5.6.2
random 3.5.1

Modules

Name Source Version
dynamodb_tasks terraform-aws-modules/dynamodb-table/aws n/a
s3_bucket cloudposse/cloudtrail-s3-bucket/aws 0.26.2

Resources

Name Type
aws_cloudtrail.cf_task_trail resource
aws_cloudwatch_event_rule.ct_event_rule resource
aws_cloudwatch_event_rule.ecs_event_rule resource
aws_cloudwatch_event_target.ct_event_target resource
aws_cloudwatch_event_target.ecs_event_target resource
aws_iam_role.lambda_ct resource
aws_iam_role.lambda_ecs resource
aws_lambda_function.lambda_ct resource
aws_lambda_function.lambda_ecs resource
aws_lambda_permission.lambda_ct_resource_policy resource
aws_lambda_permission.lambda_ecs_resource_policy resource
random_string.random resource
archive_file.lambda_ct data source
archive_file.lambda_ecs data source
aws_iam_policy_document.lambda_ct data source
aws_iam_policy_document.lambda_ecs data source

Inputs

Name Description Type Default Required
iam_pass_roles The possible IAM roles for your task definitions, this is used in the IAM policy to allow the lambda to pass the role, using [*] is a bad practice here list(string) n/a yes
max_memory The maximum amount of memory to allow a task to use in MB number 122880 no
prefix Value to prefix all resources with (lowercase) string "fargatevertiscale" no
region AWS region to deploy to string n/a yes
setup_cloud_trail Setup CloudTrail to capture ECS events, if you already have a trail setup to an S3 bucket you can set this to false. Without CloudTrail the module will not work bool true no
tag_name The tag name attached to RunTask command that triggers this module to run string "fargatevertiscale" no
task_expires Purge tasks from DynamoDB after this many seconds (default 7 days) number 604800 no

Outputs

No outputs.