-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-sns: When using filterPolicy, stack fails with: FilterPolicyScope: Invalid value [null]. Please use either MessageBody or MessageAttributes #24804
Comments
Hi Unfortunately I can't reproduce your error and was able to deploy it successfully with cdk 2.70.0 with the code below const queue = new sqs.Queue(this, "myQueue", { queueName: 'myQueue' });
const topic = new sns.Topic(this, 'Topic')
const importedtopic = sns.Topic.fromTopicArn(
this,
`myTopic`,
topic.topicArn,
);
importedtopic.addSubscription(
new SqsSubscription(queue, {
filterPolicy: { name: SubscriptionFilter.stringFilter({ allowlist: ["myName"] }) },
}),
); Can you check if the error still exists in 2.70.0 ? |
We saw this error as well. Steps:
We saw the same with:
Stack had the above mentioned error and it seemed unresolvable without deleting the stack and recreating. We had no other FilterPolicyScope defined AFAIK. We were on 2.67.0. |
I've confirmed that the above flows are reproducible in 2.70.0 of aws-cdk. |
@pahud FYI on above comments ^^^ |
Hey @curtisshaffer, when you look at the template output in |
Apologies @MrArnoldPalmer , I'm bogged down and trying to get an example that is simple and doesn't have any of the other connected work I have to show you this. |
This was definitely the issue. Cloudtrail logs indicated that it was trying to:
The first update succeeds, but the latter update fails. Does not appear to be a cdk issue, but a cloudformation issue. |
@curtisshaffer thank you, I'll try to ask around and see what can be done about this. |
@curtisshaffer I confirmed that this is a service issue btw, I'm wondering for workaround purposes, if you do new SqsSubscription(queue, {
filterPolicy: {},
}), If this works? |
Hi, we had just come across this issue. We were trying to convert a subscription from filtering on MessageBody to MessageAttributes (filterPolicyWithMessageBody to filterPolicy). We have tried setting filterPolicy to just {}, but it still errors with "Invalid parameter: FilterPolicyScope: Invalid value [null]. Please use either MessageBody or MessageAttributes (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; ..." while updating the stack. As a workaround, we just commented out the sns subscription resource (so it can get deleted) and then redeployed with the correct subscription and filter to recreate it. Avoids a stack deletion as suggested above. |
@gerarar yeah in most cases it seems like removing a subscription and replacing it should be fairly safe anyway. That likely is the best workaround for now. |
Seems like this problem was fixed. I was having this issue and I was removing and re-adding the subscription as a workaround. But it appears to be fixed. Can anyone confirm? |
Yeah this has been fixed on the service side, closing but please do reopen if you see this again. |
|
@MrArnoldPalmer |
I also encountered this recently (using aws-cdk 2.110.0) |
+1, encountered same issue while removing an sns filter, (using aws-cdk 2.130.0) |
+1, encountered this issue when trying to add a filter to subscription that didn't have one. (using aws-cdk 2.125.0) |
Encountered this today adding an SNS filter policy |
Also encountered this. Though, the description is not exactly what I encountered. I believe the issue is a two-step issue:
The issue appears to be with CloudFormation (though could be fixed from CDK). The change results in a There is a corresponding CloudFormation issue here: aws-cloudformation/cloudformation-coverage-roadmap#1840 |
Describe the bug
After updating cdk lib to 2.68.0, we are unable to deploy stacks that use SNS subscriptions with the
filterPolicy
parameter. Deployment errors out withDeployments were successful before resolving to the new version of the library. There is also no way to specify to use MessageAttributes in
aws-cdk-lib/aws-sns-subscriptions
oraws-cdk-lib/aws-sns
lib.Expected Behavior
The expected behavior is to successfully deploy the stack when using SqsSubscription with filterPolicy prop in v2.68.0 (or later) of aws-cdk-lib.
Current Behavior
The deployment errors out with:
In the cdk.out template, it indeed doesn't have the scope param
Reproduction Steps
Here is how the constructs are set up. I can provide more details if needed.
We tried completely rebuilding everything from scratch and cleaning npm but the stack still fails.
Possible Solution
Replace
undefined
with"MessageAttributes"
here.Additional Information/Context
No response
CDK CLI Version
2.68.0
Framework Version
No response
Node.js Version
16
OS
macOS 12.6
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: