Skip to content

(aws-events): {EventsPolicyId} already exists in stack Upgrade to 2.117.0 rolls back due duplicate resources #28520

@pgarbe

Description

@pgarbe

Please add your +1 👍 to let us know you have encountered this

Status: RESOLVED

Overview:

#27340 introduced the ability to create multiple event bus policies on a single event bus. To facilitate this, the logical Id was changed from "Policy" to the statementId. This triggers a replacement, which fails in CloudFormation because the statement ID does not change.

Complete Error Message:

MyEventsPolicySid already exists in stack arn:aws:cloudformation:eu-west-1:123456789012:stack/MyStack/...

Workaround:

Solution:

Upgrade to 2.118.0 or higher

Related Issues:


Original Report

Describe the bug

Upgrading to v2.117.0 breaks existing EventBus resources with an attached EventBusPolicy. The stack can't be deployed.

Expected Behavior

Upgrade of CDK versions without breaking changes

Current Behavior

The stack rolls back with a message like this:

MyEventsPolicySid already exists in stack arn:aws:cloudformation:eu-west-1:123456789012:stack/MyStack/...

Reproduction Steps

Create an EventBus and a EventBus policy with CDK < 2.117.0. After updating to 2.117.0 the deployment fails.

Reason:
The PR #27340 changes the logicalId of the policy (from "Policy" to Sid) but keeps the StatementId. The changed logicalId triggers a replacement. But CloudFormation can't create multiple policies with the same StatementId and rolls back.

Possible Solution

Workaround: Rename the Sid of your Policy and CloudFormation can roll out the update.

Possible fix: Ensure that the StatementId changes for existing resources (maybe prefix it or add a hash)

Additional Information/Context

No response

CDK CLI Version

2.117.0

Framework Version

No response

Node.js Version

18

OS

all

Language

TypeScript, Python, .NET, Java, Go

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-eventsRelated to CloudWatch EventsbugThis issue is a bug.effort/smallSmall work item – less than a day of effortmanagement/trackingIssues that track a subject or multiple issuesp0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions