File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -148,20 +148,54 @@ data "aws_iam_policy_document" "codebuild" {
148148 ]
149149 }
150150
151+ // https://docs.aws.amazon.com/codebuild/latest/userguide/auth-and-access-control-iam-identity-based-access-control.html#customer-managed-policies-example-create-vpc-network-interface
151152 dynamic "statement" {
152153 for_each = var. vpc == null ? [] : [var . vpc ]
153154 content {
154155 effect = " Allow"
155156 actions = [
156- " ec2:DescribeSecurityGroups" ,
157+ " ec2:CreateNetworkInterface" ,
158+ " ec2:DescribeDhcpOptions" ,
159+ " ec2:DescribeNetworkInterfaces" ,
160+ " ec2:DeleteNetworkInterface" ,
157161 " ec2:DescribeSubnets" ,
162+ " ec2:DescribeSecurityGroups" ,
158163 " ec2:DescribeVpcs"
159164 ]
160165 resources = [
161166 " *"
162167 ]
163168 }
164169 }
170+
171+ dynamic "statement" {
172+ for_each = var. vpc == null ? [] : [var . vpc ]
173+ content {
174+ effect = " Allow"
175+ actions = [
176+ " ec2:CreateNetworkInterfacePermission"
177+
178+ ]
179+ resources = [
180+ " arn:aws:ec2:${ data . aws_region . current . name } :${ data . aws_caller_identity . current . account_id } :network-interface/*"
181+ ]
182+ condition {
183+ test = " StringEquals"
184+ variable = " ec2:AuthorizedService"
185+ values = [
186+ " codebuild.amazonaws.com"
187+ ]
188+ }
189+ condition {
190+ test = " ArnEquals"
191+ variable = " ec2:Subnet"
192+ values = [
193+ for id in var . vpc [" subnets" ] :
194+ " arn:aws:ec2:${ data . aws_region . current . name } :${ data . aws_caller_identity . current . account_id } :subnet/${ id } "
195+ ]
196+ }
197+ }
198+ }
165199}
166200
167201resource "aws_codebuild_report_group" "sast" {
You can’t perform that action at this time.
0 commit comments