Closed bschug closed 1 year ago
Hi, thanks for reporting this! I can reproduce your issue where the serverless Function isn't accepting the dictionary of values (eg. {before: {owner: ["0x0"]}}
) while placing leaving the policy in the normal CFN resource works.
This seems to be related to the validate of the property (expects the value to be a list of strings or objects). Moving to the SAM repo.
Hi thanks for reporting this bug. This bug is related to wrong validation of FilterPolicy
property. Will create a PR to fix it soon.
@lucashuy The PR linked above is merged and should be rolling out in the upcoming weeks. Going to close this issue. Feel free to re-open or create a new issue if you have additional questions.
Description:
When using the SNS event type in the Events property of an AWS::Serverless::Function, we can define a FilterPolicy. SNS / CloudFormation allow us to build filters that match on nested hierarcies of JSON objects, e.g.
{"status":["confirmed"], "before":{"owner":["0x0"]}}
. SAM fails to create a resource with such a policy. SAM should support any FilterPolicy that is accepted by SNS and/or CloudFormation.The issue does not appear for
{"before": {"owner":["0x0"]}}
or{"status": ["confirmed"]}
. It only appears when mixing different depths in the same policy.Steps to reproduce:
Try do build and deploy a stack like this:
Observed result:
The deployment fails with:
Error: Failed to create changeset for the stack: bugreport, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state: For expression "Status" we matched expected path: "FAILED" Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [ConsumerFunctionSNSEvent] is invalid. Type of property 'FilterPolicy' is invalid.
Expected result:
The deployment succeeds.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Note that the expected stack can be deployed by writing the subscription in plain CloudFormation: