aws / aws/aws-cdk

(aws-cloudfront): Cross-region Lambda Edge fails to execute changeset when CDK deployed with notification-arn

Open
#20,603 2 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-cloudfront @aws-cdk/aws-lambda @aws-cdk/aws-sns bug effort/medium p1
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the bug

Creating a cross-region LambdaEdge resource fails when performing a `cdk deploy` with the `--notification-arn` flag set.

This is particularly a problem when deploying a dependent stack with the param, as it still attempts to apply the notification arn to all.

### Expected Behavior

Cross-region stacks created for LambdaEdge will be created irrespective of whether the stack, or a dependent stack, was deployed using the `notification-arn` flag

### Current Behavior

The deployment fails with the following error:

```
Invalid parameter: TopicArn (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID: 21bd8ae0-bff2-5c5c-84b5-d1f3137f7607; Proxy: null)
```

The same error is provided when manually attempting to execute the newly created changeset in CloudFormation. The changeset cannot be deleted in CloudFormation.

Therefore, subsequent deploys also fail as it states that a change is already in progress.

### Reproduction Steps

1. Create a stack using experimental.EdgeFunction in a region that is not `us-east-1` (e.g. `ap-southeast-2`)
2. Deploy the stack with the notificationArn flag set to a SNS topic in the same region
Example:
```cdk deploy "some-stack-name" --progress=events --require-approval=never --notification-arns=arn:aws:sns:ap-southeast-2:1111111111111:Some-SNS-Topic```

### Possible Solution

### Reason
The SNS topic is invalid for cross region function, as it must be in the same region
### Fix
- Override the created stack to NOT inherit the notification arn from the cdk CLI params
- Provide a way to set the notification ARN programatically

### Additional Information/Context

_No response_

### CDK CLI Version

1.150.0

### Framework Version

_No response_

### Node.js Version

v16.13.2

### OS

MacOS

### Language

Typescript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the deployment with experimental.EdgeFunction in a non-us-east-1 region and the cdk deploy --notification-arns option, then inspect how the cross-region stack and dependent stack receive that setting. Done means the cross-region stack can be created and its changeset executed without applying an invalid regional SNS topic.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.