Home

Awesome

<!-- markdownlint-disable -->

<a href="https://cpco.io/homepage"><img src="https://github.com/cloudposse-terraform-components/aws-ecs-service/blob/main/.github/banner.png?raw=true" alt="Project Banner"/></a><br/> <p align="right"> <a href="https://github.com/cloudposse-terraform-components/aws-ecs-service/releases/latest"><img src="https://img.shields.io/github/release/cloudposse-terraform-components/aws-ecs-service.svg?style=for-the-badge" alt="Latest Release"/></a><a href="https://slack.cloudposse.com"><img src="https://slack.cloudposse.com/for-the-badge.svg" alt="Slack Community"/></a></p>

<!-- markdownlint-restore --> <!-- ** DO NOT EDIT THIS FILE ** ** This file was automatically generated by the `cloudposse/build-harness`. ** 1) Make all changes to `README.yaml` ** 2) Run `make init` (you only need to do this once) ** 3) Run`make readme` to rebuild this file. ** ** (We maintain HUNDREDS of open source projects. This is how we maintain our sanity.) ** -->

This component is responsible for creating an ECS service.

Usage

Stack Level: Regional

Here's an example snippet for how to use this component.

# stacks/catalog/ecs-service/defaults.yaml
components:
  terraform:
    ecs-service/defaults:
      metadata:
        component: ecs-service
        type: abstract
      settings:
        spacelift:
          workspace_enabled: true
      vars:
        enabled: true
        public_lb_enabled: false
        ecr_stage_name: mgmt-automation
        task:
          launch_type: FARGATE
          network_mode: awsvpc
          desired_count: 1
          ignore_changes_desired_count: true
          ignore_changes_task_definition: false
          assign_public_ip: false
          propagate_tags: SERVICE
          wait_for_steady_state: true
          circuit_breaker_deployment_enabled: true
          circuit_breaker_rollback_enabled: true

This will launch a kong service using an ecr image from mgmt-automation account.

NOTE: Usage of ecr_image instead of image.

import:
  - catalog/ecs-service/defaults

components:
  terraform:
    ecs/b2b/kong/service:
      metadata:
        component: ecs-service
        inherits:
          - ecs-service/defaults
      vars:
        name: kong
        public_lb_enabled: true
        cluster_attributes: [b2b]
        containers:
          service:
            name: "kong-gateway"
            ecr_image: kong:latest
            map_environment:
              KONG_DECLARATIVE_CONFIG: /home/kong/production.yml
            port_mappings:
              - containerPort: 8000
                hostPort: 8000
                protocol: tcp
        task:
          desired_count: 1
          task_memory: 512
          task_cpu: 256

This will launch a httpd service using an external image from dockerhub

NOTE: Usage of image instead of ecr_image.

# stacks/catalog/ecs-service/httpd.yaml
import:
  - catalog/ecs-service/defaults

components:
  terraform:
    ecs/platform/httpd/service:
      metadata:
        component: ecs-service
        inherits:
          - ecs-service/defaults
      vars:
        enabled: true
        name: httpd
        public_lb_enabled: true
        cluster_attributes: [platform]
        containers:
          service:
            name: "Hello"
            image: httpd:2.4
            port_mappings:
              - containerPort: 80
                hostPort: 80
                protocol: tcp
            command:
              - '/bin/sh -c "echo ''<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px;
                background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS
                Sample App</h1> <h2>Congratulations!</h2> <p>Your application is now running on a container in Amazon
                ECS.</p> </div></body></html>'' >  /usr/local/apache2/htdocs/index.html && httpd-foreground"'
            entrypoint: ["sh", "-c"]
        task:
          desired_count: 1
          task_memory: 512
          task_cpu: 256

This will launch google's echoserver using an external image from gcr

NOTE: Usage of image instead of ecr_image.

# stacks/catalog/ecs-service/echoserver.yaml
import:
  - catalog/ecs-service/defaults

components:
  terraform:
    ecs/platform/echoserver/service:
      metadata:
        component: ecs-service
        inherits:
          - ecs-service/defaults
      vars:
        enabled: true
        name: echoserver
        public_lb_enabled: true
        cluster_attributes: [platform]
        containers:
          service:
            name: "echoserver"
            image: gcr.io/google_containers/echoserver:1.10
            port_mappings:
              - containerPort: 8080
                hostPort: 8080
                protocol: tcp
        task:
          desired_count: 1
          task_memory: 512
          task_cpu: 256

Other Domains

This component supports alternate service names for your ECS Service through a couple of variables:

Examples:

ecs/platform/service/echo-server:
  vars:
    vanity_domain: "dev-acme.com"
    vanity_alias:
      - "echo-server.dev-acme.com"
    additional_targets:
      - "echo.acme.com"

This then creates the following listener rules:

HTTP Host Header is
echo-server.public-platform.use2.dev.plat.service-discovery.com
 OR echo-server.dev-acme.com
 OR echo.acme.com

It will also create the record in Route53 to point "echo-server.dev-acme.com" to the ALB. Thus "echo-server.dev-acme.com" should resolve.

We can then create a pointer to this service in the acme.come hosted zone.

dns-primary:
  vars:
    domain_names:
      - acme.com
    record_config:
      - root_zone: acme.com
        name: echo.
        type: CNAME
        ttl: 60
        records:
          - echo-server.dev-acme.com

This will create a CNAME record in the acme.com hosted zone that points echo.acme.com to echo-server.dev-acme.com.

EFS

EFS is supported by this ecs service, you can use either efs_volumes or efs_component_volumes in your task definition.

This example shows how to use efs_component_volumes which remote looks up efs component and uses the efs_id to mount the volume. And how to use efs_volumes

components:
  terraform:
    ecs-services/my-service:
      metadata:
        component: ecs-service
        inherits:
          - ecs-services/defaults
      vars:
        containers:
          service:
            name: app
            image: my-image:latest
            log_configuration:
              logDriver: awslogs
              options: {}
            port_mappings:
              - containerPort: 8080
                hostPort: 8080
                protocol: tcp
            mount_points:
              - containerPath: "/var/lib/"
                sourceVolume: "my-volume-mount"

        task:
          efs_component_volumes:
            - name: "my-volume-mount"
              host_path: null
              efs_volume_configuration:
                - component: efs/my-volume-mount
                  root_directory: "/var/lib/"
                  transit_encryption: "ENABLED"
                  transit_encryption_port: 2999
                  authorization_config: []
          efs_volumes:
            - name: "my-volume-mount-2"
              host_path: null
              efs_volume_ configuration:
                - file_system_id: "fs-1234"
                  root_directory: "/var/lib/"
                  transit_encryption: "ENABLED"
                  transit_encryption_port: 2998
                  authorization_config: []
<!-- prettier-ignore-start --> <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

Requirements

NameVersion
<a name="requirement_terraform"></a> terraform>= 1.0.0
<a name="requirement_aws"></a> aws>= 4.66.1
<a name="requirement_jq"></a> jq>=0.2.0
<a name="requirement_template"></a> template>= 2.2

Providers

NameVersion
<a name="provider_aws"></a> aws>= 4.66.1
<a name="provider_jq"></a> jq>=0.2.0
<a name="provider_template"></a> template>= 2.2

Modules

NameSourceVersion
<a name="module_alb"></a> albcloudposse/stack-config/yaml//modules/remote-state1.5.0
<a name="module_alb_ingress"></a> alb_ingresscloudposse/alb-ingress/aws0.28.0
<a name="module_cloudmap_namespace"></a> cloudmap_namespacecloudposse/stack-config/yaml//modules/remote-state1.5.0
<a name="module_cloudmap_namespace_service_discovery"></a> cloudmap_namespace_service_discoverycloudposse/stack-config/yaml//modules/remote-state1.5.0
<a name="module_container_definition"></a> container_definitioncloudposse/ecs-container-definition/aws0.61.1
<a name="module_datadog_configuration"></a> datadog_configuration../datadog-configuration/modules/datadog_keysn/a
<a name="module_datadog_container_definition"></a> datadog_container_definitioncloudposse/ecs-container-definition/aws0.58.1
<a name="module_datadog_fluent_bit_container_definition"></a> datadog_fluent_bit_container_definitioncloudposse/ecs-container-definition/aws0.58.1
<a name="module_datadog_sidecar_logs"></a> datadog_sidecar_logscloudposse/cloudwatch-logs/aws0.6.6
<a name="module_ecs_alb_service_task"></a> ecs_alb_service_taskcloudposse/ecs-alb-service-task/aws0.72.0
<a name="module_ecs_cloudwatch_autoscaling"></a> ecs_cloudwatch_autoscalingcloudposse/ecs-cloudwatch-autoscaling/aws0.7.3
<a name="module_ecs_cloudwatch_sns_alarms"></a> ecs_cloudwatch_sns_alarmscloudposse/ecs-cloudwatch-sns-alarms/aws0.12.3
<a name="module_ecs_cluster"></a> ecs_clustercloudposse/stack-config/yaml//modules/remote-state1.5.0
<a name="module_efs"></a> efscloudposse/stack-config/yaml//modules/remote-state1.5.0
<a name="module_gha_assume_role"></a> gha_assume_role../account-map/modules/team-assume-role-policyn/a
<a name="module_gha_role_name"></a> gha_role_namecloudposse/label/null0.25.0
<a name="module_iam_role"></a> iam_rolecloudposse/stack-config/yaml//modules/remote-state1.5.0
<a name="module_iam_roles"></a> iam_roles../account-map/modules/iam-rolesn/a
<a name="module_logs"></a> logscloudposse/cloudwatch-logs/aws0.6.8
<a name="module_nlb"></a> nlbcloudposse/stack-config/yaml//modules/remote-state1.5.0
<a name="module_rds"></a> rdscloudposse/stack-config/yaml//modules/remote-state1.5.0
<a name="module_roles_to_principals"></a> roles_to_principals../account-map/modules/roles-to-principalsn/a
<a name="module_s3"></a> s3cloudposse/stack-config/yaml//modules/remote-state1.5.0
<a name="module_security_group"></a> security_groupcloudposse/stack-config/yaml//modules/remote-state1.5.0
<a name="module_service_domain"></a> service_domaincloudposse/stack-config/yaml//modules/remote-state1.5.0
<a name="module_this"></a> thiscloudposse/label/null0.25.0
<a name="module_vanity_alias"></a> vanity_aliascloudposse/route53-alias/aws0.13.0
<a name="module_vpc"></a> vpccloudposse/stack-config/yaml//modules/remote-state1.5.0

Resources

NameType
aws_iam_policy.defaultresource
aws_iam_role.github_actionsresource
aws_kinesis_stream.defaultresource
aws_s3_bucket_object.task_definition_templateresource
aws_security_group_rule.custom_sg_rulesresource
aws_service_discovery_service.defaultresource
aws_ssm_parameter.full_urlsresource
aws_caller_identity.currentdata source
aws_ecs_task_definition.created_taskdata source
aws_iam_policy_document.github_actions_iam_ecspresso_policydata source
aws_iam_policy_document.github_actions_iam_platform_policydata source
aws_iam_policy_document.github_actions_iam_policydata source
aws_iam_policy_document.thisdata source
aws_kms_alias.selecteddata source
aws_route53_zone.selecteddata source
aws_route53_zone.selected_vanitydata source
aws_s3_object.task_definitiondata source
aws_s3_objects.mirrordata source
aws_ssm_parameters_by_path.defaultdata source
jq_query.service_domain_querydata source
template_file.envsdata source

Inputs

NameDescriptionTypeDefaultRequired
<a name="input_additional_tag_map"></a> additional_tag_mapAdditional key-value pairs to add to each map in tags_as_list_of_maps. Not added to tags or id.<br/>This is for some rare cases where resources want additional configuration of tags<br/>and therefore take a list of maps with tag key, value, and additional configuration.map(string){}no
<a name="input_additional_targets"></a> additional_targetsAdditional target routes to add to the ALB that point to this service. The only difference between this and var.vanity_alias is var.vanity_alias will create an alias record in Route 53 in the hosted zone in this account as well. var.additional_targets only adds the listener route to this service's target group.list(string)[]no
<a name="input_alb_configuration"></a> alb_configurationThe configuration to use for the ALB, specifying which cluster alb configuration to usestring"default"no
<a name="input_alb_name"></a> alb_nameThe name of the ALB this service should attach tostringnullno
<a name="input_attributes"></a> attributesID element. Additional attributes (e.g. workers or cluster) to add to id,<br/>in the order they appear in the list. New attributes are appended to the<br/>end of the list. The elements of the list are joined by the delimiter<br/>and treated as a single ID element.list(string)[]no
<a name="input_autoscaling_dimension"></a> autoscaling_dimensionThe dimension to use to decide to autoscalestring"cpu"no
<a name="input_autoscaling_enabled"></a> autoscaling_enabledShould this service autoscale using SNS alaramsbooltrueno
<a name="input_chamber_service"></a> chamber_serviceSSM parameter service name for use with chamber. This is used in chamber_format where /$chamber_service/$name/$container_name/$parameter would be the default.string"ecs-service"no
<a name="input_cluster_attributes"></a> cluster_attributesThe attributes of the cluster name e.g. if the full name is namespace-tenant-environment-dev-ecs-b2b then the cluster_name is ecs and this value should be b2b.list(string)[]no
<a name="input_containers"></a> containersFeed inputs into container definition module<pre>map(object({<br/> name = string<br/> ecr_image = optional(string)<br/> image = optional(string)<br/> memory = optional(number)<br/> memory_reservation = optional(number)<br/> cpu = optional(number)<br/> essential = optional(bool, true)<br/> readonly_root_filesystem = optional(bool, null)<br/> privileged = optional(bool, null)<br/> container_depends_on = optional(list(object({<br/> containerName = string<br/> condition = string # START, COMPLETE, SUCCESS, HEALTHY<br/> })), null)<br/><br/> port_mappings = optional(list(object({<br/> containerPort = number<br/> hostPort = optional(number)<br/> protocol = optional(string)<br/> name = optional(string)<br/> appProtocol = optional(string)<br/> })), [])<br/> command = optional(list(string), null)<br/> entrypoint = optional(list(string), null)<br/> healthcheck = optional(object({<br/> command = list(string)<br/> interval = number<br/> retries = number<br/> startPeriod = number<br/> timeout = number<br/> }), null)<br/> ulimits = optional(list(object({<br/> name = string<br/> softLimit = number<br/> hardLimit = number<br/> })), null)<br/> log_configuration = optional(object({<br/> logDriver = string<br/> options = optional(map(string), {})<br/> }))<br/> docker_labels = optional(map(string), null)<br/> map_environment = optional(map(string), {})<br/> map_secrets = optional(map(string), {})<br/> volumes_from = optional(list(object({<br/> sourceContainer = string<br/> readOnly = bool<br/> })), null)<br/> mount_points = optional(list(object({<br/> sourceVolume = optional(string)<br/> containerPath = optional(string)<br/> readOnly = optional(bool)<br/> })), [])<br/> }))</pre>{}no
<a name="input_context"></a> contextSingle object for setting entire context at once.<br/>See description of individual variables for details.<br/>Leave string and numeric variables as null to use default value.<br/>Individual variable settings (non-null) override settings in context object,<br/>except for attributes, tags, and additional_tag_map, which are merged.any<pre>{<br/> "additional_tag_map": {},<br/> "attributes": [],<br/> "delimiter": null,<br/> "descriptor_formats": {},<br/> "enabled": true,<br/> "environment": null,<br/> "id_length_limit": null,<br/> "label_key_case": null,<br/> "label_order": [],<br/> "label_value_case": null,<br/> "labels_as_tags": [<br/> "unset"<br/> ],<br/> "name": null,<br/> "namespace": null,<br/> "regex_replace_chars": null,<br/> "stage": null,<br/> "tags": {},<br/> "tenant": null<br/>}</pre>no
<a name="input_cpu_utilization_high_alarm_actions"></a> cpu_utilization_high_alarm_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization High Alarm actionlist(string)[]no
<a name="input_cpu_utilization_high_evaluation_periods"></a> cpu_utilization_high_evaluation_periodsNumber of periods to evaluate for the alarmnumber1no
<a name="input_cpu_utilization_high_ok_actions"></a> cpu_utilization_high_ok_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization High OK actionlist(string)[]no
<a name="input_cpu_utilization_high_period"></a> cpu_utilization_high_periodDuration in seconds to evaluate for the alarmnumber300no
<a name="input_cpu_utilization_high_threshold"></a> cpu_utilization_high_thresholdThe maximum percentage of CPU utilization averagenumber80no
<a name="input_cpu_utilization_low_alarm_actions"></a> cpu_utilization_low_alarm_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization Low Alarm actionlist(string)[]no
<a name="input_cpu_utilization_low_evaluation_periods"></a> cpu_utilization_low_evaluation_periodsNumber of periods to evaluate for the alarmnumber1no
<a name="input_cpu_utilization_low_ok_actions"></a> cpu_utilization_low_ok_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization Low OK actionlist(string)[]no
<a name="input_cpu_utilization_low_period"></a> cpu_utilization_low_periodDuration in seconds to evaluate for the alarmnumber300no
<a name="input_cpu_utilization_low_threshold"></a> cpu_utilization_low_thresholdThe minimum percentage of CPU utilization averagenumber20no
<a name="input_custom_security_group_rules"></a> custom_security_group_rulesThe list of custom security group rules to add to the service security group<pre>list(object({<br/> type = string<br/> from_port = number<br/> to_port = number<br/> protocol = string<br/> cidr_blocks = list(string)<br/> description = optional(string)<br/> }))</pre>[]no
<a name="input_datadog_agent_sidecar_enabled"></a> datadog_agent_sidecar_enabledEnable the Datadog Agent Sidecarboolfalseno
<a name="input_datadog_log_method_is_firelens"></a> datadog_log_method_is_firelensDatadog logs can be sent via cloudwatch logs (and lambda) or firelens, set this to true to enable firelens via a sidecar container for fluentbitboolfalseno
<a name="input_datadog_logging_default_tags_enabled"></a> datadog_logging_default_tags_enabledAdd Default tags to all logs sent to Datadogbooltrueno
<a name="input_datadog_logging_tags"></a> datadog_logging_tagsTags to add to all logs sent to Datadogmap(string)nullno
<a name="input_datadog_sidecar_containers_logs_enabled"></a> datadog_sidecar_containers_logs_enabledEnable the Datadog Agent Sidecar to send logs to aws cloudwatch group, requires datadog_agent_sidecar_enabled to be truebooltrueno
<a name="input_delimiter"></a> delimiterDelimiter to be used between ID elements.<br/>Defaults to - (hyphen). Set to "" to use no delimiter at all.stringnullno
<a name="input_descriptor_formats"></a> descriptor_formatsDescribe additional descriptors to be output in the descriptors output map.<br/>Map of maps. Keys are names of descriptors. Values are maps of the form<br/>{<br/> format = string<br/> labels = list(string)<br/>}<br/>(Type is any so the map values can later be enhanced to provide additional options.)<br/>format is a Terraform format string to be passed to the format() function.<br/>labels is a list of labels, in order, to pass to format() function.<br/>Label values will be normalized before being passed to format() so they will be<br/>identical to how they appear in id.<br/>Default is {} (descriptors output will be empty).any{}no
<a name="input_ecr_region"></a> ecr_regionThe region to use for the fully qualified ECR image URL. Defaults to the current region.string""no
<a name="input_ecr_stage_name"></a> ecr_stage_nameThe ecr stage (account) name to use for the fully qualified ECR image URL.string"auto"no
<a name="input_ecs_cluster_name"></a> ecs_cluster_nameThe name of the ECS Cluster this belongs toany"ecs"no
<a name="input_enabled"></a> enabledSet to false to prevent the module from creating any resourcesboolnullno
<a name="input_environment"></a> environmentID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'stringnullno
<a name="input_exec_enabled"></a> exec_enabledSpecifies whether to enable Amazon ECS Exec for the tasks within the serviceboolfalseno
<a name="input_github_actions_allowed_repos"></a> github_actions_allowed_reposA list of the GitHub repositories that are allowed to assume this role from GitHub Actions. For example,<br/> ["cloudposse/infra-live"]. Can contain "*" as wildcard.<br/> If org part of repo name is omitted, "cloudposse" will be assumed.list(string)[]no
<a name="input_github_actions_ecspresso_enabled"></a> github_actions_ecspresso_enabledCreate IAM policies required for deployments with Ecspressoboolfalseno
<a name="input_github_actions_iam_role_attributes"></a> github_actions_iam_role_attributesAdditional attributes to add to the role namelist(string)[]no
<a name="input_github_actions_iam_role_enabled"></a> github_actions_iam_role_enabledFlag to toggle creation of an IAM Role that GitHub Actions can assume to access AWS resourcesboolfalseno
<a name="input_github_oidc_trusted_role_arns"></a> github_oidc_trusted_role_arnsA list of IAM Role ARNs allowed to assume this cluster's GitHub OIDC rolelist(string)[]no
<a name="input_health_check_healthy_threshold"></a> health_check_healthy_thresholdThe number of consecutive health checks successes required before healthynumber2no
<a name="input_health_check_interval"></a> health_check_intervalThe duration in seconds in between health checksnumber15no
<a name="input_health_check_matcher"></a> health_check_matcherThe HTTP response codes to indicate a healthy checkstring"200-404"no
<a name="input_health_check_path"></a> health_check_pathThe destination for the health check requeststring"/health"no
<a name="input_health_check_port"></a> health_check_portThe port to use to connect with the target. Valid values are either ports 1-65536, or traffic-port. Defaults to traffic-portstring"traffic-port"no
<a name="input_health_check_timeout"></a> health_check_timeoutThe amount of time to wait in seconds before failing a health check requestnumber10no
<a name="input_health_check_unhealthy_threshold"></a> health_check_unhealthy_thresholdThe number of consecutive health check failures required before unhealthynumber2no
<a name="input_http_protocol"></a> http_protocolWhich http protocol to use in outputs and SSM url params. This value is ignored if a load balancer is not used. If it is null, the redirect value from the ALB determines the protocol.stringnullno
<a name="input_iam_policy_enabled"></a> iam_policy_enabledIf set to true will create IAM policy in AWSboolfalseno
<a name="input_iam_policy_statements"></a> iam_policy_statementsMap of IAM policy statements to use in the policy. This can be used with or instead of the var.iam_source_json_url.any{}no
<a name="input_id_length_limit"></a> id_length_limitLimit id to this many characters (minimum 6).<br/>Set to 0 for unlimited length.<br/>Set to null for keep the existing setting, which defaults to 0.<br/>Does not affect id_full.numbernullno
<a name="input_kinesis_enabled"></a> kinesis_enabledEnable Kinesisboolfalseno
<a name="input_kms_alias_name_ssm"></a> kms_alias_name_ssmKMS alias name for SSMstring"alias/aws/ssm"no
<a name="input_kms_key_alias"></a> kms_key_aliasID of KMS keystring"default"no
<a name="input_label_key_case"></a> label_key_caseControls the letter case of the tags keys (label names) for tags generated by this module.<br/>Does not affect keys of tags passed in via the tags input.<br/>Possible values: lower, title, upper.<br/>Default value: title.stringnullno
<a name="input_label_order"></a> label_orderThe order in which the labels (ID elements) appear in the id.<br/>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br/>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.list(string)nullno
<a name="input_label_value_case"></a> label_value_caseControls the letter case of ID elements (labels) as included in id,<br/>set as tag values, and output by this module individually.<br/>Does not affect values of tags passed in via the tags input.<br/>Possible values: lower, title, upper and none (no transformation).<br/>Set this to title and set delimiter to "" to yield Pascal Case IDs.<br/>Default value: lower.stringnullno
<a name="input_labels_as_tags"></a> labels_as_tagsSet of labels (ID elements) to include as tags in the tags output.<br/>Default is to include all labels.<br/>Tags with empty values will not be included in the tags output.<br/>Set to [] to suppress all generated tags.<br/>Notes:<br/> The value of the name tag, if included, will be the id, not the name.<br/> Unlike other null-label inputs, the initial setting of labels_as_tags cannot be<br/> changed in later chained modules. Attempts to change it will be silently ignored.set(string)<pre>[<br/> "default"<br/>]</pre>no
<a name="input_lb_catch_all"></a> lb_catch_allShould this service act as catch all for all subdomain hosts of the vanity domainboolfalseno
<a name="input_logs"></a> logsFeed inputs into cloudwatch logs moduleany{}no
<a name="input_memory_utilization_high_alarm_actions"></a> memory_utilization_high_alarm_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization High Alarm actionlist(string)[]no
<a name="input_memory_utilization_high_evaluation_periods"></a> memory_utilization_high_evaluation_periodsNumber of periods to evaluate for the alarmnumber1no
<a name="input_memory_utilization_high_ok_actions"></a> memory_utilization_high_ok_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization High OK actionlist(string)[]no
<a name="input_memory_utilization_high_period"></a> memory_utilization_high_periodDuration in seconds to evaluate for the alarmnumber300no
<a name="input_memory_utilization_high_threshold"></a> memory_utilization_high_thresholdThe maximum percentage of Memory utilization averagenumber80no
<a name="input_memory_utilization_low_alarm_actions"></a> memory_utilization_low_alarm_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization Low Alarm actionlist(string)[]no
<a name="input_memory_utilization_low_evaluation_periods"></a> memory_utilization_low_evaluation_periodsNumber of periods to evaluate for the alarmnumber1no
<a name="input_memory_utilization_low_ok_actions"></a> memory_utilization_low_ok_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization Low OK actionlist(string)[]no
<a name="input_memory_utilization_low_period"></a> memory_utilization_low_periodDuration in seconds to evaluate for the alarmnumber300no
<a name="input_memory_utilization_low_threshold"></a> memory_utilization_low_thresholdThe minimum percentage of Memory utilization averagenumber20no
<a name="input_name"></a> nameID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br/>This is the only ID element not also included as a tag.<br/>The "name" tag is set to the full id string. There is no tag with the value of the name input.stringnullno
<a name="input_namespace"></a> namespaceID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally uniquestringnullno
<a name="input_nlb_name"></a> nlb_nameThe name of the NLB this service should attach tostringnullno
<a name="input_rds_name"></a> rds_nameThe name of the RDS database this service should allow access toanynullno
<a name="input_regex_replace_chars"></a> regex_replace_charsTerraform regular expression (regex) string.<br/>Characters matching the regex will be removed from the ID elements.<br/>If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.stringnullno
<a name="input_region"></a> regionAWS Regionstringn/ayes
<a name="input_retention_period"></a> retention_periodLength of time data records are accessible after they are added to the streamnumber48no
<a name="input_s3_mirror_name"></a> s3_mirror_nameThe name of the S3 mirror componentstringnullno
<a name="input_service_connect_configurations"></a> service_connect_configurationsThe list of Service Connect configurations.<br/>See service_connect_configuration docs https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#service_connect_configuration<pre>list(object({<br/> enabled = bool<br/> namespace = optional(string, null)<br/> log_configuration = optional(object({<br/> log_driver = string<br/> options = optional(map(string), null)<br/> secret_option = optional(list(object({<br/> name = string<br/> value_from = string<br/> })), [])<br/> }), null)<br/> service = optional(list(object({<br/> client_alias = list(object({<br/> dns_name = string<br/> port = number<br/> }))<br/> discovery_name = optional(string, null)<br/> ingress_port_override = optional(number, null)<br/> port_name = string<br/> })), [])<br/> }))</pre>[]no
<a name="input_service_registries"></a> service_registriesThe list of Service Registries.<br/>See service_registries docs https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#service_registries<pre>list(object({<br/> namespace = string<br/> registry_arn = optional(string)<br/> port = optional(number)<br/> container_name = optional(string)<br/> container_port = optional(number)<br/> }))</pre>[]no
<a name="input_shard_count"></a> shard_countNumber of shards that the stream will usenumber1no
<a name="input_shard_level_metrics"></a> shard_level_metricsList of shard-level CloudWatch metrics which can be enabled for the streamlist(string)<pre>[<br/> "IncomingBytes",<br/> "IncomingRecords",<br/> "IteratorAgeMilliseconds",<br/> "OutgoingBytes",<br/> "OutgoingRecords",<br/> "ReadProvisionedThroughputExceeded",<br/> "WriteProvisionedThroughputExceeded"<br/>]</pre>no
<a name="input_ssm_enabled"></a> ssm_enabledIf true create SSM keys for the database user and password.boolfalseno
<a name="input_ssm_key_format"></a> ssm_key_formatSSM path format. The values will will be used in the following order: var.ssm_key_prefix, var.name, var.ssm_key_*string"/%v/%v/%v"no
<a name="input_ssm_key_prefix"></a> ssm_key_prefixSSM path prefix. Omit the leading forward slash /.string"ecs-service"no
<a name="input_stage"></a> stageID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'stringnullno
<a name="input_stickiness_cookie_duration"></a> stickiness_cookie_durationThe 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 range is 1 second to 1 week (604800 seconds). The default value is 1 day (86400 seconds)number86400no
<a name="input_stickiness_enabled"></a> stickiness_enabledBoolean to enable / disable stickiness. Default is truebooltrueno
<a name="input_stickiness_type"></a> stickiness_typeThe type of sticky sessions. The only current possible value is lb_cookiestring"lb_cookie"no
<a name="input_stream_mode"></a> stream_modeStream mode details for the Kinesis streamstring"PROVISIONED"no
<a name="input_tags"></a> tagsAdditional tags (e.g. {'BusinessUnit': 'XYZ'}).<br/>Neither the tag keys nor the tag values will be modified by this module.map(string){}no
<a name="input_task"></a> taskFeed inputs into ecs_alb_service_task module<pre>object({<br/> task_cpu = optional(number)<br/> task_memory = optional(number)<br/> task_role_arn = optional(string, "")<br/> pid_mode = optional(string, null)<br/> ipc_mode = optional(string, null)<br/> network_mode = optional(string)<br/> propagate_tags = optional(string)<br/> assign_public_ip = optional(bool, false)<br/> use_alb_security_groups = optional(bool, true)<br/> launch_type = optional(string, "FARGATE")<br/> scheduling_strategy = optional(string, "REPLICA")<br/> capacity_provider_strategies = optional(list(object({<br/> capacity_provider = string<br/> weight = number<br/> base = number<br/> })), [])<br/><br/> deployment_minimum_healthy_percent = optional(number, null)<br/> deployment_maximum_percent = optional(number, null)<br/> desired_count = optional(number, 0)<br/> min_capacity = optional(number, 1)<br/> max_capacity = optional(number, 2)<br/> wait_for_steady_state = optional(bool, true)<br/> circuit_breaker_deployment_enabled = optional(bool, true)<br/> circuit_breaker_rollback_enabled = optional(bool, true)<br/><br/> ecs_service_enabled = optional(bool, true)<br/> bind_mount_volumes = optional(list(object({<br/> name = string<br/> host_path = string<br/> })), [])<br/> efs_volumes = optional(list(object({<br/> host_path = string<br/> name = string<br/> efs_volume_configuration = list(object({<br/> file_system_id = string<br/> root_directory = string<br/> transit_encryption = string<br/> transit_encryption_port = string<br/> authorization_config = list(object({<br/> access_point_id = string<br/> iam = string<br/> }))<br/> }))<br/> })), [])<br/> efs_component_volumes = optional(list(object({<br/> host_path = string<br/> name = string<br/> efs_volume_configuration = list(object({<br/> component = optional(string, "efs")<br/> tenant = optional(string, null)<br/> environment = optional(string, null)<br/> stage = optional(string, null)<br/><br/> root_directory = string<br/> transit_encryption = string<br/> transit_encryption_port = string<br/> authorization_config = list(object({<br/> access_point_id = string<br/> iam = string<br/> }))<br/> }))<br/> })), [])<br/> docker_volumes = optional(list(object({<br/> host_path = string<br/> name = string<br/> docker_volume_configuration = list(object({<br/> autoprovision = bool<br/> driver = string<br/> driver_opts = map(string)<br/> labels = map(string)<br/> scope = string<br/> }))<br/> })), [])<br/> fsx_volumes = optional(list(object({<br/> host_path = string<br/> name = string<br/> fsx_windows_file_server_volume_configuration = list(object({<br/> file_system_id = string<br/> root_directory = string<br/> authorization_config = list(object({<br/> credentials_parameter = string<br/> domain = string<br/> }))<br/> }))<br/> })), [])<br/> })</pre>{}no
<a name="input_task_enabled"></a> task_enabledWhether or not to use the ECS task modulebooltrueno
<a name="input_task_exec_policy_arns_map"></a> task_exec_policy_arns_mapA map of name to IAM Policy ARNs to attach to the generated task execution role.<br/>The names are arbitrary, but must be known at plan time. The purpose of the name<br/>is so that changes to one ARN do not cause a ripple effect on the other ARNs.<br/>If you cannot provide unique names known at plan time, use task_exec_policy_arns instead.map(string){}no
<a name="input_task_iam_role_component"></a> task_iam_role_componentA component that outputs an iam_role module as 'role' for adding to the service as a whole.stringnullno
<a name="input_task_policy_arns"></a> task_policy_arnsThe IAM policy ARNs to attach to the ECS task IAM rolelist(string)<pre>[<br/> "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly",<br/> "arn:aws:iam::aws:policy/AmazonSSMReadOnlyAccess"<br/>]</pre>no
<a name="input_task_security_group_component"></a> task_security_group_componentA component that outputs security_group_id for adding to the service as a whole.stringnullno
<a name="input_tenant"></a> tenantID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is forstringnullno
<a name="input_unauthenticated_paths"></a> unauthenticated_pathsUnauthenticated path pattern to matchlist(string)[]no
<a name="input_unauthenticated_priority"></a> unauthenticated_priorityThe priority for the rules without authentication, between 1 and 50000 (1 being highest priority). Must be different from authenticated_priority since a listener can't have multiple rules with the same prioritystring0no
<a name="input_use_lb"></a> use_lbWhether use load balancer for the serviceboolfalseno
<a name="input_use_rds_client_sg"></a> use_rds_client_sgUse the RDS client security groupboolfalseno
<a name="input_vanity_alias"></a> vanity_aliasThe vanity aliases to use for the public LB.list(string)[]no
<a name="input_vanity_domain"></a> vanity_domainWhether to use the vanity domain alias for the servicestringnullno
<a name="input_zone_component"></a> zone_componentThe component name to look up service domain remote-state onstring"dns-delegated"no
<a name="input_zone_component_output"></a> zone_component_outputA json query to use to get the zone domain from the remote state. Seestring".default_domain_name"no

Outputs

NameDescription
<a name="output_ecs_cluster_arn"></a> ecs_cluster_arnSelected ECS cluster ARN
<a name="output_environment_map"></a> environment_mapEnvironment variables to pass to the container, this is a map of key/value pairs, where the key is containerName,variableName
<a name="output_full_domain"></a> full_domainDomain to respond to GET requests
<a name="output_github_actions_iam_role_arn"></a> github_actions_iam_role_arnARN of IAM role for GitHub Actions
<a name="output_github_actions_iam_role_name"></a> github_actions_iam_role_nameName of IAM role for GitHub Actions
<a name="output_lb_arn"></a> lb_arnSelected LB ARN
<a name="output_lb_listener_https"></a> lb_listener_httpsSelected LB HTTPS Listener
<a name="output_lb_sg_id"></a> lb_sg_idSelected LB SG ID
<a name="output_logs"></a> logsOutput of cloudwatch logs module
<a name="output_service_image"></a> service_imageThe image of the service container
<a name="output_ssm_key_prefix"></a> ssm_key_prefixSSM prefix
<a name="output_ssm_parameters"></a> ssm_parametersSSM parameters for the ECS Service
<a name="output_subnet_ids"></a> subnet_idsSelected subnet IDs
<a name="output_task_definition_arn"></a> task_definition_arnThe task definition ARN
<a name="output_task_definition_revision"></a> task_definition_revisionThe task definition revision
<a name="output_task_template"></a> task_templateThe task template rendered
<a name="output_vpc_id"></a> vpc_idSelected VPC ID
<a name="output_vpc_sg_id"></a> vpc_sg_idSelected VPC SG ID
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> <!-- prettier-ignore-end -->

References

[!TIP]

πŸ‘½ Use Atmos with Terraform

Cloud Posse uses atmos to easily orchestrate multiple environments using Terraform. <br/> Works with Github Actions, Atlantis, or Spacelift.

<details> <summary><strong>Watch demo of using Atmos with Terraform</strong></summary> <img src="https://github.com/cloudposse/atmos/blob/main/docs/demo.gif?raw=true"/><br/> <i>Example of running <a href="https://atmos.tools"><code>atmos</code></a> to manage infrastructure from our <a href="https://atmos.tools/quick-start/">Quick Start</a> tutorial.</i> </detalis>

Related Projects

Check out these related projects.

[!TIP]

Use Terraform Reference Architectures for AWS

Use Cloud Posse's ready-to-go terraform architecture blueprints for AWS to get up and running quickly.

βœ… We build it together with your team.<br/> βœ… Your team owns everything.<br/> βœ… 100% Open Source and backed by fanatical support.<br/>

<a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse-terraform-components/aws-ecs-service&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>

<details><summary>πŸ“š <strong>Learn More</strong></summary> <br/>

Cloud Posse is the leading DevOps Accelerator for funded startups and enterprises.

Your team can operate like a pro today.

Ensure that your team succeeds by using Cloud Posse's proven process and turnkey blueprints. Plus, we stick around until you succeed.

Day-0: Your Foundation for Success

<a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse-terraform-components/aws-ecs-service&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>

Day-2: Your Operational Mastery

<a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse-terraform-components/aws-ecs-service&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>

</details>

✨ Contributing

This project is under active development, and we encourage contributions from our community.

Many thanks to our outstanding contributors:

<a href="https://github.com/cloudposse-terraform-components/aws-ecs-service/graphs/contributors"> <img src="https://contrib.rocks/image?repo=cloudposse-terraform-components/aws-ecs-service&max=24" /> </a>

For πŸ› bug reports & feature requests, please use the issue tracker.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

  1. Review our Code of Conduct and Contributor Guidelines.
  2. Fork the repo on GitHub
  3. Clone the project to your own machine
  4. Commit changes to your own branch
  5. Push your work back up to your fork
  6. Submit a Pull Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

🌎 Slack Community

Join our Open Source Community on Slack. It's FREE for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally sweet infrastructure.

πŸ“° Newsletter

Sign up for our newsletter and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. Dropped straight into your Inbox every week β€” and usually a 5-minute read.

πŸ“† Office Hours <a href="https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse-terraform-components/aws-ecs-service&utm_content=office_hours"><img src="https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png" align="right" /></a>

Join us every Wednesday via Zoom for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a live Q&A that you can’t find anywhere else. It's FREE for everyone!

License

<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge" alt="License"></a>

<details> <summary>Preamble to the Apache License, Version 2.0</summary> <br/> <br/>
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
</details>

Trademarks

All other trademarks referenced herein are the property of their respective owners.


Copyright Β© 2017-2024 Cloud Posse, LLC

<a href="https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse-terraform-components/aws-ecs-service&utm_content=readme_footer_link"><img alt="README footer" src="https://cloudposse.com/readme/footer/img"/></a>

<img alt="Beacon" width="0" src="https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse-terraform-components/aws-ecs-service?pixel&cs=github&cm=readme&an=aws-ecs-service"/>