Skip to content

Latest commit

 

History

History
89 lines (64 loc) · 3.53 KB

File metadata and controls

89 lines (64 loc) · 3.53 KB

SNS Email Subscription

SNS Email Subscription

Publishing a message to the Amazon Simple Notification Service via AWS Console or AWS CLI to send an e-mail to the endpoint.

NOTE: The e-mail subscription require confirmation by visiting the link sent to the e-mail address.

SNS Subscription Confirmation

SNS Subscription Confirmation

Invoking SNS function via AWS Console

  1. Go to Amazon SNS → Topics → Your SNS TopicPublish message

  2. Enter the following information

    a. Subject (optional)

    b. Message body (see sample payload)

  3. Click on the Publish message in the bottom right corner

Invoking SNS via AWS CLI

  1. Use the following command and replace the placeholder sns_topic_arn with the actual SNS Topic ARN

    aws sns publish \
    --topic-arn sns_topic_arn \
    --message file://sns-sample-message.txt \
    --subject "Cash on Delivery (COD) #210327LL6J2NE7"

    It will publish the specified message to the specified SNS Topic. The message comes from a text file, which enables you to include line breaks.

Sample Payload

Hello John,
  
We regret to inform you that your Cash on Delivery (COD) payment request for order #210327LL6J2NE7 has been declined. We have notified the seller to cancel the shipping of your item(s).

Sample SNS Published Email

SNS Published Email

AWS CDK API / Developer Reference

AWS Documentation Developer Guide

Useful commands

The cdk.json file tells the CDK Toolkit how to execute your app.

  • npm install install projects dependencies
  • npm run build compile typescript to js
  • npm run watch watch for changes and compile
  • npm run test perform the jest unit tests
  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk synth emits the synthesized CloudFormation template
  • cdk bootstrap deployment of AWS CloudFormation template to a specific AWS environment (account and region)
  • cdk destroy destroy this stack from your default AWS account/region

Deploy

Using make command

  1. Install all the dependencies, bootstrap your project, and synthesized CloudFormation template.

    # Without passing "profile" parameter
    dev@dev:~:aws-cdk-samples/sns/sns-email-subscription$ make init
    
    # With "profile" parameter
    dev@dev:~:aws-cdk-samples/sns/sns-email-subscription$ make init profile=[profile_name]
  2. Deploy the project.

    # Without passing "profile" parameter
    dev@dev:~:aws-cdk-samples/sns/sns-email-subscription$ make deploy
    
    # With "profile" parameter
    dev@dev:~:aws-cdk-samples/sns/sns-email-subscription$ make deploy profile=[profile_name]