Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-cdk/aws-sns

Package Overview
Dependencies
Maintainers
4
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-cdk/aws-sns

The CDK Construct Library for AWS::SNS

  • 1.169.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
170K
increased by33.22%
Maintainers
4
Weekly downloads
 
Created

What is @aws-cdk/aws-sns?

@aws-cdk/aws-sns is an AWS Cloud Development Kit (CDK) library that allows you to define Amazon Simple Notification Service (SNS) topics and subscriptions in your AWS infrastructure as code. This package provides a high-level, object-oriented abstraction to create and manage SNS resources programmatically.

What are @aws-cdk/aws-sns's main functionalities?

Create an SNS Topic

This code sample demonstrates how to create an SNS topic with a display name using the AWS CDK.

const sns = require('@aws-cdk/aws-sns');
const cdk = require('@aws-cdk/core');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const topic = new sns.Topic(this, 'MyTopic', {
      displayName: 'My Cool Topic'
    });
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Add an Email Subscription to an SNS Topic

This code sample shows how to add an email subscription to an SNS topic using the AWS CDK.

const sns = require('@aws-cdk/aws-sns');
const subs = require('@aws-cdk/aws-sns-subscriptions');
const cdk = require('@aws-cdk/core');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const topic = new sns.Topic(this, 'MyTopic');

    topic.addSubscription(new subs.EmailSubscription('example@example.com'));
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Add a Lambda Subscription to an SNS Topic

This code sample demonstrates how to add a Lambda function as a subscription to an SNS topic using the AWS CDK.

const sns = require('@aws-cdk/aws-sns');
const subs = require('@aws-cdk/aws-sns-subscriptions');
const lambda = require('@aws-cdk/aws-lambda');
const cdk = require('@aws-cdk/core');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const topic = new sns.Topic(this, 'MyTopic');

    const myFunction = new lambda.Function(this, 'MyFunction', {
      runtime: lambda.Runtime.NODEJS_14_X,
      handler: 'index.handler',
      code: lambda.Code.fromAsset('lambda')
    });

    topic.addSubscription(new subs.LambdaSubscription(myFunction));
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Other packages similar to @aws-cdk/aws-sns

Keywords

FAQs

Package last updated on 18 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc