An open API service indexing awesome lists of open source software.

https://github.com/geekcell/terraform-aws-ecs-fargate-eventbridge

Terraform module to run an ECS Fargate periodically via EventBrdige.
https://github.com/geekcell/terraform-aws-ecs-fargate-eventbridge

aws cloudwatch cron docker ecs event eventbridge fargate terraform terraform-module

Last synced: about 1 month ago
JSON representation

Terraform module to run an ECS Fargate periodically via EventBrdige.

Awesome Lists containing this project

README

          

[![Geek Cell GmbH](https://raw.githubusercontent.com/geekcell/.github/main/geekcell-github-banner.png)](https://www.geekcell.io/)

### Code Quality
[![License](https://img.shields.io/github/license/geekcell/terraform-aws-ecs-fargate-eventbridge)](https://github.com/geekcell/terraform-aws-ecs-fargate-eventbridge/blob/master/LICENSE)
[![GitHub release (latest tag)](https://img.shields.io/github/v/release/geekcell/terraform-aws-ecs-fargate-eventbridge?logo=github&sort=semver)](https://github.com/geekcell/terraform-aws-ecs-fargate-eventbridge/releases)
[![Release](https://github.com/geekcell/terraform-aws-ecs-fargate-eventbridge/actions/workflows/release.yaml/badge.svg)](https://github.com/geekcell/terraform-aws-ecs-fargate-eventbridge/actions/workflows/release.yaml)
[![Validate](https://github.com/geekcell/terraform-aws-ecs-fargate-eventbridge/actions/workflows/validate.yaml/badge.svg)](https://github.com/geekcell/terraform-aws-ecs-fargate-eventbridge/actions/workflows/validate.yaml)
[![Lint](https://github.com/geekcell/terraform-aws-ecs-fargate-eventbridge/actions/workflows/linter.yaml/badge.svg)](https://github.com/geekcell/terraform-aws-ecs-fargate-eventbridge/actions/workflows/linter.yaml)

# Terraform AWS ECS Fargate EventBridge

This module creates an AWS EventBridge (formerly known as CloudWatch Events) rule and target to run a task on an
ECS Fargate cluster. This is useful for running tasks periodically, like cleanup CRON jobs.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [assign\_public\_ip](#input\_assign\_public\_ip) | Assign a public IP address to the ENI. | `bool` | `false` | no |
| [container\_overrides](#input\_container\_overrides) | The container overrides for the ECS task. | `list(any)` | `[]` | no |
| [ecs\_cluster\_arn](#input\_ecs\_cluster\_arn) | The ARN of the ECS cluster to run the task in. | `string` | n/a | yes |
| [ecs\_target\_group](#input\_ecs\_target\_group) | The name of the ECS task group for the task. | `string` | `null` | no |
| [enable\_ecs\_managed\_tags](#input\_enable\_ecs\_managed\_tags) | Specifies whether to enable Amazon ECS managed tags for the task. | `bool` | `false` | no |
| [enable\_execute\_command](#input\_enable\_execute\_command) | Whether to enable the execute command functionality for the ECS task. | `bool` | `false` | no |
| [platform\_version](#input\_platform\_version) | Platform version on which to run your ECS task. | `string` | `"1.4.0"` | no |
| [propagate\_tags](#input\_propagate\_tags) | Specifies whether to propagate the tags from the task definition the ECS tasks. | `string` | `null` | no |
| [rule\_description](#input\_rule\_description) | Description of the rule. | `string` | `null` | no |
| [rule\_is\_enabled](#input\_rule\_is\_enabled) | Whether the rule is enabled. | `bool` | `true` | no |
| [rule\_name](#input\_rule\_name) | Name of the rule. | `string` | n/a | yes |
| [rule\_role\_arn](#input\_rule\_role\_arn) | The ARN of the IAM role associated with the rule. | `string` | `null` | no |
| [rule\_schedule\_expression](#input\_rule\_schedule\_expression) | The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes). | `string` | n/a | yes |
| [security\_group\_ids](#input\_security\_group\_ids) | Security groups associated with the ECS task. If you do not specify a security group, the default security group for the VPC is used. | `list(string)` | `[]` | no |
| [subnet\_ids](#input\_subnet\_ids) | Subnets associated with the ECS task. | `list(string)` | n/a | yes |
| [tags](#input\_tags) | Tags to add to the created resources. | `map(any)` | `{}` | no |
| [target\_name](#input\_target\_name) | Name of the target. | `string` | n/a | yes |
| [target\_policy\_name](#input\_target\_policy\_name) | The name of the policy to create. | `string` | `null` | no |
| [target\_policy\_name\_prefix](#input\_target\_policy\_name\_prefix) | Whether to use the target\_policy\_name as a prefix or not. | `bool` | `false` | no |
| [target\_role\_name](#input\_target\_role\_name) | The name of the EventBridge target role. | `string` | `null` | no |
| [target\_role\_name\_prefix](#input\_target\_role\_name\_prefix) | Whether to prefix the EventBridge target role name. | `bool` | `false` | no |
| [task\_count](#input\_task\_count) | The number of tasks to create based on the task definition. | `number` | `1` | no |
| [task\_definition\_arn](#input\_task\_definition\_arn) | The ARN of the task definition to use. | `string` | n/a | yes |
| [task\_execution\_role\_arn](#input\_task\_execution\_role\_arn) | The ARN of the IAM role to use as execution role for the ECS task. | `string` | `null` | no |
| [task\_role\_arn](#input\_task\_role\_arn) | The ARN of the IAM role to use as task role for the ECS task. | `string` | `null` | no |
| [use\_rule\_name\_prefix](#input\_use\_rule\_name\_prefix) | Use the `rule_name` attribute as prefix for the rule name. | `bool` | `false` | no |

## Outputs

No outputs.

## Providers

| Name | Version |
|------|---------|
| [aws](#provider\_aws) | >= 4.36 |

## Resources

- resource.aws_cloudwatch_event_rule.main (main.tf#7)
- resource.aws_cloudwatch_event_target.main (main.tf#20)

# Examples
### Complete
```hcl
module "example" {
source = "../../"

rule_name = "run-cleanup-script-on-midnight"
rule_schedule_expression = "cron(0 0 * * ? *)"

target_name = "ecs-fargate-taskdef"

ecs_cluster_arn = "arn:aws:ecs:us-east-1:123456789012:cluster/ecs-cluster"
task_definition_arn = "arn:aws:ecs:us-east-1:123456789012:task-definition/ecs-task"

security_group_ids = ["sg-12345678"]
subnet_ids = [
"subnet-12345678",
"subnet-87654321",
]
}
```