Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vvalorous/7a8b5b0946bc8605485b3d0d62662ff2 to your computer and use it in GitHub Desktop.
Save vvalorous/7a8b5b0946bc8605485b3d0d62662ff2 to your computer and use it in GitHub Desktop.
sns_SubscribeAddFilterPolicy.py
#!/usr/bin/env python
import boto3
import json
sns = boto3.client("sns")
topic_arn = "YOUR_SNS_TOPIC"
proto = "http"
endpoint = "YOUR_EDNPOINT"
attributes = {"FilterPolicy": json.dumps({"key": ["foo", "bar"]})}
subscription_resp = sns.subscribe(TopicArn=topic_arn, Protocol=proto, Endpoint=endpoint, Attributes=attributes, ReturnSubscriptionArn=True)
print("\nSUBSCRIBE:\n" + json.dumps(subscription_resp, indent=4))
get_attributes_resp = sns.get_subscription_attributes(SubscriptionArn=subscription_resp["SubscriptionArn"])
print("\nGET_SUBSCRIPTIONS_ATTRIBUTES:\n" + json.dumps(get_attributes_resp, indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment