AWS ECS Fargate Scheduled Task Terraform Module

This Terraform module deploys an AWS ECS Fargate scheduled task service.

Usage

Check versions for this module on:

Other modules that you may need to use this module

The Networking module:

The ECS Cluster module:

The ECS Task Definition module:

Install pre commit hooks.

Pleas run this command right after cloning the repository.

    pre-commit install

For that you may need to install the folowwing tools:

In order to run all checks at any point run the following command:

    pre-commit run --all-files

Requirements

Name Version
terraform >= 0.13

Providers

Name Version
aws n/a

Modules

No modules.

Resources

Name Type
aws_cloudwatch_event_rule.event_rule resource
aws_cloudwatch_event_target.ecs_scheduled_task resource
aws_iam_role.scheduled_task_cw_event_role resource
aws_iam_role_policy.scheduled_task_cw_event_role_cloudwatch_policy resource
aws_iam_policy_document.scheduled_task_cw_event_role_assume_role_policy data source
aws_iam_policy_document.scheduled_task_cw_event_role_cloudwatch_policy data source

Inputs

Name Description Type Default Required
ecs_cluster_arn The ECS Cluster where the scheduled task will run any n/a yes
ecs_execution_task_role_arn (Required) The task definition execution role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. any n/a yes
ecs_task_role_arn (Optional) The task definition role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. any null no
event_rule_description (Optional) The description of the rule. any null no
event_rule_event_bus_name (Optional) The event bus to associate with this rule. If you omit this, the default event bus is used. any null no
event_rule_event_pattern (Optional) The event pattern described a JSON object. At least one of schedule_expression or event_pattern is required. any null no
event_rule_is_enabled (Optional) Whether the rule should be enabled (defaults to true). bool true no
event_rule_name The name of the rule. any n/a yes
event_rule_role_arn (Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation. any null no
event_rule_schedule_expression (Optional) The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes). At least one of event_rule_schedule_expression or event_rule_event_pattern is required. Can only be used on the default event bus. any null no
event_target_ecs_target_assign_public_ip (Optional) Assign a public IP address to the ENI. Default false. bool false no
event_target_ecs_target_group (Optional) Specifies an ECS task group for the task. The maximum length is 255 characters. any null no
event_target_ecs_target_platform_version (Optional) Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 1.1.0. For more information about valid platform versions, see AWS Fargate Platform Versions. Default to LATEST string "LATEST" no
event_target_ecs_target_security_groups (Optional) 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(any) null no
event_target_ecs_target_subnets The subnets associated with the task or service. list(any) n/a yes
event_target_ecs_target_task_count (Optional) The number of tasks to create based on the TaskDefinition. The default is 1. number 1 no
event_target_ecs_target_task_definition_arn (Required) The ARN of the task definition to use if the event target is an Amazon ECS cluster. any n/a yes
event_target_input (Optional) Valid JSON text passed to the target. Conflicts with event_target_input_path. any null no
event_target_input_path (Optional) The value of the JSONPath that is used for extracting part of the matched event when passing it to the target. Conflicts with event_target_input. any null no
event_target_target_id (Optional) The unique target assignment ID. If missing, will generate a random, unique id. any null no
name_prefix Name prefix for resources on AWS any n/a yes

Outputs

Name Description
aws_cloudwatch_event_rule_event_rule_arn The Amazon Resource Name (ARN) of the CloudWatch Event Rule.
aws_cloudwatch_event_rule_event_rule_id The name of the rule.
aws_iam_role_policy_scheduled_task_cw_event_role_cloudwatch_policy_id The role policy ID, in the form of role_name:role_policy_name.
aws_iam_role_policy_scheduled_task_cw_event_role_cloudwatch_policy_name The name of the policy.
aws_iam_role_policy_scheduled_task_cw_event_role_cloudwatch_policy_policy The policy document attached to the role.
aws_iam_role_policy_scheduled_task_cw_event_role_cloudwatch_policy_role The name of the role associated with the policy.
scheduled_task_cw_event_role_arn The Amazon Resource Name (ARN) specifying the role.
scheduled_task_cw_event_role_create_date The creation date of the IAM role.
scheduled_task_cw_event_role_description The description of the role.
scheduled_task_cw_event_role_id The name of the role.
scheduled_task_cw_event_role_name The name of the role.
scheduled_task_cw_event_role_unique_id The stable and unique string identifying the role.