Skip to content

DNXLabs/terraform-aws-ecs-weighted-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

terraform-aws-ecs-weighted-app

Lint Status LICENSE

Requirements

Name Version
terraform >= 0.13
aws >= 4.0.0

Providers

Name Version
aws 5.95.0
random 3.7.2

Modules

No modules.

Resources

Name Type
aws_appautoscaling_policy.scale_cpu resource
aws_appautoscaling_policy.scale_memory resource
aws_appautoscaling_target.ecs resource
aws_cloudwatch_event_rule.ecs_events resource
aws_cloudwatch_event_target.ecs_events resource
aws_cloudwatch_log_group.default resource
aws_cloudwatch_log_group.ecs_events resource
aws_cloudwatch_log_resource_policy.ecs_events resource
aws_cloudwatch_log_subscription_filter.log_subscription_filter resource
aws_cloudwatch_metric_alarm.ecs_running_tasks resource
aws_cloudwatch_metric_alarm.high_cpu_usage resource
aws_cloudwatch_metric_alarm.min_healthy_tasks resource
aws_codedeploy_app.ecs resource
aws_codedeploy_deployment_group.ecs resource
aws_ecs_service.default resource
aws_ecs_task_definition.default resource
aws_iam_role.codedeploy_service resource
aws_iam_role_policy_attachment.codedeploy_service resource
aws_lb_listener_rule.default resource
aws_lb_listener_rule.green_auth_oidc resource
aws_lb_listener_rule.path_redirects resource
aws_lb_listener_rule.redirects resource
aws_lb_target_group.default resource
aws_route53_record.hostnames resource
aws_route53_record.hostnames_internal resource
random_string.alb_prefix resource
aws_ecs_cluster.ecs_cluster data source
aws_iam_account_alias.current data source
aws_iam_policy_document.ecs_events data source
aws_lb.alb_selected data source
aws_lb_listener.ecs data source
aws_region.current data source
aws_route53_zone.selected data source

Inputs

Name Description Type Default Required
alarm_ecs_running_tasks_threshold Alarm when the number of ecs service running tasks is lower than a certain value. CloudWatch Container Insights must be enabled for the cluster. number 0 no
alarm_evaluation_periods The number of minutes the alarm must be below the threshold before entering the alarm state. string "2" no
alarm_high_cpu_usage_above Alarm when CPU is above a certain value (use 0 to disable this alarm) number 80 no
alarm_min_healthy_tasks Alarm when the number of healthy tasks is less than this number (use 0 to disable this alarm) number 2 no
alarm_prefix String prefix for cloudwatch alarms. (Optional) string "alarm" no
alarm_sns_topics Alarm topics to create and alert on ECS service metrics. Leaving empty disables all alarms. list(string) [] no
alb_dns_name ALB DNS Name string "" no
alb_listener_https_arn ALB HTTPS Listener created by ECS cluster module string n/a yes
alb_name ALB name - Required if it is an internal one string "" no
alb_only Whether to deploy only an alb and no cloudFront or not with the cluster bool false no
alb_priority priority rules ALB (leave 0 to let terraform calculate) number 0 no
auth_oidc_authorization_endpoint Authorization endpoint for OIDC (Google: https://accounts.google.com/o/oauth2/v2/auth) string "" no
auth_oidc_client_id Client ID for OIDC authentication string "" no
auth_oidc_client_secret Client Secret for OIDC authentication string "" no
auth_oidc_enabled Enables OIDC-authenticated listener rule bool false no
auth_oidc_hostnames List of hostnames to use as a condition to authenticate with OIDC list(string) [] no
auth_oidc_issuer Issuer URL for OIDC authentication (Google: https://accounts.google.com) string "" no
auth_oidc_paths List of paths to use as a condition to authenticate (example: ['/admin*']) list(string) [] no
auth_oidc_session_timeout Session timeout for OIDC authentication (default 12 hours) number 43200 no
auth_oidc_token_endpoint Token Endpoint URL for OIDC authentication (Google: https://oauth2.googleapis.com/token) string "" no
auth_oidc_user_info_endpoint User Info Endpoint URL for OIDC authentication (Google: https://openidconnect.googleapis.com/v1/userinfo) string "" no
autoscaling_custom Set one or more app autoscaling by customized metric
list(object({
name = string
scale_in_cooldown = number
scale_out_cooldown = number
target_value = number
metric_name = string
namespace = string
statistic = string
}))
[] no
autoscaling_max_prod Max number of containers to scale with autoscaling string "1" no
autoscaling_min_prod Min number of containers to scale with autoscaling string "1" no
cluster_name Name of existing ECS Cluster to deploy this app to string n/a yes
codedeploy_deployment_config_name Specifies the deployment configuration for CodeDeploy string "CodeDeployDefault.ECSAllAtOnce" no
codedeploy_role_arn Existing IAM CodeDeploy role ARN created by ECS cluster module string null no
codedeploy_wait_time_for_cutover Time in minutes to route the traffic to the new application deployment number 0 no
codedeploy_wait_time_for_termination Time in minutes to terminate the new deployment number 0 no
compat_keep_target_group_naming Keeps old naming convention for target groups to avoid recreation of resource in production environments bool false no
create_iam_codedeployrole Create Codedeploy IAM Role for ECS or not. bool true no
deployment_controller Type of deployment controller. Valid values: CODE_DEPLOY, ECS, EXTERNAL. string "CODE_DEPLOY" no
dynamic_stickiness Target Group stickiness. Used in dynamic block. any [] no
ecs_service_capacity_provider_strategy (Optional) The capacity provider strategy to use for the service. Can be one or more. These can be updated without destroying and recreating the service only if set to [] and not changing from 0 capacity_provider_strategy blocks to greater than 0, or vice versa. list(map(string))
[
{}
]
no
efs_mapping A map of efs volume ids and paths to mount into the default task definition map(string) {} no
enable_schedule Enables schedule to shut down and start up instances outside business hours. bool false no
enable_schedule_prod_1 enable / disable schedule on prod string false no
enable_schedule_prod_2 enable / disable schedule on prod string false no
fargate_spot Set true to use FARGATE_SPOT capacity provider by default (only when launch_type=FARGATE) bool false no
hosted_zone Hosted Zone to create DNS record for this app string "" no
hosted_zone_id Hosted Zone ID to create DNS record for this app (use this to avoid data lookup when using hosted_zone) string "" no
hosted_zone_is_internal Set true in case the hosted zone is in an internal VPC, otherwise false string "false" no
hostname_create Optional parameter to create or not a Route53 record bool false no
hostname_redirects List of hostnames to redirect to the main one, comma-separated string "" no
hostnames List of hostnames to create listerner rule and optionally, DNS records for this app list(string) [] no
http_header Header to use on listerner rule with name e values list(any) [] no
launch_type The launch type on which to run your service. The valid values are EC2 and FARGATE. Defaults to EC2. string "FARGATE" no
log_subscription_filter_destination_arn n/a string "" no
log_subscription_filter_enabled n/a string false no
log_subscription_filter_filter_pattern n/a string "" no
log_subscription_filter_role_arn n/a string "" no
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) string 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
type = string
}))
[] no
paths List of paths to use on listener rule (example: ['/*']) list(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
redirects Map of path redirects to add to the listener map(any) {} 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_start_prod_1 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
schedule_cron_start_prod_2 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
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
schedule_cron_stop_prod_1 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
schedule_cron_stop_prod_2 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 list(string) null no
service_deployment_maximum_percent Maximum percentage of tasks to run during deployments number 200 no
service_deployment_minimum_healthy_percent Minimum healthy percentage during deployments number 100 no
service_desired_count Desired count for this service (for use when auto scaling is disabled) number 1 no
service_health_check_grace_period_seconds Time until your container starts serving requests number 0 no
service_role_arn Existing service role ARN created by ECS cluster module string n/a yes
services n/a
list(object({
name = string
port = optional(number, 80)
container_port = optional(number, 8080)
protocol = optional(string, "HTTP")
healthcheck_path = optional(string, "/")
healthcheck_interval = optional(string, "10")
healthy_threshold = optional(number, 3)
unhealthy_threshold = optional(number, 3)
healthcheck_timeout = optional(number, 5)
healthcheck_matcher = optional(string, "200")
target_group_weight = optional(number, 100)
desired_count = optional(number, 2)
deployment_controller = optional(string, "ECS")
cloudwatch_logs_retention = optional(number, 120)
cloudwatch_logs_export = optional(bool, false)
image = optional(string, "")
log_subscription_filter_enabled = optional(string, false)
autoscaling_cpu = optional(bool, false)
autoscaling_memory = optional(bool, false)
autoscaling_max = optional(number, 4)
autoscaling_min = optional(number, 1)
autoscaling_target_cpu = optional(number, 50)
autoscaling_target_memory = optional(number, 90)
autoscaling_scale_in_cooldown = optional(number, 300)
autoscaling_scale_out_cooldown = optional(number, 300)
memory = optional(number, 1024)
cpu = optional(number, 512)
# paths = optional(list(string), [])
# hostnames = optional(list(string), [])
# source_ips = optional(list(string), [])
}))
n/a yes
source_ips List of source ip to use on listerner rule list(string) [] no
ssm_variables Map of variables and SSM locations to add to the task definition map(string) {} no
static_variables Map of variables and static values to add to the task definition map(string) {} no
subnets The subnets associated with the task or service. (REQUIRED IF var.launch_type IS FARGATE) list(string) null no
task_definition_arn Task definition to use for this service (optional) string "" no
task_role_arn Existing task role ARN created by ECS cluster module string n/a yes
ulimits Container ulimit settings. This is a list of maps, where each map should contain "name", "hardLimit" and "softLimit"
list(object({
name = string
hardLimit = number
softLimit = number
}))
null no
vpc_id VPC ID to deploy this app to string n/a yes

Outputs

No outputs.

About

Terraform module to deploy multiple ECS services, each with different weights on the LB

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages