File tree 9 files changed +40
-40
lines changed
9 files changed +40
-40
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ data "aws_iam_policy_document" "execution_role" {
13
13
resource "aws_iam_role" "task_execution_role" {
14
14
name = " ${ local . name } -execution-role"
15
15
assume_role_policy = data. aws_iam_policy_document . execution_role . json
16
+ tags = local. tags
16
17
}
17
18
18
19
# TODO(mbarrien): We can probably narrow this down to allowing access to only
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ resource "aws_iam_role" "task_execution_role" {
13
13
count = var. registry_secretsmanager_arn != null ? 1 : 0
14
14
name = " ${ local . name } -execution-role"
15
15
assume_role_policy = data. aws_iam_policy_document . execution_role . json
16
+ tags = local. tags
16
17
}
17
18
18
19
# TODO(mbarrien): We can probably narrow this down to allowing access to only
Original file line number Diff line number Diff line change @@ -24,21 +24,12 @@ data "aws_route53_zone" "zone" {
24
24
private_zone = false
25
25
}
26
26
27
- data "aws_iam_policy_document" "assume_role" {
28
- statement {
29
- principals {
30
- type = "Service"
31
- identifiers = ["ecs-tasks.amazonaws.com"]
32
- }
33
-
34
- actions = ["sts:AssumeRole"]
35
- }
36
- }
37
-
38
- resource "aws_iam_role" "role" {
39
- name = "${var.project}-${var.env}-myservice"
40
- description = "Task role for myservice in ${var.env} environment"
41
- assume_role_policy = data.aws_iam_policy_document.assume_role.json
27
+ module "role" {
28
+ source = "github.com/chanzuckerberg/cztack//aws-iam-ecs-task-role?ref=v0.21.3"
29
+ project = var.project
30
+ env = var.env
31
+ service = var.component
32
+ owner = var.owner
42
33
}
43
34
44
35
module "role-policy" {
@@ -47,7 +38,7 @@ module "role-policy" {
47
38
env = var.env
48
39
service = var.component
49
40
region = var.region
50
- role_name = aws_iam_role .role.name
41
+ role_name = module .role.name
51
42
}
52
43
53
44
# This will define a task that runs this (example) container.
@@ -126,7 +117,7 @@ module "web-service" {
126
117
task_definition = local.template
127
118
128
119
# The task is given this role. Useful for services that need to make API calls to AWS.
129
- task_role_arn = aws_iam_role .role.arn
120
+ task_role_arn = module .role.arn
130
121
131
122
cpu = 256
132
123
memory = 512
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ data "aws_iam_policy_document" "execution_role" {
13
13
resource "aws_iam_role" "task_execution_role" {
14
14
name = " ${ local . name } -execution-role"
15
15
assume_role_policy = data. aws_iam_policy_document . execution_role . json
16
+ tags = local. tags
16
17
}
17
18
18
19
# TODO: Add support for giving permissions to ECR ARNs and possibly cloudwatch log group
Original file line number Diff line number Diff line change @@ -20,21 +20,12 @@ data "aws_route53_zone" "zone" {
20
20
private_zone = false
21
21
}
22
22
23
- data "aws_iam_policy_document" "assume_role" {
24
- statement {
25
- principals {
26
- type = "Service"
27
- identifiers = ["ecs-tasks.amazonaws.com"]
28
- }
29
-
30
- actions = ["sts:AssumeRole"]
31
- }
32
- }
33
-
34
- resource "aws_iam_role" "role" {
35
- name = "${var.project}-${var.env}-myservice"
36
- description = "Task role for myservice in ${var.env} environment"
37
- assume_role_policy = data.aws_iam_policy_document.assume_role.json
23
+ module "role" {
24
+ source = "github.com/chanzuckerberg/cztack//aws-iam-ecs-task-role?ref=v0.21.3"
25
+ project = var.project
26
+ env = var.env
27
+ service = var.component
28
+ owner = var.owner
38
29
}
39
30
40
31
module "role-policy" {
@@ -43,7 +34,7 @@ module "role-policy" {
43
34
env = var.env
44
35
service = var.component
45
36
region = var.region
46
- role_name = aws_iam_role .role.name
37
+ role_name = module .role.name
47
38
}
48
39
49
40
# This will define a task that runs this (example) container.
@@ -121,7 +112,7 @@ module "web-service" {
121
112
task_definition = local.template
122
113
123
114
# The task is given this role. Useful for services that need to make API calls to AWS.
124
- task_role_arn = aws_iam_role .role.arn
115
+ task_role_arn = module .role.arn
125
116
126
117
with_service_discovery = true
127
118
}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ resource "aws_iam_role" "task_execution_role" {
13
13
count = var. registry_secretsmanager_arn != null ? 1 : 0
14
14
name = " ${ local . name } -execution-role"
15
15
assume_role_policy = data. aws_iam_policy_document . execution_role . json
16
+ tags = local. tags
16
17
}
17
18
18
19
# TODO: Add support for giving permissions to ECR ARNs and possibly cloudwatch log group
Original file line number Diff line number Diff line change
1
+ locals {
2
+ tags = {
3
+ Name = " ${ var . project } -${ var . env } -${ var . service } "
4
+ project = var.project
5
+ env = var.env
6
+ service = var.service
7
+ owner = var.owner
8
+ managedBy = " terraform"
9
+ }
10
+ }
11
+
1
12
data "aws_iam_policy_document" "role" {
2
13
statement {
3
14
principals {
@@ -12,6 +23,7 @@ data "aws_iam_policy_document" "role" {
12
23
resource "aws_iam_role" "role" {
13
24
name = " ${ var . project } -${ var . env } -${ var . service } "
14
25
description = " Task role for ${ var . service } task in ${ var . project } -${ var . env } . Owned by ${ var . owner } ."
15
- assume_role_policy = " ${ data . aws_iam_policy_document . role . json } "
16
- path = " ${ var . iam_path } "
26
+ assume_role_policy = data. aws_iam_policy_document . role . json
27
+ path = var. iam_path
28
+ tags = local. tags
17
29
}
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ resource "aws_iam_role" "bless" {
59
59
name_prefix = " ${ local . name } -"
60
60
path = " ${ var . iam_path } "
61
61
assume_role_policy = " ${ data . aws_iam_policy_document . assume_role . json } "
62
+ tags = local. tags
62
63
}
63
64
64
65
resource "aws_iam_role_policy" "lambda" {
@@ -68,7 +69,7 @@ resource "aws_iam_role_policy" "lambda" {
68
69
}
69
70
70
71
module "logs_policy" {
71
- source = " github.com/chanzuckerberg/cztack// aws-iam-policy-cwlogs?ref=v0.14.0 "
72
+ source = " ../ aws-iam-policy-cwlogs"
72
73
role_name = " ${ aws_iam_role . bless . name } "
73
74
iam_path = " ${ var . iam_path } "
74
75
}
Original file line number Diff line number Diff line change @@ -48,9 +48,10 @@ module "attach-logs" {
48
48
}
49
49
50
50
resource "aws_iam_role" "lambda" {
51
- name = " ${ local . name } "
52
- path = " ${ var . iam_path } "
53
- assume_role_policy = " ${ data . aws_iam_policy_document . assume_role . json } "
51
+ name = local. name
52
+ path = var. iam_path
53
+ assume_role_policy = data. aws_iam_policy_document . assume_role . json
54
+ tags = local. tags
54
55
}
55
56
56
57
module "github_secret" {
You can’t perform that action at this time.
0 commit comments