Search code examples
amazon-web-servicesaws-cloudformationaws-codepipeline

Update an existing stack with a new codepipeline


I have a Cloudformation stack in AWS that was originally deployed by a GitHub Workflow. Now I'd like to switch from deploying it with GHA to deploying it with Codepipeline, but even if the stack name is the same and the CDK code hasn't changed, AWS creates a new stack and adds the account name to the beginning of the stack name instead of using the existing one. Is there a way to reuse the existing stack?

Deleting and recreating the stack is not an option for me.


Solution

  • I managed to reuse the existing stack by setting the stackName parameter.

    new MyStack(this, `MyStack-${deployEnv}`, deployEnv, {
      env: {account: this.account, region: this.region},
      stackName: `MyStack-${deployEnv}`
    });