Skip to content

FitnessKeeper/terraform-aws-ecs-service

Repository files navigation

tf_aws_ecs_service

Terraform module for deploying and managing a generic ECS service onto an existing cluster.


Usage


module "pganalyze_testdb" {
  source             = "github.com/terraform-community-modules/tf_aws_ecs_service?ref=v1.0.0"
  region             = "${data.aws_region.current.name}"
  ecs_cluster        = "my-ecs-cluster"
  service_identifier = "pganalyze"
  task_identifier    = "testdb"
  docker_image       = "quay.io/pganalyze:stable"

  docker_environment = [
    {
      "name"  = "DB_URL",
      "value" = "postgres://user:password@host:port/database",
    },
  ]
}

Authors

Changelog

Please See the GitHub Releases Page

License

This software is released under the MIT License (see LICENSE).

Inputs

Name Description Type Default Required
acm_cert_domain Domain name of ACM-managed certificate string "" no
alb_cookie_duration Duration of ALB session stickiness cookie in seconds (default 86400) string "86400" no
alb_deregistration_delay The amount of time in seconds to wait before deregistering a target from a target group (default) string "300" no
alb_enable_http Enable HTTP listener in ALB (default false) string "false" no
alb_enable_https Enable HTTPS listener in ALB (default true) string "true" no
alb_healthcheck_healthy_threshold Number of consecutive successful health checks before marking service as healthy (default 5) string "5" no
alb_healthcheck_interval Time in seconds between ALB health checks (default 30) string "30" no
alb_healthcheck_matcher HTTP response codes to accept as healthy (default 200) string "200" no
alb_healthcheck_path URI path for ALB health checks (default /) string "/" no
alb_healthcheck_port Port for ALB to use when connecting health checks (default same as application traffic) string "traffic-port" no
alb_healthcheck_protocol Protocol for ALB to use when connecting health checks (default HTTP) string "HTTP" no
alb_healthcheck_timeout Timeout in seconds for ALB to use when connecting health checks (default 5) string "5" no
alb_healthcheck_unhealthy_threshold Number of consecutive failed health checks before marking service as unhealthy (default 2) string "5" no
alb_internal Configure ALB as internal-only (default false) string "false" no
alb_stickiness_enabled Enable ALB session stickiness (default false) string "false" no
alb_subnet_ids VPC subnet IDs in which to create the ALB (unnecessary if neither alb_enable_https or alb_enable_http are true) list <list> no
app_port Numeric port on which application listens (unnecessary if neither alb_enable_https or alb_enable_http are true) string "" no
docker_command String to override CMD in Docker container (default "") string "" no
docker_environment List of environment maps of format { "name" = "var_name", "value" = "var_value" } list <list> no
docker_image Docker image to use for task string n/a yes
docker_memory Hard limit on memory use for task container (default 256) string "256" no
docker_memory_reservation Soft limit on memory use for task container (default 128) string "128" no
docker_mount_points List of mount point maps of format { "sourceVolume" = "vol_name", "containerPath" = "path", ["readOnly" = "true or false" ] } list <list> no
docker_port_mappings List of port mapping maps of format { "containerPort" = integer, [ "hostPort" = integer, "protocol" = "tcp or udp" ] } list <list> no
ecs_cluster_arn ARN of ECS cluster in which the service will be deployed string n/a yes
ecs_data_volume_path Path to volume on ECS node to be defined as a "data" volume (default "/opt/data") string "/opt/data" no
ecs_deployment_maximum_percent Upper limit in percentage of tasks that can be running during a deployment (default 200) string "200" no
ecs_deployment_minimum_healthy_percent Lower limit in percentage of tasks that must remain healthy during a deployment (default 100) string "100" no
ecs_desired_count Desired number of containers in the task (default 1) string "1" no
ecs_health_check_grace_period Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 1800. (default 0) string "0" no
ecs_log_retention Number of days of ECS task logs to retain (default 3) string "3" no
ecs_placement_strategy_field Container metadata field to use when distributing tasks (default instanceId) string "instanceId" no
ecs_placement_strategy_type Placement strategy to use when distributing tasks (default spread) string "spread" no
ecs_security_group_id Security group ID of ECS cluster in which the service will be deployed string n/a yes
extra_task_policy_arns List of ARNs of IAM policies to be attached to the ECS task role (in addition to the default policy, so cannot be more than 9 ARNs) list <list> no
lb_bucket_name Full name for S3 bucket. string n/a yes
lb_log_enabled Enables/Disables logging to designated S3 bucket. S3 bucket name (lb_bucket_name) is still required. (default is true) string "true" no
lb_log_prefix Prefix for S3 bucket. (default is log/elb). string "logs/elb" no
log_group_name Name for CloudWatch Log Group that will receive collector logs (must be unique, default is created from service_identifier and task_identifier) string "" no
network_mode Docker network mode for task (default "bridge") string "bridge" no
region AWS region in which ECS cluster is located (default is 'us-east-1') string "us-east-1" no
service_identifier Unique identifier for this pganalyze service (used in log prefix, service name etc.) string "service" no
task_identifier Unique identifier for this pganalyze task (used in log prefix, service name etc.) string "task" no
vpc_id ID of VPC in which ECS cluster is located string n/a yes

Outputs

Name Description
alb_arn ARN of ALB provisioned for service (if present)
alb_dns_name FQDN of ALB provisioned for service (if present)
alb_zone_id Route 53 zone ID of ALB provisioned for service (if present)
log_group_arn ARN of the CloudWatch Log Group
log_group_name Name of the CloudWatch Log Group
service_iam_role_arn ARN of the IAM Role for the ECS Service
service_iam_role_name Name of the IAM Role for the ECS Task
task_iam_role_arn ARN of the IAM Role for the ECS Task
task_iam_role_name Name of the IAM Role for the ECS Task