Skip to content

Instantly share code, notes, and snippets.

@hendrixroa
Last active May 4, 2023 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hendrixroa/2f5cfad3db9501a988e3f495cb61ac17 to your computer and use it in GitHub Desktop.
Save hendrixroa/2f5cfad3db9501a988e3f495cb61ac17 to your computer and use it in GitHub Desktop.
AWS IAM role and policy to perform ECS events task
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