Is this a bug in CDK v2 codebuild.Project() construct? The Docker image parameter gets corrupted.

0

I have this CDKv2 code (fragment shown below):

        const dockerImageUriParameter = ssm.StringParameter
            .fromStringParameterName(
                this, 'DockerImageUriParam', '/codebuild-image-uri');

        const ecrRepo = ecr.Repository.fromRepositoryName(
            this, 'EcrRepo', dockerImageUriParameter.stringValue);

        const dockerImage = codebuild.LinuxBuildImage.fromEcrRepository(ecrRepo);

        const project = new codebuild.Project(this, 'AppCodeBuildProject', {
            projectName: cdk.Stack.of(this).stackName,
            description: 'my Application CodeBuild Project',
            environment: {
                privileged: true,
                computeType: codebuild.ComputeType.MEDIUM,
                buildImage: dockerImage
            },
            ... rest of code omitted for clarity ...

Upon inspection in the AWS Console, I see that the SSM parameter has the correct value, something like:

123456789012.dkr.ecr.us-west-2.amazonaws.com/cdk-xxxxxxxxx-container-assets-123456789012-us-west-2:888888e16a7935f3e9488835692573393ae1372efa06fd469999999999999999

However, the codebuild project gets configured with an incorrect-looking (based on Console inspection) image uri:

123456789012.dkr.ecr.us-west-2.amazonaws.com/123456789012.dkr.ecr.us-west-2.amazonaws.com/cdk-xxxxxxxxx-container-assets-123456789012-us-west-2:888b01e16a7935f3e9488835692573393ae1372efa06fd469999999999999999

Note how part of the URI is repeated.

What is going on here?

1 Answer
1
Accepted Answer

Still unclear whether that was a bug, but this works instead:

        const dockerImageUri = cdk.Fn.importValue('BuilderImageUriExport');
        const dockerImage = codebuild.LinuxBuildImage.fromDockerRegistry(dockerImageUri);
AlexR
answered a month ago
profile picture
EXPERT
reviewed 25 days ago
profile picture
EXPERT
reviewed 25 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions