Skip to content

AWS SNS Subscriptions: missing match_suffixes argument #28765

@wdesouza

Description

@wdesouza

Describe the feature

I've been working with AWS SNS Filter Policy and CDK for Python. I noticed that there are no parameter to set suffixes, only prefixes. Is there any way to pass policy as dict?

Use Case

Code snippet

# topic - sns.Topic
# fn - _lambda.Function

filter_policy = {
    "key": sns.SubscriptionFilter.string_filter(
        match_suffixes=[".fastq", ".fastq.gz"] # param doesn't exist
    )
}
topic.add_subscription(
    subscriptions.LambdaSubscription(fn, filter_policy=filter_policy)
)

Proposed Solution

Maybe to include match_suffixes in future releases; or a way to pass filter policy as dict.
I am using CfnSubscription as workaround.

filter_policy = {"key": [{"suffix": ".fastq"}, {"suffix": ".fastq.gz"}]}
sns.CfnSubscription(
    self,
    "SubscriptionExample",
    topic_arn=topic.topic_arn,
    filter_policy=filter_policy,
    protocol="lambda",
    endpoint=fn.function_arn,
)

# I don't know how to use fn.grant_invoke on topic
lambda_.CfnPermission(
    self,
    "LambdaPermission",
    action="lambda:InvokeFunction",
    function_name=fn.function_arn,
    principal="sns.amazonaws.com",
    source_arn=topic.topic_arn,
)

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.122.0 (build 7e77e02)

Environment details (OS name and version, etc.)

macOS, Python 3.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-snsRelated to Amazon Simple Notification Serviceeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions