Pretty new to AWS CDK and am getting stuck with a certain issue.
I have a working CDK code pipeline deploying a bunch of resources to different environments, eventually making its way to prod. It uses master as its source branch and is currently has a prod deployment waiting to make it into production.
In order to allow devs to keep working I created a new pipeline which works on a new branch called dev but is meant to deploy the same resources to the same stacks but only in our dev environment.
Once the new dev pipeline runs I get the 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 seems that despite the same stack name and resources it is trying to add a new usage plan instead of accept the existing one
Second pipeline created like so
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 figured that is the stack name is the same and the resources are the same why would it think it needs to create a new resource? I suspect its the 'Pipeline' vs 'PipelineDev' id but when I change them both to 'Pipeline', I can't deploy the new pipeline due to the following error
Pipeline/Pipeline/Pipeline/ArtifactsBucketEncryptionKeyAlias (PipelineArtifactsBucketEncryptionKeyAlias94A07392) alias/codepipeline-pipelinefb9defa0 already exists in stack arn:aws:cloudformation:ap-southeast-2:master-build-pipeline
Any help or advice appreciated