ecs-service
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 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: false
cluster_attributes: [platform]
## Example task_exec_iam_policy
# task_exec_iam_policy:
# - policy_id: "EcsServiceEchoServer"
# statements:
# - sid: "EcsServiceEchoServer"
# effect: "Allow"
# actions:
# - "kms:Decrypt"
# resources:
# - "*"
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
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
Other Domains
This component supports alternate service names for your ECS Service through a couple of variables:
vanity_domain&vanity_alias- This will create a route to the service in the listener rules of the ALB. This will also create a Route 53 alias record in the hosted zone in this account. The hosted zone is looked up by thevanity_domaininput.additional_targets- This will create a route to the service in the listener rules of the ALB. This will not create a Route 53 alias record.
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: []
Variables
Required Variables
region(string) requiredAWS Region
Optional Variables
additional_lb_target_groupsoptionalAdditional load balancer target group configurations for registering multiple container ports.
This allows you to register sidecar containers to separate target groups.
Each entry requires:- container_name: Name of the container to register
- container_port: Port on the container to register
- target_group_arn: ARN of the target group. Each additional port must specify a unique target group ARN
Type:
list(object({
container_name = string
container_port = number
target_group_arn = string
}))Default value:
[ ]- container_name: Name of the container to register
additional_security_groups(list(string)) optionalA list of additional security group IDs to add to the service
Default value:
[ ]additional_targets(list(string)) optionalAdditional target routes to add to the ALB that point to this service. The only difference between this and
var.vanity_aliasisvar.vanity_aliaswill create an alias record in Route 53 in the hosted zone in this account as well.var.additional_targetsonly adds the listener route to this service's target group.Default value:
[ ]alb_configuration(string) optionalThe configuration to use for the ALB, specifying which cluster alb configuration to use
Default value:
"default"alb_name(string) optionalThe name of the ALB this service should attach to
Default value:
nullautoscaling_dimension(string) optionalThe dimension to use to decide to autoscale
Default value:
"cpu"autoscaling_enabled(bool) optionalShould this service autoscale using SNS alarams
Default value:
truechamber_service(string) optionalSSM parameter service name for use with chamber. This is used in chamber_format where /$chamber_service/$name/$container_name/$parameter would be the default.
Default value:
"ecs-service"cluster_attributes(list(string)) optionalThe attributes of the cluster name e.g. if the full name is
namespace-tenant-environment-dev-ecs-b2bthen thecluster_nameisecsand this value should beb2b.Default value:
[ ]containersoptionalInputs for the container definition module.
user: The user to run as inside the container. Can be any of these formats: user, user:group, uid, uid:gid, user:gid, uid:group. The default (null) will use the container's configuredUSERdirective or root if not set."Type:
map(object({
name = string
ecr_image = optional(string)
image = optional(string)
memory = optional(number)
memory_reservation = optional(number)
cpu = optional(number)
essential = optional(bool, true)
readonly_root_filesystem = optional(bool, null)
privileged = optional(bool, null)
user = optional(string, null)
container_depends_on = optional(list(object({
containerName = string
condition = string # START, COMPLETE, SUCCESS, HEALTHY
})), null)
port_mappings = optional(list(object({
containerPort = number
hostPort = optional(number)
protocol = optional(string)
name = optional(string)
appProtocol = optional(string)
})), [])
command = optional(list(string), null)
entrypoint = optional(list(string), null)
healthcheck = optional(object({
command = list(string)
interval = number
retries = number
startPeriod = number
timeout = number
}), null)
ulimits = optional(list(object({
name = string
softLimit = number
hardLimit = number
})), null)
log_configuration = optional(object({
logDriver = string
options = optional(map(string), {})
}))
docker_labels = optional(map(string), null)
map_environment = optional(map(string), {})
map_secrets = optional(map(string), {})
volumes_from = optional(list(object({
sourceContainer = string
readOnly = bool
})), null)
mount_points = optional(list(object({
sourceVolume = optional(string)
containerPath = optional(string)
readOnly = optional(bool)
})), [])
}))Default value:
{ }cpu_utilization_high_alarm_actions(list(string)) optionalA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization High Alarm action
Default value:
[ ]cpu_utilization_high_evaluation_periods(number) optionalNumber of periods to evaluate for the alarm
Default value:
1cpu_utilization_high_ok_actions(list(string)) optionalA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization High OK action
Default value:
[ ]cpu_utilization_high_period(number) optionalDuration in seconds to evaluate for the alarm
Default value:
300cpu_utilization_high_threshold(number) optionalThe maximum percentage of CPU utilization average
Default value:
80cpu_utilization_low_alarm_actions(list(string)) optionalA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization Low Alarm action
Default value:
[ ]cpu_utilization_low_evaluation_periods(number) optionalNumber of periods to evaluate for the alarm
Default value:
1cpu_utilization_low_ok_actions(list(string)) optionalA list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization Low OK action
Default value:
[ ]cpu_utilization_low_period(number) optionalDuration in seconds to evaluate for the alarm
Default value:
300cpu_utilization_low_threshold(number) optionalThe minimum percentage of CPU utilization average
Default value:
20custom_security_group_rulesoptionalThe list of custom security group rules to add to the service security group
Type:
list(object({
type = string
from_port = number
to_port = number
protocol = string
cidr_blocks = optional(list(string))
description = optional(string)
source_security_group_id = optional(string)
prefix_list_ids = optional(list(string))
security_group_id = optional(string)
}))Default value:
[ ]datadog_agent_sidecar_enabled(bool) optionalEnable the Datadog Agent Sidecar
Default value:
falsedatadog_api_key_ssm_parameter_name(string) optionalThe SSM Parameter Name containing the Datadog API Key
Default value:
nulldatadog_log_method_is_firelens(bool) optionalDatadog logs can be sent via cloudwatch logs (and lambda) or firelens, set this to true to enable firelens via a sidecar container for fluentbit
Default value:
falsedatadog_logging_default_tags_enabled(bool) optionalAdd Default tags to all logs sent to Datadog
Default value:
truedatadog_logging_tags(map(string)) optionalTags to add to all logs sent to Datadog
Default value:
nulldatadog_sidecar_containers_logs_enabled(bool) optionalEnable the Datadog Agent Sidecar to send logs to aws cloudwatch group, requires
datadog_agent_sidecar_enabledto be trueDefault value:
truedatadog_site(string) optionalThe Datadog Site to send logs to
Default value:
"us5.datadoghq.com"ecr_region(string) optionalThe region to use for the fully qualified ECR image URL. Defaults to the current region.
Default value:
""ecr_stage_name(string) optionalThe ecr stage (account) name to use for the fully qualified ECR image URL.
Default value:
"auto"ecs_cluster_name(any) optionalThe name of the ECS Cluster this belongs to
Default value:
"ecs"enable_all_egress_rule(bool) optionalA flag to enable/disable adding the all ports egress rule to the service security group
Default value:
trueexec_enabled(bool) optionalSpecifies whether to enable Amazon ECS Exec for the tasks within the service
Default value:
falsegithub_actions_allowed_repos(list(string)) optionalA list of the GitHub repositories that are allowed to assume this role from GitHub Actions. For example,
["cloudposse/infra-live"]. Can contain "*" as wildcard.
If org part of repo name is omitted, "cloudposse" will be assumed.Default value:
[ ]github_actions_ecspresso_enabled(bool) optionalCreate IAM policies required for deployments with Ecspresso
Default value:
falsegithub_actions_iam_role_attributes(list(string)) optionalAdditional attributes to add to the role name
Default value:
[ ]github_actions_iam_role_enabled(bool) optionalFlag to toggle creation of an IAM Role that GitHub Actions can assume to access AWS resources
Default value:
falsegithub_oidc_trusted_role_arns(list(string)) optionalA list of IAM Role ARNs allowed to assume this cluster's GitHub OIDC role
Default value:
[ ]health_check_healthy_threshold(number) optionalThe number of consecutive health checks successes required before healthy
Default value:
2health_check_interval(number) optionalThe duration in seconds in between health checks
Default value:
15health_check_matcher(string) optionalThe HTTP response codes to indicate a healthy check
Default value:
"200-404"health_check_path(string) optionalThe destination for the health check request
Default value:
"/health"health_check_port(string) optionalThe port to use to connect with the target. Valid values are either ports 1-65536, or
traffic-port. Defaults totraffic-portDefault value:
"traffic-port"health_check_protocol(string) optionalThe protocol to use to connect with the target. Defaults to HTTP. Not applicable when target_type is lambda
Default value:
"HTTP"health_check_timeout(number) optionalThe amount of time to wait in seconds before failing a health check request
Default value:
10health_check_unhealthy_threshold(number) optionalThe number of consecutive health check failures required before unhealthy
Default value:
2http_protocol(string) optionalWhich 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.Default value:
nulliam_policy_enabled(bool) optionalIf set to true will create IAM policy in AWS
Default value:
falseiam_policy_statements(any) optionalMap of IAM policy statements to use in the policy. This can be used with or instead of the
var.iam_source_json_url.Default value:
{ }kinesis_enabled(bool) optionalEnable Kinesis
Default value:
falsekms_alias_name_ssm(string) optionalKMS alias name for SSM
Default value:
"alias/aws/ssm"kms_key_alias(string) optionalID of KMS key
Default value:
"default"lb_catch_all(bool) optionalShould this service act as catch all for all subdomain hosts of the vanity domain
Default value:
falselogs(any) optionalFeed inputs into cloudwatch logs module
Default value:
{ }memory_utilization_high_alarm_actions(list(string)) optionalA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization High Alarm action
Default value:
[ ]memory_utilization_high_evaluation_periods(number) optionalNumber of periods to evaluate for the alarm
Default value:
1memory_utilization_high_ok_actions(list(string)) optionalA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization High OK action
Default value:
[ ]memory_utilization_high_period(number) optionalDuration in seconds to evaluate for the alarm
Default value:
300memory_utilization_high_threshold(number) optionalThe maximum percentage of Memory utilization average
Default value:
80memory_utilization_low_alarm_actions(list(string)) optionalA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization Low Alarm action
Default value:
[ ]memory_utilization_low_evaluation_periods(number) optionalNumber of periods to evaluate for the alarm
Default value:
1memory_utilization_low_ok_actions(list(string)) optionalA list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization Low OK action
Default value:
[ ]memory_utilization_low_period(number) optionalDuration in seconds to evaluate for the alarm
Default value:
300memory_utilization_low_threshold(number) optionalThe minimum percentage of Memory utilization average
Default value:
20nlb_name(string) optionalThe name of the NLB this service should attach to
Default value:
nullport(number) optionalThe port for the created ALB target group. Defaults to 80
Default value:
80protocol(string) optionalThe protocol for the created ALB target group. Defaults to HTTP
Default value:
"HTTP"rds_name(any) optionalThe name of the RDS database this service should allow access to
Default value:
nullretention_period(number) optionalLength of time data records are accessible after they are added to the stream
Default value:
48s3_mirror_name(string) optionalThe name of the S3 mirror component
Default value:
nullscale_down_step_adjustmentsoptionalList of step adjustments for scale down policy
Type:
list(object({
metric_interval_lower_bound = optional(number)
metric_interval_upper_bound = optional(number)
scaling_adjustment = number
}))Default value:
[
{
"metric_interval_lower_bound": null,
"metric_interval_upper_bound": 0,
"scaling_adjustment": -1
}
]scale_up_step_adjustmentsoptionalList of step adjustments for scale up policy
Type:
list(object({
metric_interval_lower_bound = optional(number)
metric_interval_upper_bound = optional(number)
scaling_adjustment = number
}))Default value:
[
{
"metric_interval_lower_bound": 0,
"metric_interval_upper_bound": null,
"scaling_adjustment": 1
}
]service_connect_configurationsoptionalThe list of Service Connect configurations.
Seeservice_connect_configurationdocs https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#service_connect_configurationType:
list(object({
enabled = bool
namespace = optional(string, null)
log_configuration = optional(object({
log_driver = string
options = optional(map(string), null)
secret_option = optional(list(object({
name = string
value_from = string
})), [])
}), null)
service = optional(list(object({
client_alias = list(object({
dns_name = string
port = number
}))
discovery_name = optional(string, null)
ingress_port_override = optional(number, null)
port_name = string
})), [])
}))Default value:
[ ]service_registriesoptionalThe list of Service Registries.
Seeservice_registriesdocs https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#service_registriesType:
list(object({
namespace = string
registry_arn = optional(string)
port = optional(number)
container_name = optional(string)
container_port = optional(number)
}))Default value:
[ ]shard_count(number) optionalNumber of shards that the stream will use
Default value:
1shard_level_metrics(list(string)) optionalList of shard-level CloudWatch metrics which can be enabled for the stream
Default value:
[
"IncomingBytes",
"IncomingRecords",
"IteratorAgeMilliseconds",
"OutgoingBytes",
"OutgoingRecords",
"ReadProvisionedThroughputExceeded",
"WriteProvisionedThroughputExceeded"
]ssm_enabled(bool) optionalIf
truecreate SSM keys for the database user and password.Default value:
falsessm_key_format(string) optionalSSM path format. The values will will be used in the following order:
var.ssm_key_prefix,var.name,var.ssm_key_*Default value:
"/%v/%v/%v"ssm_key_prefix(string) optionalSSM path prefix. Omit the leading forward slash
/.Default value:
"ecs-service"stickiness_cookie_duration(number) optionalThe 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)
Default value:
86400stickiness_enabled(bool) optionalBoolean to enable / disable
stickiness. Default istrueDefault value:
truestickiness_type(string) optionalThe type of sticky sessions. The only current possible value is
lb_cookieDefault value:
"lb_cookie"stream_mode(string) optionalStream mode details for the Kinesis stream
Default value:
"PROVISIONED"taskoptionalFeed inputs into ecs_alb_service_task module
Type:
object({
task_cpu = optional(number)
task_memory = optional(number)
task_role_arn = optional(string, "")
pid_mode = optional(string, null)
ipc_mode = optional(string, null)
network_mode = optional(string)
propagate_tags = optional(string)
assign_public_ip = optional(bool, false)
use_alb_security_groups = optional(bool, true)
launch_type = optional(string, "FARGATE")
scheduling_strategy = optional(string, "REPLICA")
capacity_provider_strategies = optional(list(object({
capacity_provider = string
weight = number
base = number
})), [])
deployment_minimum_healthy_percent = optional(number, null)
deployment_maximum_percent = optional(number, null)
desired_count = optional(number, 0)
min_capacity = optional(number, 1)
max_capacity = optional(number, 2)
wait_for_steady_state = optional(bool, true)
circuit_breaker_deployment_enabled = optional(bool, true)
circuit_breaker_rollback_enabled = optional(bool, true)
ignore_changes_task_definition = optional(bool, true)
ignore_changes_desired_count = optional(bool, false)
ecs_service_enabled = optional(bool, true)
bind_mount_volumes = optional(list(object({
name = string
host_path = string
})), [])
efs_volumes = optional(list(object({
host_path = string
name = 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
}))
}))
})), [])
efs_component_volumes = optional(list(object({
host_path = string
name = string
efs_volume_configuration = list(object({
component = optional(string, "efs")
tenant = optional(string, null)
environment = optional(string, null)
stage = optional(string, null)
root_directory = string
transit_encryption = string
transit_encryption_port = string
authorization_config = list(object({
access_point_id = string
iam = string
}))
}))
})), [])
docker_volumes = optional(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
}))
})), [])
fsx_volumes = optional(list(object({
host_path = string
name = string
fsx_windows_file_server_volume_configuration = list(object({
file_system_id = string
root_directory = string
authorization_config = list(object({
credentials_parameter = string
domain = string
}))
}))
})), [])
})Default value:
{ }task_enabled(bool) optionalWhether or not to use the ECS task module
Default value:
truetask_exec_iam_policyoptionalIAM policy as list of Terraform objects, compatible with Terraform
aws_iam_policy_documentdata source
except thatsource_policy_documentsandoverride_policy_documentsare not included.
Use inputsiam_source_policy_documentsandiam_override_policy_documentsfor that.Type:
list(object({
policy_id = optional(string, null)
version = optional(string, null)
statements = list(object({
sid = optional(string, null)
effect = optional(string, null)
actions = optional(list(string), null)
not_actions = optional(list(string), null)
resources = optional(list(string), null)
not_resources = optional(list(string), null)
conditions = optional(list(object({
test = string
variable = string
values = list(string)
})), [])
principals = optional(list(object({
type = string
identifiers = list(string)
})), [])
not_principals = optional(list(object({
type = string
identifiers = list(string)
})), [])
}))
}))Default value:
[ ]task_exec_policy_arns_map(map(string)) optionalA map of name to IAM Policy ARNs to attach to the generated task execution role.
The names are arbitrary, but must be known at plan time. The purpose of the name
is so that changes to one ARN do not cause a ripple effect on the other ARNs.
If you cannot provide unique names known at plan time, usetask_exec_policy_arnsinstead.Default value:
{ }task_iam_role_component(string) optionalA component that outputs an iam_role module as 'role' for adding to the service as a whole.
Default value:
nulltask_policy_arns(list(string)) optionalThe IAM policy ARNs to attach to the ECS task IAM role
Default value:
[
"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly",
"arn:aws:iam::aws:policy/AmazonSSMReadOnlyAccess"
]task_security_group_component(string) optionalA component that outputs security_group_id for adding to the service as a whole.
Default value:
nullunauthenticated_paths(list(string)) optionalUnauthenticated path pattern to match
Default value:
[ ]unauthenticated_priority(string) optionalThe priority for the rules without authentication, between 1 and 50000 (1 being highest priority). Must be different from
authenticated_prioritysince a listener can't have multiple rules with the same priorityDefault value:
0use_lb(bool) optionalWhether use load balancer for the service
Default value:
falseuse_rds_client_sg(bool) optionalUse the RDS client security group
Default value:
falsevanity_alias(list(string)) optionalThe vanity aliases to use for the public LB.
Default value:
[ ]vanity_domain(string) optionalWhether to use the vanity domain alias for the service
Default value:
nullvpc_component_name(string) optionalThe name of a VPC component
Default value:
"vpc"zone_component(string) optionalThe component name to look up service domain remote-state on
Default value:
"dns-delegated"zone_component_output(string) optionalA json query to use to get the zone domain from the remote state. See
Default value:
".default_domain_name"
Context Variables
The following variables are defined in the context.tf file of this module and part of the terraform-null-label pattern.
context.tf file of this module and part of the terraform-null-label pattern.additional_tag_map(map(string)) optionalAdditional key-value pairs to add to each map in
tags_as_list_of_maps. Not added totagsorid.
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.Required: No
Default value:
{ }attributes(list(string)) optionalID element. Additional attributes (e.g.
workersorcluster) to add toid,
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 thedelimiter
and treated as a single ID element.Required: No
Default value:
[ ]context(any) optionalSingle object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables asnullto use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.Required: No
Default value:
{
"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
}delimiter(string) optionalDelimiter to be used between ID elements.
Defaults to-(hyphen). Set to""to use no delimiter at all.Required: No
Default value:
nulldescriptor_formats(any) optionalDescribe additional descriptors to be output in the
descriptorsoutput map.
Map of maps. Keys are names of descriptors. Values are maps of the form
\{<br/> format = string<br/> labels = list(string)<br/> \}
(Type isanyso the map values can later be enhanced to provide additional options.)
formatis a Terraform format string to be passed to theformat()function.
labelsis a list of labels, in order, to pass toformat()function.
Label values will be normalized before being passed toformat()so they will be
identical to how they appear inid.
Default is{}(descriptorsoutput will be empty).Required: No
Default value:
{ }enabled(bool) optionalSet to false to prevent the module from creating any resources
Required: NoDefault value:
nullenvironment(string) optionalID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'
Required: NoDefault value:
nullid_length_limit(number) optionalLimit
idto this many characters (minimum 6).
Set to0for unlimited length.
Set tonullfor keep the existing setting, which defaults to0.
Does not affectid_full.Required: No
Default value:
nulllabel_key_case(string) optionalControls the letter case of the
tagskeys (label names) for tags generated by this module.
Does not affect keys of tags passed in via thetagsinput.
Possible values:lower,title,upper.
Default value:title.Required: No
Default value:
nulllabel_order(list(string)) optionalThe 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.Required: No
Default value:
nulllabel_value_case(string) optionalControls 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 thetagsinput.
Possible values:lower,title,upperandnone(no transformation).
Set this totitleand setdelimiterto""to yield Pascal Case IDs.
Default value:lower.Required: No
Default value:
nulllabels_as_tags(set(string)) optionalSet of labels (ID elements) to include as tags in the
tagsoutput.
Default is to include all labels.
Tags with empty values will not be included in thetagsoutput.
Set to[]to suppress all generated tags.
Notes:
The value of thenametag, if included, will be theid, not thename.
Unlike othernull-labelinputs, the initial setting oflabels_as_tagscannot be
changed in later chained modules. Attempts to change it will be silently ignored.Required: No
Default value:
[
"default"
]name(string) optionalID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as atag.
The "name" tag is set to the fullidstring. There is no tag with the value of thenameinput.Required: No
Default value:
nullnamespace(string) optionalID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique
Required: NoDefault value:
nullregex_replace_chars(string) optionalTerraform 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.Required: No
Default value:
nullstage(string) optionalID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'
Required: NoDefault value:
nulltags(map(string)) optionalAdditional tags (e.g.
{'BusinessUnit': 'XYZ'}).
Neither the tag keys nor the tag values will be modified by this module.Required: No
Default value:
{ }tenant(string) optionalID element (Rarely used, not included by default). A customer identifier, indicating who this instance of a resource is for
Required: NoDefault value:
null
Outputs
ecs_cluster_arnSelected ECS cluster ARN
environment_mapEnvironment variables to pass to the container, this is a map of key/value pairs, where the key is
containerName,variableNamefull_domainDomain to respond to GET requests
github_actions_iam_role_arnARN of IAM role for GitHub Actions
github_actions_iam_role_nameName of IAM role for GitHub Actions
lb_arnSelected LB ARN
lb_listener_httpsSelected LB HTTPS Listener
lb_sg_idSelected LB SG ID
logsOutput of cloudwatch logs module
service_arnThe ECS service ARN
service_imageThe image of the service container
service_nameThe ECS service name
ssm_key_prefixSSM prefix
ssm_parametersSSM parameters for the ECS Service
subnet_idsSelected subnet IDs
task_definition_arnThe task definition ARN
task_definition_revisionThe task definition revision
task_templateThe task template rendered
vpc_idSelected VPC ID
vpc_sg_idSelected VPC SG ID
Dependencies
Requirements
terraform, version:>= 1.0.0aws, version:>= 4.66.1, < 6.0.0jq, version:>=0.2.0template, version:>= 2.2
Providers
aws, version:>= 4.66.1, < 6.0.0jq, version:>=0.2.0template, version:>= 2.2
Modules
Resources
The following resources are used by this module:
aws_iam_policy.default(resource)aws_iam_role.github_actions(resource)aws_iam_role_policy.github_actions(resource)aws_iam_role_policy_attachment.additional_exec(resource)aws_iam_role_policy_attachment.custom_exec(resource)aws_kinesis_stream.default(resource)aws_s3_object.task_definition_template(resource)aws_security_group_rule.custom_sg_rules(resource)aws_service_discovery_service.default(resource)aws_ssm_parameter.full_urls(resource)
Data Sources
The following data sources are used by this module:
aws_caller_identity.current(data source)aws_ecs_task_definition.created_task(data source)aws_iam_policy_document.github_actions_iam_ecspresso_policy(data source)aws_iam_policy_document.github_actions_iam_platform_policy(data source)aws_iam_policy_document.github_actions_iam_policy(data source)aws_iam_policy_document.this(data source)aws_kms_alias.selected(data source)aws_route53_zone.selected(data source)aws_route53_zone.selected_vanity(data source)aws_s3_object.task_definition(data source)aws_s3_objects.mirror(data source)aws_ssm_parameter.datadog_api_key(data source)aws_ssm_parameters_by_path.default(data source)jq_query.service_domain_query(data source)template_file.envs(data source)