Skip to content

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

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 >= 1.5.7
aws ~>6

Providers

Name Version
aws 6.33.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
aws_iam_policy_document.scheduled_task_cw_event_role_pass_role_policy data source
aws_iam_policy_document.scheduled_task_cw_event_role_run_ecs_tasks_policy data source

Inputs

Name Description Type Default Required
additional_tags (Optional) Additional tags to add to resources. These will be merged with the default tags added by the module. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level. map(string) {} no
ecs_execution_task_role_arn (Optional) 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 null no
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 name or ARN of 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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. string null no
event_rule_force_destroy (Optional) Used to delete managed rules created by AWS. Defaults to false. bool false no
event_rule_name The name of the rule. If omitted, Terraform will assign a random, unique name. Conflicts with name_prefix. string n/a yes
event_rule_role_arn (Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation. If not set a role will be created with the necessary permissions to invoke the target when the rule is triggered. string null no
event_rule_schedule_expression (Optional) 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 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_cluster_arn The ECS Cluster where the scheduled task will run. string n/a yes
event_target_ecs_target_additional_tags (Optional) Additional tags to add to the ECS target. These will be merged with the default tags added by the module and the additional_tags variable. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level. map(string) {} no
event_target_ecs_target_assign_public_ip (Optional) Assign a public IP address to the ENI. Valid values are true or false. Defaults to false. bool false no
event_target_ecs_target_enable_ecs_managed_tags (Optional) Specifies whether to enable Amazon ECS managed tags for the task. bool false no
event_target_ecs_target_enable_execute_command (Optional) Whether or not to enable the execute command functionality for the containers in this task. If true, this enables execute command functionality on all containers in the task. 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. The only valid value is: TASK_DEFINITION. 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(string) null no
event_target_ecs_target_subnets (Required) The subnets associated with the task or service. list(string) n/a yes
event_target_ecs_target_task_count (Optional) The number of tasks to create based on the TaskDefinition. Defaults to 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_force_destroy (Optional) Used to delete managed rules created by AWS. Defaults to false. bool false no
event_target_input (Optional) Valid JSON text passed to the target. Conflicts with event_target_input_path and event_target_input_transformer. 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 and event_target_input_transformer. string null no
event_target_input_transformer (Optional) Parameters used when you are providing a custom event_target_input to a target based on certain event data. Conflicts with input and event_target_input_path.
object({
input_template = string
input_paths = optional(map(string))
})
null no
event_target_retry_policy_maximum_event_age_in_seconds (Optional) The age in seconds to continue to make retry attempts. number null no
event_target_retry_policy_maximum_retry_attempts (Optional) maximum number of retry attempts to make before the request fails. number 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_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.
cloudwatch_event_role Values from the created CloudWatch Event Role. Will be null if using a custom role ARN.
cloudwatch_event_rule Values from the created CloudWatch Event Rule.
cloudwatch_event_target Values from the created CloudWatch Event Target.
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.

Sponsor this project

Packages

 
 
 

Contributors

Languages