I am currently navigating my way through AWS CDK and have hit a roadblock with a specific issue.
My existing CDK code pipeline is successfully deploying a variety of resources to different environments, ultimately reaching production. It utilizes the master branch as its source and currently has a pending prod deployment awaiting production.
To enable developers to continue working, I created a new pipeline that operates on a new branch named dev. This new pipeline is designed to deploy the same set of resources to the same stacks, but exclusively in our development environment.
Upon running the new dev pipeline, I encountered the following error:
Resource handler returned message: "Usage Plan j4p4g2 cannot be added because API Key n8uyhik8h8 cannot reference multiple Usage Plans with the same API Stage: 9i1lnft358:v1 (Service: ApiGateway, Status Code: 409, Request ID: 54889a52-4fb8-4c90-93e5-31c8b1865335, Extended Request ID: null)" (RequestToken: 6fb61327-fa39-b967-8969-639daa658c72, HandlerErrorCode: AlreadyExists)
It appears that despite the identical stack name and resources, it is attempting to add a new usage plan instead of recognizing the existing one.
The second pipeline was created as follows:
if (stackBuildTargetAcct === 'dev') {
new PipelineStack(app, 'PipelineDev', {
environment: 'dev',
stackName: 'dev-build-pipeline',
})
} else if (stackBuildTargetAcct === 'prod') {
new PipelineStack(app, 'Pipeline', {
environment: 'prod',
stackName: 'master-build-pipeline',
})
}
I thought that since the stack names and resources are the same, there should be no need to create a new resource. I suspect it may be related to the 'Pipeline' versus 'PipelineDev' identifiers, but when I change them both to 'Pipeline,' I encounter an error preventing the deployment of the new pipeline:
Pipeline/Pipeline/Pipeline/ArtifactsBucketEncryptionKeyAlias (PipelineArtifactsBucketEncryptionKeyAlias94A07392) alias/codepipeline-pipelinefb9defa0 already exists in stack arn:aws:cloudformation:ap-southeast-2:master-build-pipeline
Any assistance or guidance would be greatly appreciated.