Skip to content

cn-terraform/terraform-aws-ecs-fargate-scheduled-task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 following 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
aws >= 4
local >= 2

Providers

Name Version
aws 5.41.0

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. string 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. string 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. string null no
event_rule_description (Optional) The description of the rule. string 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. string 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. string null no
event_rule_name The name of the rule. string n/a yes
event_rule_role_arn (Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation. string 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. string null no
event_rule_state (Optional) State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. string "ENABLED" 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. string 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_propagate_tags (Optional) Specifies whether to propagate the tags from the task definition to the task. If no value is specified, the tags are not propagated. Tags can only be propagated to the task during task creation. Valid values: TASK_DEFINITION or leave empty to avoid propagation. string "" 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. string n/a yes
event_target_input (Optional) Valid JSON text passed to the target. Conflicts with event_target_input_path. string 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. string null no
event_target_target_id (Optional) The unique target assignment ID. If missing, will generate a random, unique id. string null no
name_prefix Name prefix for resources on AWS. string n/a yes
permissions_boundary (Optional) The ARN of the policy that is used to set the permissions boundary for the role. string null no

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.