DEV Community

Tomasz Szuster
Tomasz Szuster

Posted on • Edited on

1

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.

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay