Amazon Simple Notification Service Command Lines


Hits: 671  

Install the AWS CLI Using the Bundled Installer

Download the AWS CLI Bundled Installer.

# curl “https://s3.amazonaws.com/aws-cli/awscli-bundle.zip” -o “awscli-bundle.zip”
# unzip awscli-bundle.zip
# chmod a+x ./awscli-bundle/install
# ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Configure AWS CLI

# aws configure
AWS Access Key ID [None]: XXXXXXXXXXXXXXXXXXXXX
AWS Secret Access Key [None]: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Default region name [None]: us-east-1
Default output format [None]: json

# cat ~/.aws/credentials

[default]
aws_access_key_id=XXXXXXXXXXXXXXXXXXXXX
aws_secret_access_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

# cat ~/.aws/config

[default]
region=us-east-1
output=json

AWS SNS Common actions

– Create a communication channel to send messages and subscribe to notifications
– Create a platform application for mobile devices
– Subscribe an endpoint to a topic to receive messages published to that topic
– Publish a message to a topic or as a direct publish to a platform endpoint
– Publish a text message (SMS) to a phone number

Create AWS SNS Topic

# aws sns create-topic –name My-Blog
{
“TopicArn”: “arn:aws:sns:us-east-1:xxxxxxxxxxxx:My-Blog”
}

Now you can subscribe to Topic using these protocols

http, https, email, email-json, sms, sqs, application, lambda

check more here: http://docs.aws.amazon.com/cli/latest/reference/sns/subscribe.html

Subscribe to AWS SNS Topic by email

# aws sns subscribe –topic-arn arn:aws:sns:us-east-1:xxxxxxxxxxxx:My-Blog –protocol email –notification-endpoint email@domain.com
{
“SubscriptionArn”: “pending confirmation”
}

AWS SNS Confirm

After Subscription Confirmed it provide SubscriptionArn like arn:aws:sns:us-east-1:xxxxxxxxxxxx:My-Blog:4e2a8654-6b5d-43fe-bf14-2237c8c849f7

AWS SNS Pending Confirm

Subscribe to AWS SNS Topic by Mobile (SMS)

# aws sns subscribe –topic-arn arn:aws:sns:us-east-1:xxxxxxxxxxxx:My-Blog –protocol sms –notification-endpoint 919912345678
{
“SubscriptionArn”: “arn:aws:sns:us-east-1:xxxxxxxxxxxx:My-Blog:a0bb38ca-ece1-4adb-897b-5a21010889e9”
}

Publish message to Topic

# aws sns publish –topic-arn arn:aws:sns:us-east-1:xxxxxxxxxxxx:My-Blog –message “Welcome to My Blog!”
{
“MessageId”: “9f280eb4-b561-5d34-b8c3-5f3be74515b2”
}

AWS SNS Push Message

AWS SNS SMS

Unsubscribe to AWS SNS Topic

# aws sns unsubscribe –subscription-arn “arn:aws:sns:us-east-1:xxxxxxxxxxxx:My-Blog:4e2a8654-6b5d-43fe-bf14-2237c8c849f7”

You can find Available Commands for AWS SNS here
http://docs.aws.amazon.com/cli/latest/reference/sns/index.html#cli-aws-sns

Delete AWS SNS Topic

# aws sns delete-topic –topic-arn “arn:aws:sns:us-east-1:xxxxxxxxxxxx:My-Blog”

Uninstalling AWS CLI

# rm -rf /usr/local/aws
# rm /usr/local/bin/aws

Install the AWS Command Line Interface on Microsoft Windows
http://docs.aws.amazon.com/cli/latest/userguide/awscli-install-windows.html#install-msi-on-windows