@@ -67,16 +67,14 @@ data "aws_iam_policy_document" "functions" {
67
67
}
68
68
69
69
resource "aws_iam_policy" "ecr_scanning" {
70
- count = var. is_organizational ? 0 : 1
71
-
72
70
name = " ${ local . ecr_role_name } -ecr"
73
71
description = " Grants Sysdig Secure access to ECR images"
74
72
policy = data. aws_iam_policy_document . scanning . json
75
73
tags = var. tags
76
74
}
77
75
78
76
resource "aws_iam_policy" "functions_scanning" {
79
- count = var. lambda_scanning_enabled && ! var . is_organizational ? 1 : 0
77
+ count = var. lambda_scanning_enabled ? 1 : 0
80
78
81
79
name = " ${ local . ecr_role_name } -functions"
82
80
description = " Grants Sysdig Secure access to AWS Lambda"
@@ -108,26 +106,22 @@ data "aws_iam_policy_document" "scanning_assume_role_policy" {
108
106
}
109
107
110
108
resource "aws_iam_role" "scanning" {
111
- count = var. is_organizational ? 0 : 1
112
-
113
109
name = local. ecr_role_name
114
110
tags = var. tags
115
111
assume_role_policy = data. aws_iam_policy_document . scanning_assume_role_policy . json
116
112
}
117
113
118
114
resource "aws_iam_policy_attachment" "scanning" {
119
- count = var. is_organizational ? 0 : 1
120
-
121
115
name = local. ecr_role_name
122
- roles = [aws_iam_role . scanning [ 0 ] . name ]
123
- policy_arn = aws_iam_policy. ecr_scanning [ 0 ] . arn
116
+ roles = [aws_iam_role . scanning . name ]
117
+ policy_arn = aws_iam_policy. ecr_scanning . arn
124
118
}
125
119
126
120
resource "aws_iam_policy_attachment" "functions" {
127
- count = var. lambda_scanning_enabled && ! var . is_organizational ? 1 : 0
121
+ count = var. lambda_scanning_enabled ? 1 : 0
128
122
129
123
name = local. ecr_role_name
130
- roles = [aws_iam_role . scanning [ 0 ] . name ]
124
+ roles = [aws_iam_role . scanning . name ]
131
125
policy_arn = aws_iam_policy. functions_scanning [0 ]. arn
132
126
}
133
127
@@ -145,7 +139,7 @@ resource "sysdig_secure_cloud_auth_account_component" "vm_workload_scanning_acco
145
139
version = " v0.1.0"
146
140
trusted_role_metadata = jsonencode ({
147
141
aws = {
148
- role_name = aws_iam_role.scanning[ 0 ] .name
142
+ role_name = aws_iam_role.scanning.name
149
143
}
150
144
})
151
145
0 commit comments