This module creates a set of AWS resources:
- AWS ECS Fargate Service
- AWS Security group for the Fargate Service
- A set of monitoring resources including Slack notifications
- A set of autoscaling resources
- If autoscaling isn't enabled, desires count will match min and max count
The autoscaling is triggered by a set of cloudwatch alarms that monitor CPU and memory. Monitoring period and thresholds for each alarm are configurable.
Autoscaling resources have been configured using Cloudposse ecs-cloudwatch-autoscaling
module
Name | Description | Type | Default | Required |
---|---|---|---|---|
alarm_data_missing_action | Missing data action for success responses alarm. Possible values: missing or breaching | string |
"missing" |
no |
assign_public_ip | Assign public IP to the Fargate service | bool |
false |
no |
cpu_utilization_high_period | Duration of the monitoring period | number |
300 |
no |
cpu_utilization_high_threshold | High CPU threshold | number |
60 |
no |
cpu_utilization_low_period | Duration of the monitoring period | number |
300 |
no |
cpu_utilization_low_threshold | Low CPU threshold | number |
20 |
no |
create_connection_error_alarm | Set to true if connection error alarm should be created | bool |
false |
no |
create_request_count_alarm | Set to true if request count alarm should be created | bool |
false |
no |
create_success_responses_alarm | Set to true if success responses alarm should be created | bool |
false |
no |
create_target_response_time_alarm | Set to true if target response time alarm should be created | bool |
false |
no |
create_unhealthy_host_count_alarm | Set to true if unhealthy host count alarm should be created | bool |
false |
no |
deployment_controller | Type of deployment controller. Valid values: CODE_DEPLOY, ECS, EXTERNAL. Default: ECS | string |
"ECS" |
no |
desired_count | desired number of container instances running | number |
n/a | yes |
ecs_cluster_arn | ECS Cluster ARN | string |
n/a | yes |
ecs_cluster_name | Name of the ECS cluster | string |
n/a | yes |
enable_autoscaling | Indicate if autoscaling should be enabled or not | bool |
false |
no |
enable_codedeploy_control | Setting this variable to true configures Fargate service terraform lifecycle to ignore changes done to the task definition and load balancer config. These will be controlled by code deploy. | bool |
false |
no |
enable_slack_notifications | Indicates if slack notifications should be enabled or not. If true, slack_webhook_url must be provided. | bool |
false |
no |
fargate_platform_version | The version of the Fargate platform | string |
"LATEST" |
no |
health_check_grace_period | Number of seconds that ECS service scheduler should ignore unhealthy ELB target/container/route 53 health checks after a task enters a RUNNING state | number |
0 |
no |
include_region | If set to true the current providers region will be appended to any global AWS resources such as IAM roles | bool |
false |
no |
ingress_sg_list | List of ingress security groups that will be applied to the created Fargate service | list(string) |
[] |
no |
max_count | Maximum number of tasks in the service, used only when autoscaling is enabled | number |
1 |
no |
max_percent | max percent of healthy container instances | number |
200 |
no |
memory_utilization_high_period | Duration of the monitoring period | number |
300 |
no |
memory_utilization_high_threshold | High memory threshold | number |
60 |
no |
memory_utilization_low_period | Duration of the monitoring period | number |
300 |
no |
memory_utilization_low_threshold | Low memory threshold | number |
20 |
no |
min_count | Minimum number of tasks in the service, used only when autoscaling is enabled | number |
1 |
no |
min_healthy_percent | min percent of healthy container instances | number |
100 |
no |
monit_resp_success_percentage | What percentage of requests should be responded to with 2xx | string |
"99" |
no |
monit_target_response_time | service response time in seconds greater than or equal to | string |
"0.5" |
no |
monitoring_config | n/a | list(object({ |
n/a | yes |
name | Name of the fargate instance | string |
"fargate" |
no |
namespace | n/a | string |
n/a | yes |
port | The port the service is available from | number |
5060 |
no |
region | AWS Region the Fargate service is deployed to | string |
n/a | yes |
sg_egress_cidr_blocks | List of egress CIDR blocks that will be applied to the created Fargate service | list(string) |
[ |
no |
sg_list | List of security groups that will be applied to the created Fargate service | list(string) |
[] |
no |
slack_webhook_url | Slack webhook URL for Cloudwatch alarm notifications | string |
"" |
no |
stage | Deployment stage i.e. environment name | string |
n/a | yes |
subnet_ids | A list of subnet ids the fargate service will be deployed to | list(string) |
n/a | yes |
tags | A set of tags that will be applied to all resources created by this module | map(string) |
n/a | yes |
target_group_arns | A list of target group ARNs | list(string) |
[] |
no |
task_definition | The family and revision (family:revision) or full ARN of the task definition that you want to run in your service | string |
n/a | yes |
vpc_id | VPC Id | string |
n/a | yes |
wait_for_steady_state | Terraform will wait for the service to reach a steady state (like aws ecs wait services-stable) before continuing | bool |
false |
no |
low_cpu_alarm_enabled | "Indicates if the low cpu alarm is enabled | bool |
true |
yes |
Name | Description |
---|---|
fargate_service_name | n/a |
security_group_id | n/a |
sns_alarm_topic_arn | n/a |
sns_slack_notification_topic_arn | n/a |
In order to validate any changes in this repo locally.
- Push your code up to a brach on BitBucket.
- Clone the sr-fargate-module repository.
- in the sr-fargate-module repository open the main.tf file
- Navigate to line 198 and change the source property for the module "fargate-service" to point to your branch by changing the value of the ref= part of the url to be like ref=BranchName.
- Pull the latest terraform code from the branch by running the command of terraform init.