Skip to content

justtrackio/terraform-aws-ecs-scheduled-app

terraform-aws-ecs-scheduled-app

Terraform module which creates a scheduled ecs app

Requirements

Name Version
terraform >= 1.3.0
aws >= 4.67, != 5.71.0

Providers

Name Version
aws >= 4.67, != 5.71.0

Modules

Name Source Version
container_definition cloudposse/ecs-container-definition/aws 0.58.1
container_definition_fluentbit cloudposse/ecs-container-definition/aws 0.58.1
ecs_label justtrackio/label/null 0.26.0
service_task justtrackio/ecs-scheduled-task/aws 1.3.1
ssm_label justtrackio/label/null 0.26.0
this justtrackio/label/null 0.26.0

Resources

Name Type
aws_cloudwatch_log_group.default resource
aws_ssm_parameter.container_cpu data source
aws_ssm_parameter.container_memory_reservation data source
aws_ssm_parameter.container_tag data source

Inputs

Name Description Type Default Required
additional_tag_map Additional 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
app_image_repository Container registry repository url string "" no
app_image_tag The default container image to use in container definition string null no
attributes ID 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
aws_account_id AWS account id string null no
aws_region AWS region string null no
cloudwatch_event_policy_arns The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. string "" no
cloudwatch_log_group_enabled A boolean to disable cloudwatch log group creation bool true no
container_cpu The 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) number 0 no
container_map_environment The environment variables to pass to the container. This is a map of string: {key: value}. environment overrides map_environment map(string) null no
container_memory The 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) number null no
container_memory_reservation The amount of RAM (Soft Limit) to allow container to use in MB. This value must be less than container_memory if set number 128 no
container_start_timeout Time duration (in seconds) to wait before giving up on resolving dependencies for a container number null no
container_stop_timeout Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own number null no
context Single 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
delimiter Delimiter to be used between ID elements.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
string null no
descriptor_formats Describe 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
ecs_cluster_arn The ECS Cluster ARN where ECS Service will be provisioned string n/a yes
enabled Set to false to prevent the module from creating any resources bool null no
environment ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' string null no
healthcheck A 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
})
null no
id_length_limit Limit 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.
number null no
is_enabled Whether the rule should be enabled. bool true no
label_key_case Controls 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.
string null no
label_order The 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) null no
label_orders Overrides the labels_order for the different labels to modify ID elements appear in the id
object({
cloudwatch = optional(list(string)),
ecs = optional(list(string)),
iam = optional(list(string)),
ssm = optional(list(string))
})
{} no
label_value_case Controls 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.
string null no
labels_as_tags Set 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_type The launch type on which to run your service. Valid values are EC2 and FARGATE string "EC2" no
log_driver The log driver to use for the container. If using Fargate launch type, only supported value is awslogs string "awsfirelens" no
log_retention_in_days The number of days to retain logs for the log group number 1 no
log_router_container_cpu The log router cpu reservation for the ECS task definition string 30 no
log_router_container_memory_reservation The log router cpu reservation for the ECS task definition string 64 no
log_router_essential Determines whether all other containers in a task are stopped, if this container fails or stops for any reason. Due to how Terraform type casts booleans in json it is required to double quote this value bool false no
log_router_image_repository Container registry repository url string "" no
log_router_image_tag The default container image to use in container definition string null no
log_router_map_environment The environment variables to pass to the container. This is a map of string: {key: value}. environment overrides map_environment map(string) null no
log_router_options The log router options to use map(string)
{
"config-file-type": "file",
"config-file-value": "/fluent-bit/etc/extra.conf"
}
no
log_router_stop_timeout Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own number 60 no
log_router_type The log router type to use string "fluentbit" no
map_secrets The secrets variables to pass to the container. This is a map of string: {key: value}. map_secrets overrides secrets map(string) null no
name ID 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.
string null no
namespace ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique string null no
network_mode The network mode to use for the task. This is required to be awsvpc for FARGATE launch_type or null for EC2 launch_type string null no
organizational_unit Usually used to indicate the AWS organizational unit, e.g. 'prod', 'sdlc' string null no
port_gateway Define the gateway port number 8088 no
port_health Define the health port number 8090 no
port_mappings The 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
}))
[] no
port_metadata Define the metadata port number 8070 no
port_profiling Define the profiling port number 8091 no
regex_replace_chars Terraform 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.
string null no
schedule_expression The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes). At least one of schedule_expression or event_pattern is required. Can only be used on the default event bus. string "" no
secrets The secrets to pass to the container. This is a list of maps
list(object({
name = string
valueFrom = string
}))
[] no
security_groups The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used. list(string) [] no
stage ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' string null no
subnet_ids A list of subnet IDs to associate with the task or service list(string) [] no
tags Additional tags (e.g. {'BusinessUnit': 'XYZ'}).
Neither the tag keys nor the tag values will be modified by this module.
map(string) {} no
task_count The number of tasks to create based on the TaskDefinition. number null no
task_cpu The 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) number null no
task_memory The 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) number null no
task_policy_arns A list of IAM Policy ARNs to attach to the generated task role. list(string) [] no
tenant ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for string null no
ulimits The 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
working_directory The working directory to run commands inside the container string "/app" no

Outputs

Name Description
cloudwatch_log_group All outputs from aws_cloudwatch_log_group.default
cloudwatch_log_group_arn Cloudwatch log group ARN
cloudwatch_log_group_name Cloudwatch log group name
container_definition All outputs from module.container_definition
container_definition_json JSON encoded list of container definitions for use with other terraform resources such as aws_task_definition
container_definition_json_map JSON encoded container definitions for use with other terraform resources such as aws_task_definition
exec_role_policy_id The ECS execution role policy ID, in the form of role_name:role_policy_name
exec_role_policy_name The ECS execution role policy name
service_task All outputs from module.service_task
task_definition_family The ECS task definition family
task_definition_revision The ECS task definition revision
task_role_arn The ECS task role ARN
task_role_id The ECS task role id
task_role_name The ECS task role name