Skip to content

Instantly share code, notes, and snippets.

[
{
"name": "${definition_name}",
"image": "${image_tag}",
"cpu": 64,
"memory": 256,
"memoryReservation": 128,
"essential": true,
"logConfiguration": {
"logDriver": "awslogs",
resource "aws_cloudwatch_event_rule" "scheduled_task" {
name = "scheduled-ecs-event-rule"
schedule_expression = "rate(5 minutes)"
}
resource "aws_cloudwatch_event_target" "scheduled_task" {
target_id = "$scheduled-ecs-target"
rule = aws_cloudwatch_event_rule.scheduled_task.name
arn = aws_ecs_cluster.cluster.arn
role_arn = aws_iam_role.scheduled_task_cloudwatch.arn
ecs_target {
task_count = 1
task_definition_arn = aws_ecs_task_definition.definition.arn
launch_type = "FARGATE"
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecs:RunTask"
],
"Resource": [
"${replace(aws_ecs_task_definition.definition.arn, "/:\\d+$/", ":*")}"