DEV Community

Tomasz Szuster
Tomasz Szuster

Posted on • Edited on

AWS CDK ARM64 CodeBuild is broken

That's so sad that AWS is not doing a good job with undifferentiated heavy lifting.
A lot of noise but the reality as usual shows what is true.

Below is a simple example of CDK Pipelines which should work


pipelines.CodePipeline(
    self,
    "pipeline",
    self_mutation_code_build_defaults=pipelines.CodeBuildOptions(
        partial_build_spec=codebuild.BuildSpec.from_object(
            {
                "phases": {
                    "install": {
                        "commands": [
                            "npm cache clean -f",
                            "n 16",
                            "node -v",
                        ]
                    }
                }
            }
        )
    ),
    code_build_defaults=pipelines.CodeBuildOptions(
        role_policy=[
            iam.PolicyStatement(actions=["*"], resources=["*"]),
            iam.PolicyStatement(actions=["sts:AssumeRole"], resources=["*"]),
        ],
        build_environment=codebuild.BuildEnvironment(
            compute_type=codebuild.ComputeType.LARGE,
            build_image=codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM_2,
        ),
        partial_build_spec=codebuild.BuildSpec.from_object(
            {
                "phases": {
                    "install": {
                        "commands": [
                            "npm cache clean -f",
                            "n 16",
                            "node -v",
                        ]
                    }
                }
            }
        ),
    ),
    synth=pipelines.ShellStep(
        "synth",
        input=pipelines.CodePipelineSource.connection(
            repo_string=pipeline_vars.github_git_repo,
            branch="main",
            connection_arn=pipeline_vars.github_connection_arn,
        ),
        install_commands=[
            "npm cache clean -f",
            "n 16",
            "node -v",
            "pip install -r requirements.txt",
            "npm install -g aws-cdk",
        ],
        commands=[
            "cdk synth",
        ],
    ),
    pipeline_name=pipeline_vars.project,
    self_mutation=True,
)

Enter fullscreen mode Exit fullscreen mode

What we need to remember is that AWS doesn't provide updated build image that contain supported node version, ideally 16 or 18, but they stick with node 12!

The pipeline above is enforcing node 16 installation for pipeline synth and self-mutation.

Top comments (0)