A Terraform module to create an ECS Fargate Task Definition which can be scheduled via CloudWatch Events, with the related CloudWatch Log Group and IAM resources.
Available through the Terraform registry.
- You want to create an ECS Fargate Task Definition and schedule its execution via CloudWatch Events.
- You have created a Virtual Private Cloud (VPC) and subnets where you intend to put the ECS resources.
- You have created a NAT Gateway in one of the public subnets of the VPC with necessary routes for traffic from the private subnets (needed for ECR integration).
- You have created an ECS Cluster and a Task Execution IAM Role.
- You have created an ECR Repository containing a Docker image that you want to deploy using the module.
A full example leveraging other community modules is contained in the /examples/complete
directory.
Here's the gist of using it via GitHub source:
module "fargate_task" {
source = "babbel/ecs-fargate-scheduled-task/aws"
region = "eu-west-1"
task_name = "fargate-task"
schedule_expression = "rate(30 minutes)"
ecs_cluster_arn = "my-cluster"
task_execution_role_arn = "arn:aws:iam::123456789012:role/my-task-execution-role"
task_definition = "task-definition.json"
task_policy = "policy.json"
vpc_subnets = ["subnet-123456789abcdefgh", "subnet-abcdefgh123456789"]
vpc_security_groups = ["sg-123456789abcdefgh"]
}
Code formatting and documentation for variables and outputs is generated using pre-commit-terraform hooks which uses terraform-docs.
Follow these instructions to install pre-commit locally.
Report issues/questions/feature requests on in the issues section.
Full contributing guidelines are covered here.
Created by Riccardo Bassetto. Maintained by Mehdi Talbi, Dženan Softić, Andrzej Neumann.
MIT Licensed. See LICENSE for full details.
Name | Description | Type | Default | Required |
---|---|---|---|---|
assign_public_ip | (Optional) Assign a public IP to the EC2 instance running the Fargate task | bool | "false" |
no |
ecs_cluster_arn | (Required) ARN of the ECS Cluster where to deploy the Fargate task | string | n/a | yes |
logs_retention_days | (Optional) Retention days for logs of the Fargate task log group | number | "14" |
no |
platform_version | (Optional) Fargate platform version | string | "LATEST" |
no |
region | (Required) AWS region | string | n/a | yes |
schedule_expression | (Required) CRON schedule expression to trigger the Fargate task | string | n/a | yes |
task_cpu | (Optional) CPU value for the Fargate task | number | "256" |
no |
task_definition | (Required) Path to the Task Definition JSON file | string | n/a | yes |
task_execution_role_arn | (Required) ARN of the Task Execution Role for the Fargate task | string | n/a | yes |
task_memory | (Optional) Memory value for the Fargate task | number | "512" |
no |
task_name | (Required) Name of the Fargate task | string | n/a | yes |
task_policy | (Required) Path to the Task IAM Policy JSON file | string | n/a | yes |
vpc_security_groups | (Required) List of security groups for the EC2 instance running the Fargate task | list(string) | n/a | yes |
vpc_subnets | (Required) List of subnets were AWS will spawn an EC2 instance running the Fargate task | list(string) | n/a | yes |
Name | Description |
---|---|
cloudwatch_event_iam_role_arn | ARN of the CloudWatch Events IAM Role |
cloudwatch_event_rule_id | Name of the CloudWatch Events Rule |
cloudwatch_log_group_name | Name of the CloudWatch log group |
scheduled_task_arn | ARN of the scheduled ECS Fargate Task Definition |
scheduled_task_family | Family of the scheduled ECS Fargate Task Definition |
scheduled_task_iam_role_arn | ARN of the ECS Fargate task IAM Role |