Amazon ECS Service
Deploy an Amazon ECS Service
View on GitHubReference
- Inputs
- Outputs
- alarm_sns_topic_arns— A list of ARNs of the SNS topic(s) to write alarm events to
- alarm_sns_topic_arns_us_east_1— A list of SNS topic ARNs to notify when the route53 health check changes to ALARM, OK, or- INSUFFICIENT_DATAstate. Note: these SNS topics MUST be in us-east-1! This is because Route 53 only sends CloudWatch metrics to us-east-1, so we must create the alarm in that region, and therefore, can only notify SNS topics in that region
- alb_sticky_session_cookie_duration— The time period, in seconds, during which requests from a client should be routed to the same Target. After this time period expires, the load balancer-generated cookie is considered stale. The acceptable range is 1 second to 1 week (604800 seconds). The default value is 1 day (86400 seconds). Only used if- elb_target_groupsis set.
- alb_sticky_session_type— The type of Sticky Sessions to use. See https://goo.gl/MNwqNu for possible values. Only used if- elb_target_groupsis set.
- canary_container_definitions— List of container definitions to use for the canary ECS task. Each entry corresponds to a different ECS container definition.
- canary_version— Which version of the ECS Service Docker container to deploy as a canary (e.g. 0.57)
- capacity_provider_strategy— The capacity provider strategy to use for the service. Note that the capacity providers have to be present on the ECS cluster before deploying the ECS service. When provided,- launch_typeis ignored.
- clb_container_name— The name of the container, as it appears in the- task_arnTask definition, to associate with a CLB. Currently, ECS can only associate a CLB with a single container per service. Only used if- clb_nameis set.
- clb_container_port— The port on the container in- clb_container_nameto associate with an CLB. Currently, ECS can only associate a CLB with a single container per service. Only used if- clb_nameis set.
- clb_name— The name of a Classic Load Balancer (CLB) to associate with this service. Containers in the service will automatically register with the CLB when booting up. Set to null if using ELBv2.
- cloudwatch_log_group_name— The name for the Cloudwatch logs that will be generated by the ecs service
- container_definitions— List of container definitions to use for the ECS task. Each entry corresponds to a different ECS container definition.
- cpu— The number of CPU units to allocate to the ECS Service.
- create_route53_entry— Set to true if you want a DNS record automatically created and pointed at the the load balancer for the ECS service
- custom_docker_command— If- use_custom_docker_run_commandis set to true, set this variable to the custom docker run command you want to provide
- custom_ecs_service_role_name— The name to use for the ECS Service IAM role, which is used to grant permissions to the ECS service to register the task IPs to ELBs.
- custom_iam_policy_prefix— Prefix for name of the custom IAM policies created by this module (those resulting from- iam_policyand- secrets_access). If omitted, defaults to- service_name.
- custom_iam_role_name_prefix— Prefix for name of the IAM role used by the ECS task.
- custom_task_execution_iam_role_name_prefix— Prefix for name of task execution IAM role and policy that grants access to CloudWatch and ECR.
- default_listener_arns— A map of all the listeners on the load balancer. The keys should be the port numbers and the values should be the ARN of the listener for that port.
- default_listener_ports— The default port numbers on the load balancer to attach listener rules to. You can override this default on a rule-by-rule basis by setting the- listener_portsparameter in each rule. The port numbers specified in this variable and the- listener_portsparameter must exist in- listener_arns.
- dependencies— Create a dependency between the resources in this module to the interpolated values in this list (and thus the source resources). In other words, the resources in this module will now depend on the resources backing the values in this list such that those resources need to be created before the resources in this module, and the resources in this module need to be destroyed before the resources in the list.
- deployment_check_loglevel— Set the logging level of the deployment check script. You can set this to- error,- warn, or- info, in increasing verbosity.
- deployment_check_timeout_seconds— Seconds to wait before timing out each check for verifying ECS service deployment. See- ecs_deploy_check_binariesfor more details.
- deployment_circuit_breaker_enabled— Set to 'true' to prevent the task from attempting to continuously redeploy after a failed health check.
- deployment_circuit_breaker_rollback— Set to 'true' to also automatically roll back to the last successful deployment.- deploy_circuit_breaker_enabledmust also be true to enable this behavior.
- deployment_maximum_percent— The upper limit, as a percentage of- desired_number_of_tasks, of the number of running tasks that can be running in a service during a deployment. Setting this to more than 100 means that during deployment, ECS will deploy new instances of a Task before undeploying the old ones.
- deployment_minimum_healthy_percent— The lower limit, as a percentage of- desired_number_of_tasks, of the number of running tasks that must remain running and healthy in a service during a deployment. Setting this to less than 100 means that during deployment, ECS may undeploy old instances of a Task before deploying new ones.
- desired_number_of_canary_tasks— How many instances of the ECS Service to run across the ECS cluster for a canary deployment. Typically, only 0 or 1 should be used.
- desired_number_of_tasks— How many instances of the ECS Service to run across the ECS cluster
- domain_name— The domain name to create a route 53 record for. This DNS record will point to the load balancer for the ECS service
- ecs_cluster_arn— The ARN of the cluster to which the ecs service should be deployed.
- ecs_cluster_name— The name of the ecs cluster to deploy the ecs service onto.
- ecs_instance_security_group_id— The ID of the security group that should be applied to ecs service instances
- ecs_node_port_mappings— A map of ports to be opened via security groups applied to the EC2 instances that back the ECS cluster, when not using fargate. The key should be the container port and the value should be what host port to map it to.
- efs_volumes— (Optional) A map of EFS volumes that containers in your task may use. Each item in the list should be a map compatible with- https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html#efs-volume-configuration-arguments.
- elb_slow_start— The amount time for targets to warm up before the load balancer sends them a full share of requests. The range is 30-900 seconds or 0 to disable. The default value is 0 seconds. Only used if- elb_target_groupsis set.
- elb_target_group_deregistration_delay— The amount of time for Elastic Load Balancing to wait before changing the state of a deregistering target from draining to unused. The range is 0-3600 seconds. Only used if- elb_target_groupsis set.
- elb_target_group_vpc_id— The ID of the VPC in which to create the target group. Only used if- elb_target_groupsis set.
- elb_target_groups— Configurations for ELB target groups for ALBs and NLBs that should be associated with the ECS Tasks. Each entry corresponds to a separate target group. Set to the empty object ({}) if you are not using an ALB or NLB.
- enable_cloudwatch_alarms— Set to true to enable Cloudwatch alarms on the ecs service instances
- enable_ecs_deployment_check— Whether or not to enable the ECS deployment check binary to make terraform wait for the task to be deployed. See- ecs_deploy_check_binariesfor more details. You must install the companion binary before the check can be used. Refer to the README for more details.
- enable_execute_command— Specifies whether to enable Amazon ECS Exec for the tasks within the service.
- enable_route53_health_check— Set this to true to create a route 53 health check and Cloudwatch alarm that will alert if your domain becomes unreachable
- expose_ecs_service_to_other_ecs_nodes— Set this to true to allow the ecs service to be accessed by other ecs nodes
- health_check_enabled— If true, enable health checks on the target group. Only applies to ELBv2. For CLBs, health checks are not configurable.
- health_check_grace_period_seconds— Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 2,147,483,647. Only valid for services configured to use load balancers.
- health_check_healthy_threshold— The number of consecutive successful health checks required before considering an unhealthy Target healthy. The acceptable range is 2 to 10.
- health_check_interval— The approximate amount of time, in seconds, between health checks of an individual Target. Minimum value 5 seconds, Maximum value 300 seconds.
- health_check_matcher— The HTTP codes to use when checking for a successful response from a Target. You can specify multiple values (e.g. '200,202') or a range of values (e.g. '200-299'). Required when using ALBs.
- health_check_path— The ping path that is the destination on the Targets for health checks. Required when using ALBs.
- health_check_port— The port the ELB uses when performing health checks on Targets. The default is to use the port on which each target receives traffic from the load balancer, indicated by the value 'traffic-port'.
- health_check_timeout— The amount of time, in seconds, during which no response from a Target means a failed health check. The acceptable range is 2 to 60 seconds.
- health_check_unhealthy_threshold— The number of consecutive failed health checks required before considering a target unhealthy. The acceptable range is 2 to 10. For NLBs, this value must be the same as the- health_check_healthy_threshold.
- high_cpu_utilization_period— The period, in seconds, over which to measure the CPU utilization percentage
- high_cpu_utilization_threshold— Trigger an alarm if the ECS Service has a CPU utilization percentage above this threshold
- high_memory_utilization_period— The period, in seconds, over which to measure the memory utilization percentage
- high_memory_utilization_threshold— Trigger an alarm if the ECS Service has a memory utilization percentage above this threshold
- hosted_zone_id— The ID of the Route 53 hosted zone into which the Route 53 DNS record should be written
- iam_policy— An object defining the policy to attach to the ECS task. Accepts a map of objects, where the map keys are sids for IAM policy statements, and the object fields are the resources, actions, and the effect ("Allow" or "Deny") of the statement.
- launch_type— The launch type of the ECS service. Must be one of EC2 or FARGATE. When using FARGATE, you must set the network mode to awsvpc and configure it. When using EC2, you can configure the placement strategy using the variables- placement_strategy_type,- placement_strategy_field,- placement_constraint_type,- placement_constraint_expression. This variable is ignored if- capacity_provider_strategyis provided.
- lb_hosted_zone_id— The ID of the Route 53 Hosted Zone in which to create a DNS A record pointed to the ECS service's load balancer
- max_number_of_tasks— The maximum number of instances of the ECS Service to run. Auto scaling will never scale out above this number.
- memory— How much memory, in MB, to give the ECS Service.
- min_number_of_tasks— The minimum number of instances of the ECS Service to run. Auto scaling will never scale in below this number.
- network_configuration— The configuration to use when setting up the VPC network mode. Required and only used if- network_modeis awsvpc.
- network_mode— The Docker networking mode to use for the containers in the task. The valid values are none, bridge, awsvpc, and host. If the- network_modeis set to awsvpc, you must configure- network_configuration.
- original_lb_dns_name— The DNS name that was assigned by AWS to the load balancer upon creation
- placement_constraint_expression— Cluster Query Language expression to apply to the constraint for matching. Does not need to be specified for the distinctInstance constraint type.
- placement_constraint_type— The type of constraint to apply for container instance placement. The only valid values at this time are memberOf and distinctInstance.
- placement_strategy_field— The field to apply the placement strategy against. For the spread placement strategy, valid values are instanceId (or host, which has the same effect), or any platform or custom attribute that is applied to a container instance, such as attribute:ecs.availability-zone. For the binpack placement strategy, valid values are cpu and memory. For the random placement strategy, this field is not used.
- placement_strategy_type— The strategy to use when placing ECS tasks on EC2 instances. Can be binpack (default), random, or spread.
- propagate_tags— Whether tags should be propogated to the tasks from the service or from the task definition. Valid values are SERVICE and- TASK_DEFINITION. Defaults to SERVICE. If set to null, no tags are created for tasks.
- proxy_configuration_container_name— Use the name of the Envoy proxy container from `- container_definitions` as the container name.
- proxy_configuration_properties— A map of network configuration parameters to provide the Container Network Interface (CNI) plugin.
- route53_health_check_path— The path, without any leading slash, that can be used as a health check (e.g. healthcheck) by Route 53. Should return a 200 OK when the service is up and running.
- route53_health_check_port— The port to use for Route 53 health checks. This should be the port for the service that is available at the publicly accessible domain name- (var.domain_name.
- route53_health_check_protocol— The protocol to use for Route 53 health checks. Should be one of HTTP, HTTPS.
- secrets_access— A list of ARNs of Secrets Manager secrets that the task should have permissions to read. The IAM role for the task will be granted- secretsmanager:GetSecretValuefor each secret in the list. The ARN can be either the complete ARN, including the randomly generated suffix, or the ARN without the suffix. If the latter, the module will look up the full ARN automatically. This is helpful in cases where you don't yet know the randomly generated suffix because the rest of the ARN is a predictable value.
- secrets_manager_arns— A list of ARNs for Secrets Manager secrets that the ECS execution IAM policy should be granted access to read. Note that this is different from the ECS task IAM policy. The execution policy is concerned with permissions required to run the ECS task.
- secrets_manager_kms_key_arn— The ARN of the kms key associated with secrets manager
- service_name— The name of the ECS service (e.g. my-service-stage)
- service_tags— A map of tags to apply to the ECS service. Each item in this list should be a map with the parameters key and value.
- task_cpu— The CPU units for the instances that Fargate will spin up. Options here:- https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html#fargate-tasks-size. Required when using FARGATE launch type.
- task_definition_tags— A map of tags to apply to the task definition. Each item in this list should be a map with the parameters key and value.
- task_memory— The memory units for the instances that Fargate will spin up. Options here:- https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html#fargate-tasks-size. Required when using FARGATE launch type.
- use_alb_sticky_sessions— If true, the ALB will use use Sticky Sessions as described at https://goo.gl/VLcNbk. Only used if- elb_target_groupsis set. Note that this can only be true when associating with an ALB. This cannot be used with CLBs or NLBs.
- use_auto_scaling— Whether or not to enable auto scaling for the ecs service
- use_custom_docker_run_command— Set this to true if you want to pass a custom docker run command. If you set this to true, you must supply- custom_docker_command
- volumes— (Optional) A map of volume blocks that containers in your task may use. The key should be the name of the volume and the value should be a map compatible with- https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html#volume-block-arguments, but not including the name parameter.
- all_metric_widgets— A list of all the CloudWatch Dashboard metric widgets available in this module.
- aws_ecs_task_definition_arn— The ARN of the ECS task definition
- aws_ecs_task_definition_canary_arn— The ARN of the canary ECS task definition
- canary_service_arn— The ARN of the canary service. Canary services are optional and can be helpful when you're attempting to verify a release candidate
- capacity_provider_strategy— The capacity provider strategy determines how infrastructure (such as EC2 instances or Fargate) that backs your ECS service is managed. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-capacity-providers.html for more information
- ecs_node_port_mappings— A map representing the instance host and container ports that should be opened
- ecs_task_execution_iam_role_arn— The ARN of the ECS task's IAM role
- ecs_task_execution_iam_role_name— The name of the ECS task execution IAM role. The execution role is used by the ECS container agent to make calls to the ECS API, pull container images from ECR, use the logs driver, etc
- ecs_task_iam_role_arn— The ARN of the IAM role associated with the ECS task
- ecs_task_iam_role_name— The name of the IAM role granting permissions to the running ECS task itself. Note this role is separate from the execution role which is assumed by the ECS container agent
- metric_widget_ecs_service_cpu_usage— The metric widget for the ECS service's CPU usage
- metric_widget_ecs_service_memory_usage— The metric widget for the ECS service's memory usage
- route53_domain_name— The domain name of the optional route53 record, which points at the load balancer for the ECS service
- service_app_autoscaling_target_arn— The ARN of the app autoscaling target
- service_app_autoscaling_target_resource_id— The resource ID of the autoscaling target
- service_arn— The ARN of the ECS service
- service_iam_role_arn— The ARN of the service role associated with the ELB of the ECS service
- service_iam_role_name— The name of the service role associated with the ELB of the ECS service
- target_group_arns— The ARNs of the ECS service's load balancer's target groups
- target_group_names— The names of the ECS service's load balancer's target groups