Last active
May 4, 2023 16:34
-
-
Save hendrixroa/2f5cfad3db9501a988e3f495cb61ac17 to your computer and use it in GitHub Desktop.
AWS IAM role and policy to perform ECS events task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_iam_role" "ecs_events" { | |
name = "ecs_events" | |
assume_role_policy = <<DOC | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "", | |
"Effect": "Allow", | |
"Principal": { | |
"Service": "events.amazonaws.com" | |
}, | |
"Action": "sts:AssumeRole" | |
} | |
] | |
} | |
DOC | |
} | |
resource "aws_iam_role_policy" "ecs_events_run_task" { | |
name = "ecs_events_run_task" | |
role = aws_iam_role.ecs_events.id | |
policy = <<DOC | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"ecs:RunTask" | |
], | |
"Resource": [ | |
"*" | |
] | |
}, | |
{ | |
"Effect": "Allow", | |
"Action": "iam:PassRole", | |
"Resource": [ | |
"*" | |
], | |
"Condition": { | |
"StringLike": { | |
"iam:PassedToService": "ecs-tasks.amazonaws.com" | |
} | |
} | |
} | |
] | |
} | |
DOC | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment