-
Notifications
You must be signed in to change notification settings - Fork 7
/
ecs-iam.tf
38 lines (34 loc) · 1.07 KB
/
ecs-iam.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Copyright (C) 2019-2021 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
resource "aws_iam_role" "beekeeper_ecs_task_exec" {
count = var.instance_type == "ecs" ? 1 : 0
name = "${local.instance_alias}-ecs-task-exec-${var.aws_region}"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "beekeeper_ecs_task_exec" {
count = var.instance_type == "ecs" ? 1 : 0
role = aws_iam_role.beekeeper_ecs_task_exec.*.id[0]
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
}
resource "aws_iam_role_policy_attachment" "beekeeper_ecs_task_docker_secrets" {
count = var.docker_registry_auth_secret_name != "" ? 1 : 0
role = aws_iam_role.beekeeper_ecs_task_exec.*.id[0]
policy_arn = aws_iam_policy.beekeeper_ecs_task_exec_docker_registry.*.arn[0]
}