You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I successfully created a new CodeBuild project and the resulting default IAM role had two issues that resulted in failed builds (in the PROVISIONING step).
To Reproduce
Using the following CDK code to produce the CodeBuild project in question:
val codeBuildBootstrapProps = CodeBuildBootstrapProps(
stackProps, "https://github.foo.com/me/bar",
"$appName-build-bucket",
ComputeType.Small,
LinuxBuildImage.UBUNTU_18_04_STANDARD_1_0,
vpc
)
CodeBuildBootstrap(app, "code-build-bootstrap", codeBuildBootstrapProps)
val projectName = this.node.getContext("app") as String
val buildEnvironment = BuildEnvironment.builder()
.withComputeType(props.computeType)
.withBuildImage(props.buildImage)
.withPrivileged(false) // true only if used to build Docker images
.build()
val gitHubEnterpriseSourceProps = GitHubEnterpriseSourceProps.builder()
.withCloneDepth(1)
.withHttpsCloneUrl(props.cloneUrl)
.build()
val gitHubEnterpriseSource = GitHubEnterpriseSource(gitHubEnterpriseSourceProps)
val buildBucket = Bucket(
this, "buildbucket", BucketProps.builder()
.withBucketName(props.buildBucketName)
.withRemovalPolicy(RemovalPolicy.Destroy)
.build()
)
val s3BucketBuildArtifactsProps = S3BucketBuildArtifactsProps.builder()
.withName("code-build-artifacts")
.withIdentifier("BuildArtifact")
.withBucket(buildBucket)
.withPath("code-build-artifacts/${projectName}.jar")
.withIncludeBuildId(true)
.build()
val s3BucketBuildArtifacts = S3BucketBuildArtifacts(s3BucketBuildArtifactsProps)
val projectProps = ProjectProps.builder()
.withEnvironment(buildEnvironment)
.withProjectName(projectName)
.withSource(gitHubEnterpriseSource)
.withBuildSpec("buildspec.yml")
.withVpc(props.vpc)
.withArtifacts(NoBuildArtifacts())
.withSecondaryArtifacts(
listOf(
s3BucketBuildArtifacts
)
)
.build()
val project = Project(this, "code-build-project", projectProps)
The first issue is the ec2:DescribeSecurityGroups action was missing on the IAM policy.
I fixed this with the following code:
Describe the bug
I successfully created a new CodeBuild project and the resulting default IAM role had two issues that resulted in failed builds (in the
PROVISIONING
step).To Reproduce
Using the following CDK code to produce the CodeBuild project in question:
The first issue is the
ec2:DescribeSecurityGroups
action was missing on the IAM policy.I fixed this with the following code:
The second issue was that the following snippet was generated:
I fixed by explicitly setting the subnets in the condition clause:
Expected behavior
The default IAM role produced by the CDK should be correct and allow successful build.
Version:
The text was updated successfully, but these errors were encountered: