Shows how to use the AWS SDK for Python (Boto3) to work with Amazon Simple Notification Service (Amazon SNS) for below actions:
- Create a topic (CreateTopic)
- Delete a subscription (Unsubscribe)
- Delete a topic (DeleteTopic)
- List the subscribers of a topic (ListSubscriptions)
- List topics (ListTopics)
- Publish an SMS text message (Publish)
- Publish to a topic with subscribed email destination (Publish)
- Set a filter policy (SetSubscriptionAttributes)
- Subscribe an email address to a topic (Subscribe)
The client can be same or different AWS regions (e.g. us-east-1 and eu-central-1) or AWS partitions (e.g. China and Global)
- Read the requirements.txt
- running the following in a virtual environment:
python -m pip install -r requirements.txt
The sns_basics_new.py updates the orignal code sns_basics.py to support set the right AWS region (default is us-west-1
) and AWS profile (change the profile name based on your environment. If you invoke global SNS from China region, you need set the global region credential in the profile) in the code.
python sns_basics_new.py
- Python 3.8 environment
- The sample lambda code sns_basics_lambda.py
- Create the environment variable
PHONE_HNUMBER
andEMAIL_ADDRESS
- Update the code with right AWS region (default is
us-west-1
) - To support invoke global SNS from China region, you need set the global region credential in the Secret Manager global_secret_name (default is
/ses/tokyo/credential
) withAWS_ACCESS_KEY_ID_GLB
andAWS_SECRET_ACCESS_KEY_GLB
- Run the lambda test