-
Notifications
You must be signed in to change notification settings - Fork 374
/
Copy pathmain.tf
35 lines (27 loc) · 916 Bytes
/
main.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
resource "aws_iam_role" "ecs_default_task" {
name = "${var.environment}_${var.cluster}_default_task"
path = "/ecs/"
assume_role_policy = "${file("ecs_default_task.json")}"
}
data "aws_caller_identity" "current" {}
data "aws_region" "current" {
current = true
}
data "template_file" "policy" {
template = "${file("aws_caller_identity.json")}"
vars {
account_id = data.aws_caller_identity.current.account_id
prefix = var.prefix
aws_region = data.aws_region.current.name
}
}
resource "aws_iam_policy" "ecs_default_task" {
name = "${var.environment}_${var.cluster}_ecs_default_task"
path = "/"
policy = data.template_file.policy.rendered
}
resource "aws_iam_policy_attachment" "ecs_default_task" {
name = "${var.environment}_${var.cluster}_ecs_default_task"
roles = ["${aws_iam_role.ecs_default_task.name}"]
policy_arn = aws_iam_policy.ecs_default_task.arn
}