Skip to content
This repository was archived by the owner on Jan 4, 2024. It is now read-only.

s2texperiments/sns-filter-policy

Repository files navigation

#SNS-FILTER-POLICY Cloudformation Custom Resource for SNS Filter Policies

Input:

#required
SubscriptionArn: The subscription which should the filter policy added to
FilterPolicy: List of Attribute/Policy objects

Permission

Sns

  • ListSubscriptionsByTopic

##Example

SnsFilterPolicy: 
  Type: "Custom::SnsFilterPolicy"
  Properties: 
    ServiceToken:
      !Sub |
        arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${LambdaFunctionName}
    SubscriptionArn: arn:to:subscription
    FilterPolicy:
      #Exact matching (whitelisting)
      - Attribute: customer_interests
        Policy: '["rugby"]'
      #Prefix matching
      - Attribute: customer_interests
        Policy: '[{"prefix":"bas"}]'
      #Anything-but matching (blacklisting)
      - Attribute: customer_interests
        Policy: '["customer_interests": [{"anything-but":"rugby"}]'
      # Numeric exact matching
      - Attribute: "price_usd"
        Policy: '[{"numeric":["=",301.5]}]'
      #Range matching
      - Atttribute: "price_usd"
        Policy: '[{"numeric":[">", 0, "<=", 150]}]'
    StackName: 
      Ref: "StackName"      

For more information see https://docs.aws.amazon.com/sns/latest/dg/message-filtering.html

About

Add filter policies to a given subscription

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published