Skip to main content

Module: ecs-web-app

A Terraform module which implements a web app on ECS and supporting AWS resources.

Usage

For a complete example, see examples/complete.

For automated tests of the complete example using bats and Terratest (which test and deploy the example on AWS), see test.

Other examples:

module "default_backend_web_app" {
source = "cloudposse/ecs-web-app/aws"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
namespace = "eg"
stage = "testing"
name = "appname"
vpc_id = module.vpc.vpc_id
alb_ingress_unauthenticated_listener_arns = module.alb.listener_arns
alb_ingress_unauthenticated_listener_arns_count = 1
aws_logs_region = "us-east-2"
ecs_cluster_arn = aws_ecs_cluster.default.arn
ecs_cluster_name = aws_ecs_cluster.default.name
ecs_security_group_ids = [module.vpc.vpc_default_security_group_id]
ecs_private_subnet_ids = module.subnets.private_subnet_ids
alb_ingress_healthcheck_path = "/healthz"
alb_ingress_unauthenticated_paths = ["/*"]
codepipeline_enabled = false

container_environment = [
{
name = "COOKIE"
value = "cookiemonster"
},
{
name = "PORT"
value = "80"
}
]
}

Requirements

NameVersion
terraform>= 0.13.0
aws>= 3.34, < 5.0

Providers

NameVersion
aws>= 3.34, < 5.0

Modules

NameSourceVersion
alb_ingresscloudposse/alb-ingress/aws0.26.0
alb_target_group_cloudwatch_sns_alarmscloudposse/alb-target-group-cloudwatch-sns-alarms/aws0.17.0
container_definitioncloudposse/ecs-container-definition/aws0.58.1
ecrcloudposse/ecr/aws0.41.0
ecs_alb_service_taskcloudposse/ecs-alb-service-task/aws0.64.1
ecs_cloudwatch_autoscalingcloudposse/ecs-cloudwatch-autoscaling/aws0.7.3
ecs_cloudwatch_sns_alarmscloudposse/ecs-cloudwatch-sns-alarms/aws0.12.2
ecs_codepipelinecloudposse/ecs-codepipeline/aws0.33.0
thiscloudposse/label/null0.25.0

Resources

NameType
aws_cloudwatch_log_group.appresource
aws_region.currentdata source

Inputs

NameDescriptionTypeDefaultRequired
additional_tag_mapAdditional key-value pairs to add to each map in tags_as_list_of_maps. Not added to tags or id.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration.
map(string){}no
alb_arn_suffixARN suffix of the ALB for the Target Groupstring""no
alb_container_nameThe name of the container to associate with the ALB. If not provided, the generated container will be usedstringnullno
alb_ingress_authenticated_hostsAuthenticated hosts to match in Hosts headerlist(string)[]no
alb_ingress_authenticated_listener_arnsA list of authenticated ALB listener ARNs to attach ALB listener rules tolist(string)[]no
alb_ingress_authenticated_listener_arns_countThe number of authenticated ARNs in alb_ingress_authenticated_listener_arns. This is necessary to work around a limitation in Terraform where counts cannot be computednumber0no
alb_ingress_authenticated_pathsAuthenticated path pattern to match (a maximum of 1 can be defined)list(string)[]no
alb_ingress_enable_default_target_groupIf true, create a default target group for the ALB ingressbooltrueno
alb_ingress_health_check_healthy_thresholdThe number of consecutive health checks successes required before healthynumber2no
alb_ingress_health_check_intervalThe duration in seconds in between health checksnumber15no
alb_ingress_health_check_matcherThe HTTP response codes to indicate a healthy checkstring"200-399"no
alb_ingress_health_check_timeoutThe amount of time to wait in seconds before failing a health check requestnumber10no
alb_ingress_health_check_unhealthy_thresholdThe number of consecutive health check failures required before unhealthynumber2no
alb_ingress_healthcheck_pathThe path of the healthcheck which the ALB checksstring"/"no
alb_ingress_healthcheck_protocolThe protocol to use to connect with the target. Defaults to HTTP. Not applicable when target_type is lambdastring"HTTP"no
alb_ingress_listener_authenticated_priorityThe priority for the rules with authentication, between 1 and 50000 (1 being highest priority). Must be different from alb_ingress_listener_unauthenticated_priority since a listener can't have multiple rules with the same prioritynumber300no
alb_ingress_listener_unauthenticated_priorityThe priority for the rules without authentication, between 1 and 50000 (1 being highest priority). Must be different from alb_ingress_listener_authenticated_priority since a listener can't have multiple rules with the same prioritynumber1000no
alb_ingress_load_balancing_algorithm_typeDetermines how the load balancer selects targets when routing requests. Only applicable for Application Load Balancer Target Groups. The value is round_robin or least_outstanding_requests. The default is round_robin.string"round_robin"no
alb_ingress_protocolThe protocol for the created ALB target group (if target_group_arn is not set). One of HTTP, HTTPS. Defaults to HTTP.string"HTTP"no
alb_ingress_protocol_versionThe protocol version. One of HTTP1, HTTP2, GRPC. Only applicable when protocol is HTTP or HTTPS. Specify GRPC to send requests to targets using gRPC. Specify HTTP2 to send requests to targets using HTTP/2. The default is HTTP1, which sends requests to targets using HTTP/1.1string"HTTP1"no
alb_ingress_target_group_arnExisting ALB target group ARN. If provided, set alb_ingress_enable_default_target_group to false to disable creation of the default target groupstring""no
alb_ingress_unauthenticated_hostsUnauthenticated hosts to match in Hosts headerlist(string)[]no
alb_ingress_unauthenticated_listener_arnsA list of unauthenticated ALB listener ARNs to attach ALB listener rules tolist(string)[]no
alb_ingress_unauthenticated_listener_arns_countThe number of unauthenticated ARNs in alb_ingress_unauthenticated_listener_arns. This is necessary to work around a limitation in Terraform where counts cannot be computednumber0no
alb_ingress_unauthenticated_pathsUnauthenticated path pattern to match (a maximum of 1 can be defined)list(string)[]no
alb_security_groupSecurity group of the ALBstringn/ayes
alb_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
alb_stickiness_enabledBoolean to enable / disable stickiness. Default is truebooltrueno
alb_stickiness_typeThe type of sticky sessions. The only current possible value is lb_cookiestring"lb_cookie"no
alb_target_group_alarms_3xx_thresholdThe maximum number of 3XX HTTPCodes in a given period for ECS Servicenumber25no
alb_target_group_alarms_4xx_thresholdThe maximum number of 4XX HTTPCodes in a given period for ECS Servicenumber25no
alb_target_group_alarms_5xx_thresholdThe maximum number of 5XX HTTPCodes in a given period for ECS Servicenumber25no
alb_target_group_alarms_alarm_actionsA list of ARNs (i.e. SNS Topic ARN) to execute when ALB Target Group alarms transition into an ALARM state from any other statelist(string)[]no
alb_target_group_alarms_enabledA boolean to enable/disable CloudWatch Alarms for ALB Target metricsboolfalseno
alb_target_group_alarms_evaluation_periodsThe number of periods to analyze for ALB CloudWatch Alarmsnumber1no
alb_target_group_alarms_insufficient_data_actionsA list of ARNs (i.e. SNS Topic ARN) to execute when ALB Target Group alarms transition into an INSUFFICIENT_DATA state from any other statelist(string)[]no
alb_target_group_alarms_ok_actionsA list of ARNs (i.e. SNS Topic ARN) to execute when ALB Target Group alarms transition into an OK state from any other statelist(string)[]no
alb_target_group_alarms_periodThe period (in seconds) to analyze for ALB CloudWatch Alarmsnumber300no
alb_target_group_alarms_response_time_thresholdThe maximum ALB Target Group response timenumber0.5no
assign_public_ipAssign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default falseboolfalseno
attributesID element. Additional attributes (e.g. workers or cluster) to add to id,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the delimiter
and treated as a single ID element.
list(string)[]no
authentication_cognito_scopeCognito scope, which should be a space separated string of requested scopes (see https://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims)stringnullno
authentication_cognito_user_pool_arnCognito User Pool ARNstring""no
authentication_cognito_user_pool_client_idCognito User Pool Client IDstring""no
authentication_cognito_user_pool_domainCognito User Pool Domain. The User Pool Domain should be set to the domain prefix (xxx) instead of full domain (https://xxx.auth.us-west-2.amazoncognito.com)string""no
authentication_oidc_authorization_endpointOIDC Authorization Endpointstring""no
authentication_oidc_client_idOIDC Client IDstring""no
authentication_oidc_client_secretOIDC Client Secretstring""no
authentication_oidc_issuerOIDC Issuerstring""no
authentication_oidc_scopeOIDC scope, which should be a space separated string of requested scopes (see https://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims, and https://developers.google.com/identity/protocols/oauth2/openid-connect#scope-param for an example set of scopes when using Google as the IdP)stringnullno
authentication_oidc_token_endpointOIDC Token Endpointstring""no
authentication_oidc_user_info_endpointOIDC User Info Endpointstring""no
authentication_typeAuthentication type. Supported values are COGNITO and OIDCstring""no
autoscaling_dimensionDimension to autoscale on (valid options: cpu, memory)string"memory"no
autoscaling_enabledA boolean to enable/disable Autoscaling policy for ECS Serviceboolfalseno
autoscaling_max_capacityMaximum number of running instances of a Servicenumber2no
autoscaling_min_capacityMinimum number of running instances of a Servicenumber1no
autoscaling_scale_down_adjustmentScaling adjustment to make during scale down eventnumber-1no
autoscaling_scale_down_cooldownPeriod (in seconds) to wait between scale down eventsnumber300no
autoscaling_scale_up_adjustmentScaling adjustment to make during scale up eventnumber1no
autoscaling_scale_up_cooldownPeriod (in seconds) to wait between scale up eventsnumber60no
aws_logs_prefixCustom AWS Logs prefix. If empty name from label module will be usedstring""no
aws_logs_regionThe region for the AWS Cloudwatch Logs groupstringnullno
badge_enabledGenerates a publicly-accessible URL for the projects build badge. Available as badge_url attribute when enabledboolfalseno
branchBranch of the GitHub repository, e.g. masterstring""no
build_environment_variablesA list of maps, that contain the keys 'name', 'value', and 'type' to be used as additional environment variables for the build. Valid types are 'PLAINTEXT', 'PARAMETER_STORE', or 'SECRETS_MANAGER'
list(object(
{
name = string
value = string
type = string
}))
[]no
build_imageDocker image for build environment, e.g. aws/codebuild/docker:docker:17.09.0string"aws/codebuild/docker:17.09.0"no
build_timeoutHow long in minutes, from 5 to 480 (8 hours), for AWS CodeBuild to wait until timing out any related build that does not get marked as completednumber60no
buildspecDeclaration to use for building the project. For more infostring""no
capacity_provider_strategiesThe capacity provider strategies to use for the service. See capacity_provider_strategy configuration block: https://www.terraform.io/docs/providers/aws/r/ecs_service.html#capacity_provider_strategy
list(object({
capacity_provider = string
weight = number
base = number
}))
[]no
circuit_breaker_deployment_enabledIf true, enable the deployment circuit breaker logic for the serviceboolfalseno
circuit_breaker_rollback_enabledIf true, Amazon ECS will roll back the service if a service deployment failsboolfalseno
cloudwatch_log_group_enabledA boolean to disable cloudwatch log group creationbooltrueno
codebuild_cache_typeThe type of storage that will be used for the AWS CodeBuild project cache. Valid values: NO_CACHE, LOCAL, and S3. Defaults to NO_CACHE. If cache_type is S3, it will create an S3 bucket for storing codebuild cache insidestring"S3"no
codepipeline_build_cache_bucket_suffix_enabledThe codebuild cache bucket generates a random 13 character string to generate a unique bucket name. If set to false it uses terraform-null-label's id value. It only works when cache_type is 'S3'booltrueno
codepipeline_build_compute_typeCodeBuild instance size. Possible values are: BUILD_GENERAL1_SMALL BUILD_GENERAL1_MEDIUM BUILD_GENERAL1_LARGEstring"BUILD_GENERAL1_SMALL"no
codepipeline_cdn_bucket_buildspec_identifierIdentifier for buildspec section controlling the optional CDN asset deployment.stringnullno
codepipeline_cdn_bucket_encryption_enabledIf set to true, enable encryption on the optional CDN asset deployment bucketboolfalseno
codepipeline_cdn_bucket_idOptional bucket for static asset deployment. If specified, the buildspec must include a secondary artifacts section which controls the files deployed to the bucket For more infostringnullno
codepipeline_enabledA boolean to enable/disable AWS Codepipeline. If false, use ecr_enabled to control if AWS ECR stays enabled.booltrueno
codepipeline_s3_bucket_force_destroyA boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without errorboolfalseno
commandThe command that is passed to the containerlist(string)nullno
container_cpuThe vCPU setting to control cpu limits of container. (If FARGATE launch type is used below, this must be a supported vCPU size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html)number256no
container_definitionOverride the main container_definitionstring""no
container_environmentThe environment variables to pass to the container. This is a list of maps
list(object({
name = string
value = string
}))
nullno
container_imageThe default container image to use in container definitionstring"cloudposse/default-backend"no
container_memoryThe amount of RAM to allow container to use in MB. (If FARGATE launch type is used below, this must be a supported Memory size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html)number512no
container_memory_reservationThe amount of RAM (Soft Limit) to allow container to use in MB. This value must be less than container_memory if setnumber128no
container_portThe port number on the container bound to assigned host_portnumber80no
container_repo_credentialsContainer repository credentials; required when using a private repo. This map currently supports a single key; "credentialsParameter", which should be the ARN of a Secrets Manager's secret holding the credentialsmap(string)nullno
container_start_timeoutTime duration (in seconds) to wait before giving up on resolving dependencies for a containernumber30no
container_stop_timeoutTime duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its ownnumber30no
contextSingle object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
any
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
no
delimiterDelimiter to be used between ID elements.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
stringnullno
deployment_controller_typeType of deployment controller. Valid values are CODE_DEPLOY and ECSstring"ECS"no
deployment_maximum_percentThe upper limit of the number of tasks (as a percentage of desired_count) that can be running in a service during a deploymentnumber200no
deployment_minimum_healthy_percentThe lower limit (as a percentage of desired_count) of the number of tasks that must remain running and healthy in a service during a deploymentnumber100no
descriptor_formatsDescribe additional descriptors to be output in the descriptors output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
{<br/> format = string<br/> labels = list(string)<br/>}
(Type is any so the map values can later be enhanced to provide additional options.)
format is a Terraform format string to be passed to the format() function.
labels is a list of labels, in order, to pass to format() function.
Label values will be normalized before being passed to format() so they will be
identical to how they appear in id.
Default is {} (descriptors output will be empty).
any{}no
desired_countThe desired number of tasks to start with. Set this to 0 if using DAEMON Service type. (FARGATE does not suppoert DAEMON Service type)number1no
ecr_enabledA boolean to enable/disable AWS ECRbooltrueno
ecr_image_tag_mutabilityThe tag mutability setting for the ecr repository. Must be one of: MUTABLE or IMMUTABLEstring"IMMUTABLE"no
ecr_scan_images_on_pushIndicates whether images are scanned after being pushed to the repository (true) or not (false)boolfalseno
ecs_alarms_cpu_utilization_high_alarm_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization High Alarm actionlist(string)[]no
ecs_alarms_cpu_utilization_high_evaluation_periodsNumber of periods to evaluate for the alarmnumber1no
ecs_alarms_cpu_utilization_high_ok_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization High OK actionlist(string)[]no
ecs_alarms_cpu_utilization_high_periodDuration in seconds to evaluate for the alarmnumber300no
ecs_alarms_cpu_utilization_high_thresholdThe maximum percentage of CPU utilization averagenumber80no
ecs_alarms_cpu_utilization_low_alarm_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization Low Alarm actionlist(string)[]no
ecs_alarms_cpu_utilization_low_evaluation_periodsNumber of periods to evaluate for the alarmnumber1no
ecs_alarms_cpu_utilization_low_ok_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization Low OK actionlist(string)[]no
ecs_alarms_cpu_utilization_low_periodDuration in seconds to evaluate for the alarmnumber300no
ecs_alarms_cpu_utilization_low_thresholdThe minimum percentage of CPU utilization averagenumber20no
ecs_alarms_enabledA boolean to enable/disable CloudWatch Alarms for ECS Service metricsboolfalseno
ecs_alarms_memory_utilization_high_alarm_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization High Alarm actionlist(string)[]no
ecs_alarms_memory_utilization_high_evaluation_periodsNumber of periods to evaluate for the alarmnumber1no
ecs_alarms_memory_utilization_high_ok_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization High OK actionlist(string)[]no
ecs_alarms_memory_utilization_high_periodDuration in seconds to evaluate for the alarmnumber300no
ecs_alarms_memory_utilization_high_thresholdThe maximum percentage of Memory utilization averagenumber80no
ecs_alarms_memory_utilization_low_alarm_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization Low Alarm actionlist(string)[]no
ecs_alarms_memory_utilization_low_evaluation_periodsNumber of periods to evaluate for the alarmnumber1no
ecs_alarms_memory_utilization_low_ok_actionsA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization Low OK actionlist(string)[]no
ecs_alarms_memory_utilization_low_periodDuration in seconds to evaluate for the alarmnumber300no
ecs_alarms_memory_utilization_low_thresholdThe minimum percentage of Memory utilization averagenumber20no
ecs_cluster_arnThe ECS Cluster ARN where ECS Service will be provisionedstringn/ayes
ecs_cluster_nameThe ECS Cluster Name to use in ECS Code Pipeline Deployment stepstringnullno
ecs_private_subnet_idsList of Private Subnet IDs to provision ECS Service onto if var.network_mode = "awsvpc"list(string)n/ayes
ecs_security_group_enabledWhether to create a security group for the service.booltrueno
ecs_security_group_idsAdditional Security Group IDs to allow into ECS Service if var.network_mode = "awsvpc"list(string)[]no
enable_all_egress_ruleA flag to enable/disable adding the all ports egress rule to the ECS security groupbooltrueno
enable_ecs_managed_tagsSpecifies whether to enable Amazon ECS managed tags for the tasks within the serviceboolfalseno
enabledSet to false to prevent the module from creating any resourcesboolnullno
entrypointThe entry point that is passed to the containerlist(string)nullno
environmentID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'stringnullno
exec_enabledSpecifies whether to enable Amazon ECS Exec for the tasks within the serviceboolfalseno
force_new_deploymentEnable to force a new task deployment of the service.boolfalseno
github_oauth_tokenGitHub Oauth Token with permissions to access private repositoriesstring""no
github_webhook_eventsA list of events which should trigger the webhook. See a list of available eventslist(string)
[
"push"
]
no
health_check_grace_period_secondsSeconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 7200. Only valid for services configured to use load balancersnumber0no
healthcheckA map containing command (string), timeout, interval (duration in seconds), retries (1-10, number of times to retry before marking container unhealthy), and startPeriod (0-300, optional grace period to wait, in seconds, before failed healthchecks count toward retries)
object({
command = list(string)
retries = number
timeout = number
interval = number
startPeriod = number
})
nullno
id_length_limitLimit id to this many characters (minimum 6).
Set to 0 for unlimited length.
Set to null for keep the existing setting, which defaults to 0.
Does not affect id_full.
numbernullno
ignore_changes_desired_countWhether to ignore changes for desired count in the ECS serviceboolfalseno
ignore_changes_task_definitionIgnore changes (like environment variables) to the ECS task definitionbooltrueno
init_containersA list of additional init containers to start. The map contains the container_definition (JSON) and the main container's dependency condition (string) on the init container. The latter can be one of START, COMPLETE, SUCCESS or HEALTHY.
list(object({
container_definition = any
condition = string
}))
[]no
label_key_caseControls the letter case of the tags keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the tags input.
Possible values: lower, title, upper.
Default value: title.
stringnullno
label_orderThe order in which the labels (ID elements) appear in the id.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.
list(string)nullno
label_value_caseControls the letter case of ID elements (labels) as included in id,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the tags input.
Possible values: lower, title, upper and none (no transformation).
Set this to title and set delimiter to "" to yield Pascal Case IDs.
Default value: lower.
stringnullno
labels_as_tagsSet of labels (ID elements) to include as tags in the tags output.
Default is to include all labels.
Tags with empty values will not be included in the tags output.
Set to [] to suppress all generated tags.
Notes:
The value of the name tag, if included, will be the id, not the name.
Unlike other null-label inputs, the initial setting of labels_as_tags cannot be
changed in later chained modules. Attempts to change it will be silently ignored.
set(string)
[
"default"
]
no
launch_typeThe ECS launch type (valid options: FARGATE or EC2)string"FARGATE"no
log_driverThe log driver to use for the container. If using Fargate launch type, only supported value is awslogsstring"awslogs"no
log_retention_in_daysThe number of days to retain logs for the log groupnumber90no
map_container_environmentThe environment variables to pass to the container. This is a map of string: {key: value}. environment overrides map_environmentmap(string)nullno
mount_pointsContainer mount points. This is a list of maps, where each map should contain a containerPath and sourceVolume
list(object({
containerPath = string
sourceVolume = string
readOnly = bool
}))
[]no
nameID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a tag.
The "name" tag is set to the full id string. There is no tag with the value of the name input.
stringnullno
namespaceID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally uniquestringnullno
network_modeThe network mode to use for the task. This is required to be awsvpc for FARGATE launch_type or null for EC2 launch_typestring"awsvpc"no
nlb_cidr_blocksA list of CIDR blocks to add to the ingress rule for the NLB container portlist(string)[]no
nlb_container_nameThe name of the container to associate with the NLB. If not provided, the generated container will be usedstringnullno
nlb_container_portThe port number on the container bound to assigned NLB host_portnumber80no
nlb_ingress_target_group_arnTarget group ARN of the NLB ingressstring""no
permissions_boundaryA permissions boundary ARN to apply to the 3 roles that are created.string""no
platform_versionThe platform version on which to run your service. Only applicable for launch_type set to FARGATE. More information about Fargate platform versions can be found in the AWS ECS User Guide.string"LATEST"no
poll_source_changesPeriodically check the location of your source content and run the pipeline if changes are detectedboolfalseno
port_mappingsThe port mappings to configure for the container. This is a list of maps. Each map should contain "containerPort", "hostPort", and "protocol", where "protocol" is one of "tcp" or "udp". If using containers in a task with the awsvpc or host network mode, the hostPort can either be left blank or set to the same value as the containerPort
list(object({
containerPort = number
hostPort = number
protocol = string
}))
[
{
"containerPort": 80,
"hostPort": 80,
"protocol": "tcp"
}
]
no
privilegedWhen this variable is true, the container is given elevated privileges on the host container instance (similar to the root user). This parameter is not supported for Windows containers or tasks using the Fargate launch type. Due to how Terraform type casts booleans in json it is required to double quote this valuestringnullno
propagate_tagsSpecifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are SERVICE and TASK_DEFINITIONstringnullno
regex_replace_charsTerraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
stringnullno
regionAWS Region for S3 bucketstringnullno
repo_nameGitHub repository name of the application to be built and deployed to ECSstring""no
repo_ownerGitHub Organization or Usernamestring""no
runtime_platformZero or one runtime platform configurations that containers in your task may use.
Map of strings with optional keys operating_system_family and cpu_architecture.
See runtime_platform docs https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#runtime_platform
list(map(string))[]no
secretsThe secrets to pass to the container. This is a list of maps
list(object({
name = string
valueFrom = string
}))
nullno
service_registriesThe service discovery registries for the service. The maximum number of service_registries blocks is 1. The currently supported service registry is Amazon Route 53 Auto Naming Service - aws_service_discovery_service; see service_registries docs https://www.terraform.io/docs/providers/aws/r/ecs_service.html#service_registries-1
list(object({
registry_arn = string
port = number
container_name = string
container_port = number
}))
[]no
stageID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'stringnullno
system_controlsA list of namespaced kernel parameters to set in the container, mapping to the --sysctl option to docker run. This is a list of maps: { namespace = "", value = ""}list(map(string))nullno
tagsAdditional tags (e.g. {'BusinessUnit': 'XYZ'}).
Neither the tag keys nor the tag values will be modified by this module.
map(string){}no
task_cpuThe number of CPU units used by the task. If unspecified, it will default to container_cpu. If using FARGATE launch type task_cpu must match supported memory values (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size)numbernullno
task_memoryThe amount of memory (in MiB) used by the task. If unspecified, it will default to container_memory. If using Fargate launch type task_memory must match supported cpu value (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size)numbernullno
task_policy_arnsA list of IAM Policy ARNs to attach to the generated task role.list(string)[]no
task_role_arnThe ARN of IAM role that allows your Amazon ECS container task to make calls to other AWS servicesstring""no
tenantID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is forstringnullno
ulimitsThe ulimits to configure for the container. This is a list of maps. Each map should contain "name", "softLimit" and "hardLimit"
list(object({
name = string
softLimit = number
hardLimit = number
}))
[]no
use_alb_security_groupA boolean to enable adding an ALB security group rule for the service taskboolfalseno
use_ecr_imageIf true, use ECR repo URL for image, otherwise use value in container_imageboolfalseno
use_nlb_cidr_blocksA flag to enable/disable adding the NLB ingress rule to the security groupboolfalseno
volumesTask volume definitions as list of configuration objects
list(object({
host_path = string
name = string
docker_volume_configuration = list(object({
autoprovision = bool
driver = string
driver_opts = map(string)
labels = map(string)
scope = string
}))
efs_volume_configuration = list(object({
file_system_id = string
root_directory = string
transit_encryption = string
transit_encryption_port = string
authorization_config = list(object({
access_point_id = string
iam = string
}))
}))
}))
[]no
vpc_idThe VPC ID where resources are createdstringn/ayes
webhook_authenticationThe type of authentication to use. One of IP, GITHUB_HMAC, or UNAUTHENTICATEDstring"GITHUB_HMAC"no
webhook_enabledSet to false to prevent the module from creating any webhook resourcesbooltrueno
webhook_filter_json_pathThe JSON path to filter onstring"$.ref"no
webhook_filter_match_equalsThe value to match on (e.g. refs/heads/{Branch})string"refs/heads/{Branch}"no
webhook_target_actionThe name of the action in a pipeline you want to connect to the webhook. The action must be from the source (first) stage of the pipelinestring"Source"no

Outputs

NameDescription
alb_ingressAll outputs from module.alb_ingress
alb_ingress_target_group_arnALB Target Group ARN
alb_ingress_target_group_arn_suffixALB Target Group ARN suffix
alb_ingress_target_group_nameALB Target Group name
alb_target_group_cloudwatch_sns_alarmsAll outputs from module.alb_target_group_cloudwatch_sns_alarms
cloudwatch_log_groupAll outputs from aws_cloudwatch_log_group.app
cloudwatch_log_group_arnCloudwatch log group ARN
cloudwatch_log_group_nameCloudwatch log group name
codebuildAll outputs from module.ecs_codepipeline
codebuild_badge_urlThe URL of the build badge when badge_enabled is enabled
codebuild_cache_bucket_arnCodeBuild cache S3 bucket ARN
codebuild_cache_bucket_nameCodeBuild cache S3 bucket name
codebuild_project_idCodeBuild project ID
codebuild_project_nameCodeBuild project name
codebuild_role_arnCodeBuild IAM Role ARN
codebuild_role_idCodeBuild IAM Role ID
codepipeline_arnCodePipeline ARN
codepipeline_idCodePipeline ID
codepipeline_webhook_idThe CodePipeline webhook's ID
codepipeline_webhook_urlThe CodePipeline webhook's URL. POST events to this endpoint to trigger the target
container_definitionAll outputs from module.container_definition
container_definition_jsonJSON encoded list of container definitions for use with other terraform resources such as aws_ecs_task_definition
container_definition_json_mapJSON encoded container definitions for use with other terraform resources such as aws_ecs_task_definition
ecrAll outputs from module.ecr
ecr_registry_idRegistry ID
ecr_registry_urlRepository URL
ecr_repository_arnARN of ECR repository
ecr_repository_nameRegistry name
ecr_repository_urlRepository URL
ecs_alarmsAll outputs from module.ecs_cloudwatch_sns_alarms
ecs_alarms_cpu_utilization_high_cloudwatch_metric_alarm_arnECS CPU utilization high CloudWatch metric alarm ARN
ecs_alarms_cpu_utilization_high_cloudwatch_metric_alarm_idECS CPU utilization high CloudWatch metric alarm ID
ecs_alarms_cpu_utilization_low_cloudwatch_metric_alarm_arnECS CPU utilization low CloudWatch metric alarm ARN
ecs_alarms_cpu_utilization_low_cloudwatch_metric_alarm_idECS CPU utilization low CloudWatch metric alarm ID
ecs_alarms_memory_utilization_high_cloudwatch_metric_alarm_arnECS Memory utilization high CloudWatch metric alarm ARN
ecs_alarms_memory_utilization_high_cloudwatch_metric_alarm_idECS Memory utilization high CloudWatch metric alarm ID
ecs_alarms_memory_utilization_low_cloudwatch_metric_alarm_arnECS Memory utilization low CloudWatch metric alarm ARN
ecs_alarms_memory_utilization_low_cloudwatch_metric_alarm_idECS Memory utilization low CloudWatch metric alarm ID
ecs_alb_service_taskAll outputs from module.ecs_alb_service_task
ecs_cloudwatch_autoscalingAll outputs from module.ecs_cloudwatch_autoscaling
ecs_cloudwatch_autoscaling_scale_down_policy_arnARN of the scale down policy
ecs_cloudwatch_autoscaling_scale_up_policy_arnARN of the scale up policy
ecs_exec_role_policy_idThe ECS service role policy ID, in the form of role_name:role_policy_name
ecs_exec_role_policy_nameECS service role name
ecs_service_arnECS Service ARN
ecs_service_nameECS Service name
ecs_service_role_arnECS Service role ARN
ecs_service_security_group_idSecurity Group ID of the ECS task
ecs_task_definition_familyECS task definition family
ecs_task_definition_revisionECS task definition revision
ecs_task_exec_role_arnECS Task exec role ARN
ecs_task_exec_role_nameECS Task role name
ecs_task_role_arnECS Task role ARN
ecs_task_role_idECS Task role id
ecs_task_role_nameECS Task role name
httpcode_elb_5xx_count_cloudwatch_metric_alarm_arnALB 5xx count CloudWatch metric alarm ARN
httpcode_elb_5xx_count_cloudwatch_metric_alarm_idALB 5xx count CloudWatch metric alarm ID
httpcode_target_3xx_count_cloudwatch_metric_alarm_arnALB Target Group 3xx count CloudWatch metric alarm ARN
httpcode_target_3xx_count_cloudwatch_metric_alarm_idALB Target Group 3xx count CloudWatch metric alarm ID
httpcode_target_4xx_count_cloudwatch_metric_alarm_arnALB Target Group 4xx count CloudWatch metric alarm ARN
httpcode_target_4xx_count_cloudwatch_metric_alarm_idALB Target Group 4xx count CloudWatch metric alarm ID
httpcode_target_5xx_count_cloudwatch_metric_alarm_arnALB Target Group 5xx count CloudWatch metric alarm ARN
httpcode_target_5xx_count_cloudwatch_metric_alarm_idALB Target Group 5xx count CloudWatch metric alarm ID
target_response_time_average_cloudwatch_metric_alarm_arnALB Target Group response time average CloudWatch metric alarm ARN
target_response_time_average_cloudwatch_metric_alarm_idALB Target Group response time average CloudWatch metric alarm ID