Search code examples
amazon-web-servicesaws-cdkaws-codepipelineaws-codebuild

AWS CodePipeline CDK TypeScript


The install commands in the Build Step of the AWS CodePipeline do not update when there are changes made in the AWS CDK Code (TypeScript) and are pushed to the repository. The Buildspec section under the Build details of the project has the same configuration as when it was created.

Is there a way to fix it? We've made some changes to the BuildStep CDK but does not take effect on the AWS CodeBuild configuration details. I'm only new to AWS CodeBuild and CodePipeline. Any answer/suggestion would be a great help.

Sample Code

const pipeline = new CodePipeline(this, 'SamplePipeline', {
    pipelineName: 'SamplePipeline',
    synth: new CodeBuildStep('BuildSynthStep', {
            input: source,
            buildEnvironment: {
                buildImage: codebuild.LinuxBuildImage.STANDARD_5_0
            },
            installCommands: [
                'install_command_1',
                'install_command_2',
                ...
                'install_command_n'
            ],
            commands: [
                'command_2',
                ...
                'command_n'
            ],
        }
    )
});

Artifact Provider: Amazon S3


Solution

  • The self-mutation of a CDK Pipeline is only applied, when you change something on an application stage (precisely CDK Stage) or other phases after the synth codebuild job.

    If you have something running before, e.g. unit tests, then you won't get into the self-update job.

    So, what are your options now?

    Well, changes according to a pipeline itself are mostly done manually. So you have to re-run a cdk deploy PipelineStack on your local machine with your changes committed to the source branch aside.