|
@@ -3,12 +3,12 @@
|
|
#-----------------------------------------------------------------------
|
|
#-----------------------------------------------------------------------
|
|
data "aws_iam_policy_document" "codebuild_role_assume_role_policy" {
|
|
data "aws_iam_policy_document" "codebuild_role_assume_role_policy" {
|
|
statement {
|
|
statement {
|
|
- effect = "Allow"
|
|
|
|
|
|
+ effect = "Allow"
|
|
actions = [
|
|
actions = [
|
|
"sts:AssumeRole"
|
|
"sts:AssumeRole"
|
|
]
|
|
]
|
|
principals {
|
|
principals {
|
|
- type = "Service"
|
|
|
|
|
|
+ type = "Service"
|
|
identifiers = [
|
|
identifiers = [
|
|
"codebuild.amazonaws.com",
|
|
"codebuild.amazonaws.com",
|
|
"events.amazonaws.com"
|
|
"events.amazonaws.com"
|
|
@@ -65,43 +65,42 @@ resource "aws_iam_policy" "codebuild_basic_policy" {
|
|
}
|
|
}
|
|
|
|
|
|
data "aws_iam_policy_document" "codebuild_base_policy" {
|
|
data "aws_iam_policy_document" "codebuild_base_policy" {
|
|
|
|
+ # checkov:skip=CKV_AWS_111: see tfsec aws-iam-no-policy-wildcard ignore comment
|
|
statement {
|
|
statement {
|
|
- sid = "WriteCodebuildLogsToCloudwatchLogs"
|
|
|
|
- effect = "Allow"
|
|
|
|
|
|
+ sid = "WriteCodebuildLogsToCloudwatchLogs"
|
|
|
|
+ effect = "Allow"
|
|
resources = [
|
|
resources = [
|
|
"arn:${local.aws_partition}:logs:${local.aws_region}:${local.aws_account}:log-group:/aws/codebuild/*"
|
|
"arn:${local.aws_partition}:logs:${local.aws_region}:${local.aws_account}:log-group:/aws/codebuild/*"
|
|
]
|
|
]
|
|
- actions = [
|
|
|
|
|
|
+ actions = [
|
|
"logs:CreateLogGroup",
|
|
"logs:CreateLogGroup",
|
|
"logs:CreateLogStream",
|
|
"logs:CreateLogStream",
|
|
"logs:PutLogEvents"
|
|
"logs:PutLogEvents"
|
|
]
|
|
]
|
|
}
|
|
}
|
|
|
|
|
|
-# tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
|
|
|
|
+ # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
statement {
|
|
statement {
|
|
- sid = "StoreArtifactsInBucket"
|
|
|
|
- effect = "Allow"
|
|
|
|
-
|
|
|
|
|
|
+ sid = "StoreArtifactsInBucket"
|
|
|
|
+ effect = "Allow"
|
|
resources = [
|
|
resources = [
|
|
"arn:${local.aws_partition}:s3:::xdr-codebuild-artifacts/*"
|
|
"arn:${local.aws_partition}:s3:::xdr-codebuild-artifacts/*"
|
|
]
|
|
]
|
|
- actions = [
|
|
|
|
|
|
+ actions = [
|
|
"s3:PutObject",
|
|
"s3:PutObject",
|
|
"s3:GetObject*",
|
|
"s3:GetObject*",
|
|
"s3:ListBucket"
|
|
"s3:ListBucket"
|
|
]
|
|
]
|
|
}
|
|
}
|
|
|
|
|
|
- # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
|
|
|
|
+ # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
statement {
|
|
statement {
|
|
- sid = "UpdateECRRepos"
|
|
|
|
- effect = "Allow"
|
|
|
|
-
|
|
|
|
|
|
+ sid = "UpdateECRRepos"
|
|
|
|
+ effect = "Allow"
|
|
resources = [
|
|
resources = [
|
|
"*"
|
|
"*"
|
|
]
|
|
]
|
|
- actions = [
|
|
|
|
|
|
+ actions = [
|
|
"ecr:GetAuthorizationToken",
|
|
"ecr:GetAuthorizationToken",
|
|
"ecr:BatchCheckLayerAvailability",
|
|
"ecr:BatchCheckLayerAvailability",
|
|
"ecr:CompleteLayerUpload",
|
|
"ecr:CompleteLayerUpload",
|
|
@@ -112,14 +111,14 @@ data "aws_iam_policy_document" "codebuild_base_policy" {
|
|
]
|
|
]
|
|
}
|
|
}
|
|
|
|
|
|
-# tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
|
|
|
|
+ # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
statement {
|
|
statement {
|
|
- sid = "LetEventBridgeTriggerABuild"
|
|
|
|
- effect = "Allow"
|
|
|
|
|
|
+ sid = "LetEventBridgeTriggerABuild"
|
|
|
|
+ effect = "Allow"
|
|
resources = [
|
|
resources = [
|
|
"*"
|
|
"*"
|
|
]
|
|
]
|
|
- actions = [
|
|
|
|
|
|
+ actions = [
|
|
"codebuild:StartBuild",
|
|
"codebuild:StartBuild",
|
|
"codebuild:StopBuild",
|
|
"codebuild:StopBuild",
|
|
"codebuild:BatchGet*",
|
|
"codebuild:BatchGet*",
|
|
@@ -147,8 +146,12 @@ resource "aws_iam_policy" "codebuild_build_ec2_amis_policy" {
|
|
policy = data.aws_iam_policy_document.codebuild_build_ec2_amis.json
|
|
policy = data.aws_iam_policy_document.codebuild_build_ec2_amis.json
|
|
}
|
|
}
|
|
|
|
|
|
-# tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
|
|
data "aws_iam_policy_document" "codebuild_build_ec2_amis" {
|
|
data "aws_iam_policy_document" "codebuild_build_ec2_amis" {
|
|
|
|
+ # checkov:skip=CKV_AWS_107: IAM policies does not allow credentials exposure for ECR
|
|
|
|
+ # checkov:skip=CKV_AWS_109: see tfsec aws-iam-no-policy-wildcard ignore comment
|
|
|
|
+ # checkov:skip=CKV_AWS_110: IAM policies does not allow privilege escalation
|
|
|
|
+ # checkov:skip=CKV_AWS_111: see tfsec aws-iam-no-policy-wildcard ignore comment
|
|
|
|
+ # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
statement {
|
|
statement {
|
|
sid = "BuildEC2AMIFromPackerDocs"
|
|
sid = "BuildEC2AMIFromPackerDocs"
|
|
effect = "Allow"
|
|
effect = "Allow"
|
|
@@ -184,10 +187,10 @@ data "aws_iam_policy_document" "codebuild_build_ec2_amis" {
|
|
]
|
|
]
|
|
}
|
|
}
|
|
|
|
|
|
- # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
|
|
statement {
|
|
statement {
|
|
sid = "BuildEC2WithInstanceRole"
|
|
sid = "BuildEC2WithInstanceRole"
|
|
effect = "Allow"
|
|
effect = "Allow"
|
|
|
|
+ # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
resources = [ "*" ]
|
|
resources = [ "*" ]
|
|
actions = [
|
|
actions = [
|
|
"iam:PassRole"
|
|
"iam:PassRole"
|
|
@@ -206,12 +209,12 @@ data "aws_iam_policy_document" "codebuild_build_ec2_amis" {
|
|
]
|
|
]
|
|
}
|
|
}
|
|
|
|
|
|
-# tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
|
|
|
|
+ # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
statement {
|
|
statement {
|
|
sid = "KMSAccessNeededForEBS"
|
|
sid = "KMSAccessNeededForEBS"
|
|
effect = "Allow"
|
|
effect = "Allow"
|
|
resources = [ "*" ]
|
|
resources = [ "*" ]
|
|
- actions = [
|
|
|
|
|
|
+ actions = [
|
|
"kms:RevokeGrant",
|
|
"kms:RevokeGrant",
|
|
"kms:ListGrants",
|
|
"kms:ListGrants",
|
|
"kms:Decrypt",
|
|
"kms:Decrypt",
|
|
@@ -221,11 +224,12 @@ data "aws_iam_policy_document" "codebuild_build_ec2_amis" {
|
|
]
|
|
]
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
statement {
|
|
statement {
|
|
sid = "SSMCodeBuildPause"
|
|
sid = "SSMCodeBuildPause"
|
|
effect = "Allow"
|
|
effect = "Allow"
|
|
resources = [ "*" ]
|
|
resources = [ "*" ]
|
|
- actions = [
|
|
|
|
|
|
+ actions = [
|
|
"ssmmessages:CreateControlChannel",
|
|
"ssmmessages:CreateControlChannel",
|
|
"ssmmessages:CreateDataChannel",
|
|
"ssmmessages:CreateDataChannel",
|
|
"ssmmessages:OpenControlChannel",
|
|
"ssmmessages:OpenControlChannel",
|
|
@@ -233,12 +237,12 @@ data "aws_iam_policy_document" "codebuild_build_ec2_amis" {
|
|
]
|
|
]
|
|
}
|
|
}
|
|
|
|
|
|
-# tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
|
|
|
|
+ # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
|
|
statement {
|
|
statement {
|
|
sid = "CreateGrantForEBS"
|
|
sid = "CreateGrantForEBS"
|
|
effect = "Allow"
|
|
effect = "Allow"
|
|
resources = ["*"]
|
|
resources = ["*"]
|
|
- actions = [
|
|
|
|
|
|
+ actions = [
|
|
"kms:CreateGrant",
|
|
"kms:CreateGrant",
|
|
]
|
|
]
|
|
condition {
|
|
condition {
|