This documentation is for the developer preview release of the AWS CDK. Do not use this version of the AWS CDK in production. Subsequent releases of the AWS CDK will likely include breaking changes.

@aws-cdk/aws-sns

AWS SNS Construct Library

Add an SNS Topic to your stack:

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

const topic = new sns.Topic(this, 'Topic', {
    displayName: 'Customer subscription topic'
});

Subscriptions

Various subscriptions can be added to the topic by calling the .subscribeXxx() methods on the topic.

Add an HTTPS Subscription to your topic:

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

myTopic.subscribeUrl('MyHttpsSubscription', 'https://foobar.com/');

Subscribe a queue to the topic:

const topic = new sns.Topic(this, 'MyTopic');
const queue = new sqs.Queue(this, 'MyQueue');

topic.subscribeQueue(queue);

Note that subscriptions of queues in different accounts need to be manually confirmed by reading the initial message from the queue and visiting the link found in it.

CloudWatch Event Rule Target

SNS topics can be used as targets for CloudWatch event rules:

const myTopic = new Topic(this, 'MyTopic');

// Use an EventRule and add the topic as a target
const rule = new events.EventRule(this, 'Rule', {
  scheduleExpression: 'rate(1 minute)'
});
rule.addTarget(myTopic);

// Or use one of the onXxx methods on event sources
codeCommitRepo.onCommit('OnCommit', myTopic);

This will result in adding a target to the event rule and will also modify the topic resource policy to allow CloudWatch events to publish to the topic.

Reference

View in Nuget

csproj:

<PackageReference Include="Amazon.CDK.AWS.SNS" Version="0.24.1" />

dotnet:

dotnet add package Amazon.CDK.AWS.SNS --version 0.24.1

packages.config:

<package id="Amazon.CDK.AWS.SNS" version="0.24.1" />

View in Maven Central

Apache Buildr:

'software.amazon.awscdk:sns:jar:0.24.1'

Apache Ivy:

<dependency groupId="software.amazon.awscdk" name="sns" rev="0.24.1"/>

Apache Maven:

<dependency>
  <groupId>software.amazon.awscdk</groupId>
  <artifactId>sns</artifactId>
  <version>0.24.1</version>
</dependency>

Gradle / Grails:

compile 'software.amazon.awscdk:sns:0.24.1'

Groovy Grape:

@Grapes(
@Grab(group='software.amazon.awscdk', module='sns', version='0.24.1')
)

View in NPM

npm:

$ npm i @aws-cdk/aws-sns@0.24.1

package.json:

{
  "@aws-cdk/aws-sns": "^0.24.1"
}

yarn:

$ yarn add @aws-cdk/aws-sns@0.24.1

View in NPM

npm:

$ npm i @aws-cdk/aws-sns@0.24.1

package.json:

{
  "@aws-cdk/aws-sns": "^0.24.1"
}

yarn:

$ yarn add @aws-cdk/aws-sns@0.24.1

CfnSubscription

class @aws-cdk/aws-sns.CfnSubscription(scope, id[, props])

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.CfnSubscription;
const { CfnSubscription } = require('@aws-cdk/aws-sns');
import { CfnSubscription } from '@aws-cdk/aws-sns';
Extends:

@aws-cdk/cdk.Resource

Parameters:
renderProperties(properties) → string => any

Overrides @aws-cdk/cdk.Resource.renderProperties()

Protected method

Parameters:properties (any) –
Return type:string => any
resourceTypeName

The CloudFormation resource type name for this resource class.

Type:string (readonly) (static)
propertyOverrides
Type:CfnSubscriptionProps (readonly)
subscriptionArn
Type:string (readonly)
apply(aspect)

Inherited from @aws-cdk/cdk.Construct

Applies the aspect to this Constructs node

Parameters:aspect (@aws-cdk/cdk.IAspect) –
toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)
ref

Inherited from @aws-cdk/cdk.Referenceable

Returns a token to a CloudFormation { Ref } that references this entity based on it’s logical ID.

Type:string (readonly)
addDeletionOverride(path)

Inherited from @aws-cdk/cdk.Resource

Syntactic sugar for addOverride(path, undefined).

Parameters:path (string) – The path of the value to delete
addDependsOn(resource)

Inherited from @aws-cdk/cdk.Resource

Indicates that this resource depends on another resource and cannot be provisioned

unless the other resource has been successfully provisioned.

Parameters:resource (@aws-cdk/cdk.Resource) –
addOverride(path, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to the synthesized CloudFormation resource. To add a

property override, either use addPropertyOverride or prefix path with

“Properties.” (i.e. Properties.TopicName).

Parameters:
  • path (string) – The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
  • value (any) – The value. Could be primitive or complex.
addPropertyDeletionOverride(propertyPath)

Inherited from @aws-cdk/cdk.Resource

Adds an override that deletes the value of a property from the resource definition.

Parameters:propertyPath (string) – The path to the property.
addPropertyOverride(propertyPath, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to a resource property.

Syntactic sugar for addOverride(“Properties.<…>”, value).

Parameters:
  • propertyPath (string) – The path of the property
  • value (any) – The value
getAtt(attributeName) → @aws-cdk/cdk.CfnReference

Inherited from @aws-cdk/cdk.Resource

Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility

in case there is no generated attribute.

Parameters:attributeName (string) – The name of the attribute.
Return type:@aws-cdk/cdk.CfnReference
toCloudFormation() → json

Inherited from @aws-cdk/cdk.Resource

Emits CloudFormation for this resource.

Return type:json
options

Inherited from @aws-cdk/cdk.Resource

Options for this resource, such as condition, update policy etc.

Type:@aws-cdk/cdk.ResourceOptions (readonly)
properties

Inherited from @aws-cdk/cdk.Resource

AWS resource properties.

This object is rendered via a call to “renderProperties(this.properties)”.

Protected property

Type:any (readonly)
resourceType

Inherited from @aws-cdk/cdk.Resource

AWS resource type.

Type:string (readonly)
untypedPropertyOverrides

Inherited from @aws-cdk/cdk.Resource

AWS resource property overrides.

During synthesis, the method “renderProperties(this.overrides)” is called

with this object, and merged on top of the output of

“renderProperties(this.properties)”.

Derived classes should expose a strongly-typed version of this object as

a public property called propertyOverrides.

Protected property

Type:any (readonly)
overrideLogicalId(newLogicalId)

Inherited from @aws-cdk/cdk.StackElement

Overrides the auto-generated logical ID with a specific ID.

Parameters:newLogicalId (string) – The new logical ID to use for this stack element.
prepare()

Inherited from @aws-cdk/cdk.StackElement

Automatically detect references in this StackElement

Protected method

creationStackTrace

Inherited from @aws-cdk/cdk.StackElement

Type:string[] (readonly)
logicalId

Inherited from @aws-cdk/cdk.StackElement

The logical ID for this CloudFormation stack element. The logical ID of the element

is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

Type:string (readonly)
stackPath

Inherited from @aws-cdk/cdk.StackElement

Return the path with respect to the stack

Type:string (readonly)
stack

Inherited from @aws-cdk/cdk.StackElement

The stack this Construct has been made a part of

Protected property

Type:@aws-cdk/cdk.Stack

CfnSubscriptionProps (interface)

class @aws-cdk/aws-sns.CfnSubscriptionProps

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.CfnSubscriptionProps;
// CfnSubscriptionProps is an interface
import { CfnSubscriptionProps } from '@aws-cdk/aws-sns';
deliveryPolicy

AWS::SNS::Subscription.DeliveryPolicy

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-deliverypolicy

Type:json or @aws-cdk/cdk.Token (optional)
endpoint

AWS::SNS::Subscription.Endpoint

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-endpoint

Type:string (optional)
filterPolicy

AWS::SNS::Subscription.FilterPolicy

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-filterpolicy

Type:json or @aws-cdk/cdk.Token (optional)
protocol

AWS::SNS::Subscription.Protocol

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-protocol

Type:string (optional)
rawMessageDelivery

AWS::SNS::Subscription.RawMessageDelivery

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-rawmessagedelivery

Type:boolean or @aws-cdk/cdk.Token (optional)
region

AWS::SNS::Subscription.Region

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-region

Type:string (optional)
topicArn

AWS::SNS::Subscription.TopicArn

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#topicarn

Type:string (optional)

CfnTopic

class @aws-cdk/aws-sns.CfnTopic(scope, id[, props])

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.CfnTopic;
const { CfnTopic } = require('@aws-cdk/aws-sns');
import { CfnTopic } from '@aws-cdk/aws-sns';
Extends:

@aws-cdk/cdk.Resource

Parameters:
  • scope (@aws-cdk/cdk.Construct) – scope in which this resource is defined
  • id (string) – scoped id of the resource
  • props (CfnTopicProps (optional)) – resource properties
renderProperties(properties) → string => any

Overrides @aws-cdk/cdk.Resource.renderProperties()

Protected method

Parameters:properties (any) –
Return type:string => any
resourceTypeName

The CloudFormation resource type name for this resource class.

Type:string (readonly) (static)
propertyOverrides
Type:CfnTopicProps (readonly)
topicArn
Type:string (readonly)
topicName
Type:string (readonly)
class SubscriptionProperty

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.CfnTopic.SubscriptionProperty;
// CfnTopic.SubscriptionProperty is an interface
import { CfnTopic.SubscriptionProperty } from '@aws-cdk/aws-sns';
endpoint

CfnTopic.SubscriptionProperty.Endpoint

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-subscription.html#cfn-sns-topic-subscription-endpoint

Type:string
protocol

CfnTopic.SubscriptionProperty.Protocol

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-subscription.html#cfn-sns-topic-subscription-protocol

Type:string
apply(aspect)

Inherited from @aws-cdk/cdk.Construct

Applies the aspect to this Constructs node

Parameters:aspect (@aws-cdk/cdk.IAspect) –
toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)
ref

Inherited from @aws-cdk/cdk.Referenceable

Returns a token to a CloudFormation { Ref } that references this entity based on it’s logical ID.

Type:string (readonly)
addDeletionOverride(path)

Inherited from @aws-cdk/cdk.Resource

Syntactic sugar for addOverride(path, undefined).

Parameters:path (string) – The path of the value to delete
addDependsOn(resource)

Inherited from @aws-cdk/cdk.Resource

Indicates that this resource depends on another resource and cannot be provisioned

unless the other resource has been successfully provisioned.

Parameters:resource (@aws-cdk/cdk.Resource) –
addOverride(path, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to the synthesized CloudFormation resource. To add a

property override, either use addPropertyOverride or prefix path with

“Properties.” (i.e. Properties.TopicName).

Parameters:
  • path (string) – The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
  • value (any) – The value. Could be primitive or complex.
addPropertyDeletionOverride(propertyPath)

Inherited from @aws-cdk/cdk.Resource

Adds an override that deletes the value of a property from the resource definition.

Parameters:propertyPath (string) – The path to the property.
addPropertyOverride(propertyPath, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to a resource property.

Syntactic sugar for addOverride(“Properties.<…>”, value).

Parameters:
  • propertyPath (string) – The path of the property
  • value (any) – The value
getAtt(attributeName) → @aws-cdk/cdk.CfnReference

Inherited from @aws-cdk/cdk.Resource

Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility

in case there is no generated attribute.

Parameters:attributeName (string) – The name of the attribute.
Return type:@aws-cdk/cdk.CfnReference
toCloudFormation() → json

Inherited from @aws-cdk/cdk.Resource

Emits CloudFormation for this resource.

Return type:json
options

Inherited from @aws-cdk/cdk.Resource

Options for this resource, such as condition, update policy etc.

Type:@aws-cdk/cdk.ResourceOptions (readonly)
properties

Inherited from @aws-cdk/cdk.Resource

AWS resource properties.

This object is rendered via a call to “renderProperties(this.properties)”.

Protected property

Type:any (readonly)
resourceType

Inherited from @aws-cdk/cdk.Resource

AWS resource type.

Type:string (readonly)
untypedPropertyOverrides

Inherited from @aws-cdk/cdk.Resource

AWS resource property overrides.

During synthesis, the method “renderProperties(this.overrides)” is called

with this object, and merged on top of the output of

“renderProperties(this.properties)”.

Derived classes should expose a strongly-typed version of this object as

a public property called propertyOverrides.

Protected property

Type:any (readonly)
overrideLogicalId(newLogicalId)

Inherited from @aws-cdk/cdk.StackElement

Overrides the auto-generated logical ID with a specific ID.

Parameters:newLogicalId (string) – The new logical ID to use for this stack element.
prepare()

Inherited from @aws-cdk/cdk.StackElement

Automatically detect references in this StackElement

Protected method

creationStackTrace

Inherited from @aws-cdk/cdk.StackElement

Type:string[] (readonly)
logicalId

Inherited from @aws-cdk/cdk.StackElement

The logical ID for this CloudFormation stack element. The logical ID of the element

is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

Type:string (readonly)
stackPath

Inherited from @aws-cdk/cdk.StackElement

Return the path with respect to the stack

Type:string (readonly)
stack

Inherited from @aws-cdk/cdk.StackElement

The stack this Construct has been made a part of

Protected property

Type:@aws-cdk/cdk.Stack

CfnTopicPolicy

class @aws-cdk/aws-sns.CfnTopicPolicy(scope, id, props)

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.CfnTopicPolicy;
const { CfnTopicPolicy } = require('@aws-cdk/aws-sns');
import { CfnTopicPolicy } from '@aws-cdk/aws-sns';
Extends:

@aws-cdk/cdk.Resource

Parameters:
renderProperties(properties) → string => any

Overrides @aws-cdk/cdk.Resource.renderProperties()

Protected method

Parameters:properties (any) –
Return type:string => any
resourceTypeName

The CloudFormation resource type name for this resource class.

Type:string (readonly) (static)
propertyOverrides
Type:CfnTopicPolicyProps (readonly)
apply(aspect)

Inherited from @aws-cdk/cdk.Construct

Applies the aspect to this Constructs node

Parameters:aspect (@aws-cdk/cdk.IAspect) –
toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)
ref

Inherited from @aws-cdk/cdk.Referenceable

Returns a token to a CloudFormation { Ref } that references this entity based on it’s logical ID.

Type:string (readonly)
addDeletionOverride(path)

Inherited from @aws-cdk/cdk.Resource

Syntactic sugar for addOverride(path, undefined).

Parameters:path (string) – The path of the value to delete
addDependsOn(resource)

Inherited from @aws-cdk/cdk.Resource

Indicates that this resource depends on another resource and cannot be provisioned

unless the other resource has been successfully provisioned.

Parameters:resource (@aws-cdk/cdk.Resource) –
addOverride(path, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to the synthesized CloudFormation resource. To add a

property override, either use addPropertyOverride or prefix path with

“Properties.” (i.e. Properties.TopicName).

Parameters:
  • path (string) – The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
  • value (any) – The value. Could be primitive or complex.
addPropertyDeletionOverride(propertyPath)

Inherited from @aws-cdk/cdk.Resource

Adds an override that deletes the value of a property from the resource definition.

Parameters:propertyPath (string) – The path to the property.
addPropertyOverride(propertyPath, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to a resource property.

Syntactic sugar for addOverride(“Properties.<…>”, value).

Parameters:
  • propertyPath (string) – The path of the property
  • value (any) – The value
getAtt(attributeName) → @aws-cdk/cdk.CfnReference

Inherited from @aws-cdk/cdk.Resource

Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility

in case there is no generated attribute.

Parameters:attributeName (string) – The name of the attribute.
Return type:@aws-cdk/cdk.CfnReference
toCloudFormation() → json

Inherited from @aws-cdk/cdk.Resource

Emits CloudFormation for this resource.

Return type:json
options

Inherited from @aws-cdk/cdk.Resource

Options for this resource, such as condition, update policy etc.

Type:@aws-cdk/cdk.ResourceOptions (readonly)
properties

Inherited from @aws-cdk/cdk.Resource

AWS resource properties.

This object is rendered via a call to “renderProperties(this.properties)”.

Protected property

Type:any (readonly)
resourceType

Inherited from @aws-cdk/cdk.Resource

AWS resource type.

Type:string (readonly)
untypedPropertyOverrides

Inherited from @aws-cdk/cdk.Resource

AWS resource property overrides.

During synthesis, the method “renderProperties(this.overrides)” is called

with this object, and merged on top of the output of

“renderProperties(this.properties)”.

Derived classes should expose a strongly-typed version of this object as

a public property called propertyOverrides.

Protected property

Type:any (readonly)
overrideLogicalId(newLogicalId)

Inherited from @aws-cdk/cdk.StackElement

Overrides the auto-generated logical ID with a specific ID.

Parameters:newLogicalId (string) – The new logical ID to use for this stack element.
prepare()

Inherited from @aws-cdk/cdk.StackElement

Automatically detect references in this StackElement

Protected method

creationStackTrace

Inherited from @aws-cdk/cdk.StackElement

Type:string[] (readonly)
logicalId

Inherited from @aws-cdk/cdk.StackElement

The logical ID for this CloudFormation stack element. The logical ID of the element

is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

Type:string (readonly)
stackPath

Inherited from @aws-cdk/cdk.StackElement

Return the path with respect to the stack

Type:string (readonly)
stack

Inherited from @aws-cdk/cdk.StackElement

The stack this Construct has been made a part of

Protected property

Type:@aws-cdk/cdk.Stack

CfnTopicPolicyProps (interface)

class @aws-cdk/aws-sns.CfnTopicPolicyProps

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.CfnTopicPolicyProps;
// CfnTopicPolicyProps is an interface
import { CfnTopicPolicyProps } from '@aws-cdk/aws-sns';
policyDocument

AWS::SNS::TopicPolicy.PolicyDocument

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-policy.html#cfn-sns-topicpolicy-policydocument

Type:json or @aws-cdk/cdk.Token
topics

AWS::SNS::TopicPolicy.Topics

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-policy.html#cfn-sns-topicpolicy-topics

Type:@aws-cdk/cdk.Token or (string or @aws-cdk/cdk.Token)[]

CfnTopicProps (interface)

class @aws-cdk/aws-sns.CfnTopicProps

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.CfnTopicProps;
// CfnTopicProps is an interface
import { CfnTopicProps } from '@aws-cdk/aws-sns';
displayName

AWS::SNS::Topic.DisplayName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html#cfn-sns-topic-displayname

Type:string (optional)
kmsMasterKeyId

AWS::SNS::Topic.KmsMasterKeyId

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html#cfn-sns-topic-kmsmasterkeyid

Type:string (optional)
subscription

AWS::SNS::Topic.Subscription

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html#cfn-sns-topic-subscription

Type:@aws-cdk/cdk.Token or (@aws-cdk/cdk.Token or SubscriptionProperty)[] (optional)
topicName

AWS::SNS::Topic.TopicName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html#cfn-sns-topic-topicname

Type:string (optional)

EmailSubscriptionOptions (interface)

class @aws-cdk/aws-sns.EmailSubscriptionOptions

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.EmailSubscriptionOptions;
// EmailSubscriptionOptions is an interface
import { EmailSubscriptionOptions } from '@aws-cdk/aws-sns';

Options for email subscriptions.

json

Indicates if the full notification JSON should be sent to the email

address or just the message text.

Type:boolean (optional)
Default:Message text (false)

ITopic (interface)

class @aws-cdk/aws-sns.ITopic

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.ITopic;
// ITopic is an interface
import { ITopic } from '@aws-cdk/aws-sns';
Extends:@aws-cdk/cdk.IConstruct
Extends:@aws-cdk/aws-events.IEventRuleTarget
Extends:@aws-cdk/aws-cloudwatch.IAlarmAction
Extends:@aws-cdk/aws-s3-notifications.IBucketNotificationDestination
Extends:@aws-cdk/aws-autoscaling-api.ILifecycleHookTarget
topicArn
Type:string (readonly)
topicName
Type:string (readonly)
addToResourcePolicy(statement)

Adds a statement to the IAM resource policy associated with this topic.

If this topic was created in this stack (new Topic), a topic policy

will be automatically created upon the first call to addToPolicy. If

the topic is improted (Topic.import), then this is a no-op.

Parameters:statement (@aws-cdk/aws-iam.PolicyStatement) –
Abstract:Yes
export() → @aws-cdk/aws-sns.TopicImportProps

Export this Topic

Return type:TopicImportProps
Abstract:Yes
grantPublish([identity])

Grant topic publishing permissions to the given identity

Parameters:identity (@aws-cdk/aws-iam.IPrincipal (optional)) –
Abstract:Yes
metric(metricName[, props]) → @aws-cdk/aws-cloudwatch.Metric

Return the given named metric for this Topic

Parameters:
Return type:

@aws-cdk/aws-cloudwatch.Metric

Abstract:

Yes

metricNumberOfMessagesPublished([props]) → @aws-cdk/aws-cloudwatch.Metric

The number of messages published to your Amazon SNS topics.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
Abstract:Yes
metricNumberOfNotificationsDelivered([props]) → @aws-cdk/aws-cloudwatch.Metric

The number of messages successfully delivered from your Amazon SNS topics to subscribing endpoints.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
Abstract:Yes
metricNumberOfNotificationsFailed([props]) → @aws-cdk/aws-cloudwatch.Metric

The number of messages that Amazon SNS failed to deliver.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
Abstract:Yes
metricNumberOfNotificationsFilteredOut([props]) → @aws-cdk/aws-cloudwatch.Metric

The number of messages that were rejected by subscription filter policies.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
Abstract:Yes
metricNumberOfNotificationsFilteredOutInvalidAttributes([props]) → @aws-cdk/aws-cloudwatch.Metric

The number of messages that were rejected by subscription filter policies because the messages’ attributes are invalid

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
Abstract:Yes
metricNumberOfNotificationsFilteredOutNoMessageAttributes([props]) → @aws-cdk/aws-cloudwatch.Metric

The number of messages that were rejected by subscription filter policies because the messages have no attributes.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
Abstract:Yes
metricPublishSize([props]) → @aws-cdk/aws-cloudwatch.Metric

Metric for the size of messages published through this topic

Average over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
Abstract:Yes
metricSMSMonthToDateSpentUSD([props]) → @aws-cdk/aws-cloudwatch.Metric

The charges you have accrued since the start of the current calendar month for sending SMS messages.

Maximum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
Abstract:Yes
metricSMSSuccessRate([props]) → @aws-cdk/aws-cloudwatch.Metric

The rate of successful SMS message deliveries.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
Abstract:Yes
subscribe(name, endpoint, protocol) → @aws-cdk/aws-sns.Subscription

Subscribe some endpoint to this topic

Parameters:
Return type:

Subscription

Abstract:

Yes

subscribeEmail(name, emailAddress[, options]) → @aws-cdk/aws-sns.Subscription

Defines a subscription from this SNS topic to an email address.

Parameters:
  • name (string) – A name for the subscription
  • emailAddress (string) – The email address to use.
  • options (EmailSubscriptionOptions (optional)) –
Return type:

Subscription

Abstract:

Yes

subscribeLambda(lambdaFunction) → @aws-cdk/aws-sns.Subscription

Defines a subscription from this SNS Topic to a Lambda function.

The Lambda’s resource policy will be updated to allow this topic to

invoke the function.

Parameters:lambdaFunction (@aws-cdk/aws-lambda.IFunction) – The Lambda function to invoke
Return type:Subscription
Abstract:Yes
subscribeQueue(queue) → @aws-cdk/aws-sns.Subscription

Defines a subscription from this SNS topic to an SQS queue.

The queue resource policy will be updated to allow this SNS topic to send

messages to the queue.

Parameters:queue (@aws-cdk/aws-sqs.IQueue) – The target queue
Return type:Subscription
Abstract:Yes
subscribeUrl(name, url) → @aws-cdk/aws-sns.Subscription

Defines a subscription from this SNS topic to an http:// or https:// URL.

Parameters:
  • name (string) – A name for the subscription
  • url (string) – The URL to invoke
Return type:

Subscription

Abstract:

Yes

asLifecycleHookTarget(lifecycleHook) → @aws-cdk/aws-autoscaling-api.LifecycleHookTargetProps

Inherited from @aws-cdk/aws-autoscaling-api.ILifecycleHookTarget

Called when this object is used as the target of a lifecycle hook

Parameters:lifecycleHook (@aws-cdk/aws-autoscaling-api.ILifecycleHook) –
Return type:@aws-cdk/aws-autoscaling-api.LifecycleHookTargetProps
Abstract:Yes
alarmActionArn

Inherited from @aws-cdk/aws-cloudwatch.IAlarmAction

Return the ARN that should be used for a CloudWatch Alarm action

Type:string (readonly)
asEventRuleTarget(ruleArn, ruleUniqueId) → @aws-cdk/aws-events.EventRuleTargetProps

Inherited from @aws-cdk/aws-events.IEventRuleTarget

Returns the rule target specification.

NOTE: Do not use the various inputXxx options. They can be set in a call to addTarget.

Parameters:
  • ruleArn (string) – The ARN of the CloudWatch Event Rule that would trigger this target.
  • ruleUniqueId (string) – A unique ID for this rule. Can be used to implement idempotency.
Return type:

@aws-cdk/aws-events.EventRuleTargetProps

Abstract:

Yes

asBucketNotificationDestination(bucketArn, bucketId) → @aws-cdk/aws-s3-notifications.BucketNotificationDestinationProps

Inherited from @aws-cdk/aws-s3-notifications.IBucketNotificationDestination

Registers this resource to receive notifications for the specified

bucket. This method will only be called once for each destination/bucket

pair and the result will be cached, so there is no need to implement

idempotency in each destination.

Parameters:
  • bucketArn (string) – The ARN of the bucket
  • bucketId (string) – A unique ID of this bucket in the stack
Return type:

@aws-cdk/aws-s3-notifications.BucketNotificationDestinationProps

Abstract:

Yes

node

Inherited from @aws-cdk/cdk.IConstruct

The construct node in the scope tree.

Type:@aws-cdk/cdk.ConstructNode (readonly)
dependencyRoots

Inherited from @aws-cdk/cdk.IDependable

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)

Subscription

class @aws-cdk/aws-sns.Subscription(scope, id, props)

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.Subscription;
const { Subscription } = require('@aws-cdk/aws-sns');
import { Subscription } from '@aws-cdk/aws-sns';

A new subscription.

Prefer to use the ITopic.subscribeXxx() methods to creating instances of

this class.

Extends:

@aws-cdk/cdk.Construct

Parameters:
apply(aspect)

Inherited from @aws-cdk/cdk.Construct

Applies the aspect to this Constructs node

Parameters:aspect (@aws-cdk/cdk.IAspect) –
prepare()

Inherited from @aws-cdk/cdk.Construct

Perform final modifications before synthesis

This method can be implemented by derived constructs in order to perform

final changes before synthesis. prepare() will be called after child

constructs have been prepared.

This is an advanced framework feature. Only use this if you

understand the implications.

Protected method

toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)

SubscriptionProps (interface)

class @aws-cdk/aws-sns.SubscriptionProps

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.SubscriptionProps;
// SubscriptionProps is an interface
import { SubscriptionProps } from '@aws-cdk/aws-sns';

Properties for creating a new subscription

endpoint

The subscription endpoint.

The meaning of this value depends on the value for ‘protocol’.

Type:any
protocol

What type of subscription to add.

Type:SubscriptionProtocol
topic

The topic to subscribe to.

Type:ITopic

SubscriptionProtocol (enum)

class @aws-cdk/aws-sns.SubscriptionProtocol

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.SubscriptionProtocol;
const { SubscriptionProtocol } = require('@aws-cdk/aws-sns');
import { SubscriptionProtocol } from '@aws-cdk/aws-sns';

The type of subscription, controlling the type of the endpoint parameter.

Http

JSON-encoded message is POSTED to an HTTP url.

Https

JSON-encoded message is POSTed to an HTTPS url.

Email

Notifications are sent via email.

EmailJson

Notifications are JSON-encoded and sent via mail.

Sms

Notification is delivered by SMS

Sqs

Notifications are enqueued into an SQS queue.

Application

JSON-encoded notifications are sent to a mobile app endpoint.

Lambda

Notifications trigger a Lambda function.

Topic

class @aws-cdk/aws-sns.Topic(scope, id[, props])

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.Topic;
const { Topic } = require('@aws-cdk/aws-sns');
import { Topic } from '@aws-cdk/aws-sns';

A new SNS topic

Extends:

TopicBase

Parameters:
static import(scope, id, props) → @aws-cdk/aws-sns.ITopic

Import a Topic defined elsewhere

Parameters:
Return type:

ITopic

export() → @aws-cdk/aws-sns.TopicImportProps

Implements @aws-cdk/aws-sns.TopicBase.export()

Export this Topic

Return type:TopicImportProps
autoCreatePolicy

Implements @aws-cdk/aws-sns.TopicBase.autoCreatePolicy()

Controls automatic creation of policy objects.

Set by subclasses.

Protected property

Type:boolean (readonly)
topicArn

Implements @aws-cdk/aws-sns.TopicBase.topicArn()

Type:string (readonly)
topicName

Implements @aws-cdk/aws-sns.TopicBase.topicName()

Type:string (readonly)
addToResourcePolicy(statement)

Inherited from @aws-cdk/aws-sns.TopicBase

Adds a statement to the IAM resource policy associated with this topic.

If this topic was created in this stack (new Topic), a topic policy

will be automatically created upon the first call to addToPolicy. If

the topic is improted (Topic.import), then this is a no-op.

Parameters:statement (@aws-cdk/aws-iam.PolicyStatement) –
asBucketNotificationDestination(bucketArn, bucketId) → @aws-cdk/aws-s3-notifications.BucketNotificationDestinationProps

Inherited from @aws-cdk/aws-sns.TopicBase

Implements the IBucketNotificationDestination interface, allowing topics to be used

as bucket notification destinations.

Parameters:
  • bucketArn (string) – The ARN of the bucket sending the notifications
  • bucketId (string) – A unique ID of the bucket
Return type:

@aws-cdk/aws-s3-notifications.BucketNotificationDestinationProps

asEventRuleTarget(_ruleArn, _ruleId) → @aws-cdk/aws-events.EventRuleTargetProps

Inherited from @aws-cdk/aws-sns.TopicBase

Returns a RuleTarget that can be used to trigger this SNS topic as a

result from a CloudWatch event.

Parameters:
  • _ruleArn (string) –
  • _ruleId (string) –
Return type:

@aws-cdk/aws-events.EventRuleTargetProps

asLifecycleHookTarget(lifecycleHook) → @aws-cdk/aws-autoscaling-api.LifecycleHookTargetProps

Inherited from @aws-cdk/aws-sns.TopicBase

Allow using SNS topics as lifecycle hook targets

Parameters:lifecycleHook (@aws-cdk/aws-autoscaling-api.ILifecycleHook) –
Return type:@aws-cdk/aws-autoscaling-api.LifecycleHookTargetProps
grantPublish([identity])

Inherited from @aws-cdk/aws-sns.TopicBase

Grant topic publishing permissions to the given identity

Parameters:identity (@aws-cdk/aws-iam.IPrincipal (optional)) –
metric(metricName[, props]) → @aws-cdk/aws-cloudwatch.Metric

Inherited from @aws-cdk/aws-sns.TopicBase

Return the given named metric for this Topic

Parameters:
Return type:

@aws-cdk/aws-cloudwatch.Metric

metricNumberOfMessagesPublished([props]) → @aws-cdk/aws-cloudwatch.Metric

Inherited from @aws-cdk/aws-sns.TopicBase

The number of messages published to your Amazon SNS topics.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricNumberOfNotificationsDelivered([props]) → @aws-cdk/aws-cloudwatch.Metric

Inherited from @aws-cdk/aws-sns.TopicBase

The number of messages successfully delivered from your Amazon SNS topics to subscribing endpoints.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricNumberOfNotificationsFailed([props]) → @aws-cdk/aws-cloudwatch.Metric

Inherited from @aws-cdk/aws-sns.TopicBase

The number of messages that Amazon SNS failed to deliver.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricNumberOfNotificationsFilteredOut([props]) → @aws-cdk/aws-cloudwatch.Metric

Inherited from @aws-cdk/aws-sns.TopicBase

The number of messages that were rejected by subscription filter policies.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricNumberOfNotificationsFilteredOutInvalidAttributes([props]) → @aws-cdk/aws-cloudwatch.Metric

Inherited from @aws-cdk/aws-sns.TopicBase

The number of messages that were rejected by subscription filter policies because the messages’ attributes are invalid

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricNumberOfNotificationsFilteredOutNoMessageAttributes([props]) → @aws-cdk/aws-cloudwatch.Metric

Inherited from @aws-cdk/aws-sns.TopicBase

The number of messages that were rejected by subscription filter policies because the messages have no attributes.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricPublishSize([props]) → @aws-cdk/aws-cloudwatch.Metric

Inherited from @aws-cdk/aws-sns.TopicBase

Metric for the size of messages published through this topic

Average over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricSMSMonthToDateSpentUSD([props]) → @aws-cdk/aws-cloudwatch.Metric

Inherited from @aws-cdk/aws-sns.TopicBase

The charges you have accrued since the start of the current calendar month for sending SMS messages.

Maximum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricSMSSuccessRate([props]) → @aws-cdk/aws-cloudwatch.Metric

Inherited from @aws-cdk/aws-sns.TopicBase

The rate of successful SMS message deliveries.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
subscribe(name, endpoint, protocol) → @aws-cdk/aws-sns.Subscription

Inherited from @aws-cdk/aws-sns.TopicBase

Subscribe some endpoint to this topic

Parameters:
Return type:

Subscription

subscribeEmail(name, emailAddress[, options]) → @aws-cdk/aws-sns.Subscription

Inherited from @aws-cdk/aws-sns.TopicBase

Defines a subscription from this SNS topic to an email address.

Parameters:
  • name (string) – A name for the subscription
  • emailAddress (string) – The email address to use.
  • options (EmailSubscriptionOptions (optional)) –
Return type:

Subscription

subscribeLambda(lambdaFunction) → @aws-cdk/aws-sns.Subscription

Inherited from @aws-cdk/aws-sns.TopicBase

Defines a subscription from this SNS Topic to a Lambda function.

The Lambda’s resource policy will be updated to allow this topic to

invoke the function.

Parameters:lambdaFunction (@aws-cdk/aws-lambda.IFunction) – The Lambda function to invoke
Return type:Subscription
subscribeQueue(queue) → @aws-cdk/aws-sns.Subscription

Inherited from @aws-cdk/aws-sns.TopicBase

Defines a subscription from this SNS topic to an SQS queue.

The queue resource policy will be updated to allow this SNS topic to send

messages to the queue.

Parameters:queue (@aws-cdk/aws-sqs.IQueue) – The target queue
Return type:Subscription
subscribeUrl(name, url) → @aws-cdk/aws-sns.Subscription

Inherited from @aws-cdk/aws-sns.TopicBase

Defines a subscription from this SNS topic to an http:// or https:// URL.

Parameters:
  • name (string) – A name for the subscription
  • url (string) – The URL to invoke
Return type:

Subscription

alarmActionArn

Inherited from @aws-cdk/aws-sns.TopicBase

Return the ARN that should be used for a CloudWatch Alarm action

Type:string (readonly)
apply(aspect)

Inherited from @aws-cdk/cdk.Construct

Applies the aspect to this Constructs node

Parameters:aspect (@aws-cdk/cdk.IAspect) –
prepare()

Inherited from @aws-cdk/cdk.Construct

Perform final modifications before synthesis

This method can be implemented by derived constructs in order to perform

final changes before synthesis. prepare() will be called after child

constructs have been prepared.

This is an advanced framework feature. Only use this if you

understand the implications.

Protected method

toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)

TopicBase

class @aws-cdk/aws-sns.TopicBase(scope, id)

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.TopicBase;
const { TopicBase } = require('@aws-cdk/aws-sns');
import { TopicBase } from '@aws-cdk/aws-sns';

Either a new or imported Topic

Extends:

@aws-cdk/cdk.Construct

Implements:

ITopic

Abstract:

Yes

Parameters:
  • scope (@aws-cdk/cdk.Construct) – The scope in which to define this construct
  • id (string) – The scoped construct ID. Must be unique amongst siblings. If the ID includes a path separator (/), then it will be replaced by double dash .
addToResourcePolicy(statement)

Implements @aws-cdk/aws-sns.ITopic.addToResourcePolicy()

Adds a statement to the IAM resource policy associated with this topic.

If this topic was created in this stack (new Topic), a topic policy

will be automatically created upon the first call to addToPolicy. If

the topic is improted (Topic.import), then this is a no-op.

Parameters:statement (@aws-cdk/aws-iam.PolicyStatement) –
asBucketNotificationDestination(bucketArn, bucketId) → @aws-cdk/aws-s3-notifications.BucketNotificationDestinationProps

Implements @aws-cdk/aws-s3-notifications.IBucketNotificationDestination.asBucketNotificationDestination()

Implements the IBucketNotificationDestination interface, allowing topics to be used

as bucket notification destinations.

Parameters:
  • bucketArn (string) – The ARN of the bucket sending the notifications
  • bucketId (string) – A unique ID of the bucket
Return type:

@aws-cdk/aws-s3-notifications.BucketNotificationDestinationProps

asEventRuleTarget(_ruleArn, _ruleId) → @aws-cdk/aws-events.EventRuleTargetProps

Implements @aws-cdk/aws-events.IEventRuleTarget.asEventRuleTarget()

Returns a RuleTarget that can be used to trigger this SNS topic as a

result from a CloudWatch event.

Parameters:
  • _ruleArn (string) –
  • _ruleId (string) –
Return type:

@aws-cdk/aws-events.EventRuleTargetProps

asLifecycleHookTarget(lifecycleHook) → @aws-cdk/aws-autoscaling-api.LifecycleHookTargetProps

Implements @aws-cdk/aws-autoscaling-api.ILifecycleHookTarget.asLifecycleHookTarget()

Allow using SNS topics as lifecycle hook targets

Parameters:lifecycleHook (@aws-cdk/aws-autoscaling-api.ILifecycleHook) –
Return type:@aws-cdk/aws-autoscaling-api.LifecycleHookTargetProps
export() → @aws-cdk/aws-sns.TopicImportProps

Implements @aws-cdk/aws-sns.ITopic.export()

Export this Topic

Return type:TopicImportProps
Abstract:Yes
grantPublish([identity])

Implements @aws-cdk/aws-sns.ITopic.grantPublish()

Grant topic publishing permissions to the given identity

Parameters:identity (@aws-cdk/aws-iam.IPrincipal (optional)) –
metric(metricName[, props]) → @aws-cdk/aws-cloudwatch.Metric

Implements @aws-cdk/aws-sns.ITopic.metric()

Return the given named metric for this Topic

Parameters:
Return type:

@aws-cdk/aws-cloudwatch.Metric

metricNumberOfMessagesPublished([props]) → @aws-cdk/aws-cloudwatch.Metric

Implements @aws-cdk/aws-sns.ITopic.metricNumberOfMessagesPublished()

The number of messages published to your Amazon SNS topics.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricNumberOfNotificationsDelivered([props]) → @aws-cdk/aws-cloudwatch.Metric

Implements @aws-cdk/aws-sns.ITopic.metricNumberOfNotificationsDelivered()

The number of messages successfully delivered from your Amazon SNS topics to subscribing endpoints.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricNumberOfNotificationsFailed([props]) → @aws-cdk/aws-cloudwatch.Metric

Implements @aws-cdk/aws-sns.ITopic.metricNumberOfNotificationsFailed()

The number of messages that Amazon SNS failed to deliver.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricNumberOfNotificationsFilteredOut([props]) → @aws-cdk/aws-cloudwatch.Metric

Implements @aws-cdk/aws-sns.ITopic.metricNumberOfNotificationsFilteredOut()

The number of messages that were rejected by subscription filter policies.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricNumberOfNotificationsFilteredOutInvalidAttributes([props]) → @aws-cdk/aws-cloudwatch.Metric

Implements @aws-cdk/aws-sns.ITopic.metricNumberOfNotificationsFilteredOutInvalidAttributes()

The number of messages that were rejected by subscription filter policies because the messages’ attributes are invalid

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricNumberOfNotificationsFilteredOutNoMessageAttributes([props]) → @aws-cdk/aws-cloudwatch.Metric

Implements @aws-cdk/aws-sns.ITopic.metricNumberOfNotificationsFilteredOutNoMessageAttributes()

The number of messages that were rejected by subscription filter policies because the messages have no attributes.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricPublishSize([props]) → @aws-cdk/aws-cloudwatch.Metric

Implements @aws-cdk/aws-sns.ITopic.metricPublishSize()

Metric for the size of messages published through this topic

Average over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricSMSMonthToDateSpentUSD([props]) → @aws-cdk/aws-cloudwatch.Metric

Implements @aws-cdk/aws-sns.ITopic.metricSMSMonthToDateSpentUSD()

The charges you have accrued since the start of the current calendar month for sending SMS messages.

Maximum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
metricSMSSuccessRate([props]) → @aws-cdk/aws-cloudwatch.Metric

Implements @aws-cdk/aws-sns.ITopic.metricSMSSuccessRate()

The rate of successful SMS message deliveries.

Sum over 5 minutes

Parameters:props (@aws-cdk/aws-cloudwatch.MetricCustomization (optional)) –
Return type:@aws-cdk/aws-cloudwatch.Metric
subscribe(name, endpoint, protocol) → @aws-cdk/aws-sns.Subscription

Implements @aws-cdk/aws-sns.ITopic.subscribe()

Subscribe some endpoint to this topic

Parameters:
Return type:

Subscription

subscribeEmail(name, emailAddress[, options]) → @aws-cdk/aws-sns.Subscription

Implements @aws-cdk/aws-sns.ITopic.subscribeEmail()

Defines a subscription from this SNS topic to an email address.

Parameters:
  • name (string) – A name for the subscription
  • emailAddress (string) – The email address to use.
  • options (EmailSubscriptionOptions (optional)) –
Return type:

Subscription

subscribeLambda(lambdaFunction) → @aws-cdk/aws-sns.Subscription

Implements @aws-cdk/aws-sns.ITopic.subscribeLambda()

Defines a subscription from this SNS Topic to a Lambda function.

The Lambda’s resource policy will be updated to allow this topic to

invoke the function.

Parameters:lambdaFunction (@aws-cdk/aws-lambda.IFunction) – The Lambda function to invoke
Return type:Subscription
subscribeQueue(queue) → @aws-cdk/aws-sns.Subscription

Implements @aws-cdk/aws-sns.ITopic.subscribeQueue()

Defines a subscription from this SNS topic to an SQS queue.

The queue resource policy will be updated to allow this SNS topic to send

messages to the queue.

Parameters:queue (@aws-cdk/aws-sqs.IQueue) – The target queue
Return type:Subscription
subscribeUrl(name, url) → @aws-cdk/aws-sns.Subscription

Implements @aws-cdk/aws-sns.ITopic.subscribeUrl()

Defines a subscription from this SNS topic to an http:// or https:// URL.

Parameters:
  • name (string) – A name for the subscription
  • url (string) – The URL to invoke
Return type:

Subscription

alarmActionArn

Implements @aws-cdk/aws-cloudwatch.IAlarmAction.alarmActionArn()

Return the ARN that should be used for a CloudWatch Alarm action

Type:string (readonly)
autoCreatePolicy

Controls automatic creation of policy objects.

Set by subclasses.

Protected property

Type:boolean (readonly) (abstract)
topicArn

Implements @aws-cdk/aws-sns.ITopic.topicArn()

Type:string (readonly) (abstract)
topicName

Implements @aws-cdk/aws-sns.ITopic.topicName()

Type:string (readonly) (abstract)
apply(aspect)

Inherited from @aws-cdk/cdk.Construct

Applies the aspect to this Constructs node

Parameters:aspect (@aws-cdk/cdk.IAspect) –
prepare()

Inherited from @aws-cdk/cdk.Construct

Perform final modifications before synthesis

This method can be implemented by derived constructs in order to perform

final changes before synthesis. prepare() will be called after child

constructs have been prepared.

This is an advanced framework feature. Only use this if you

understand the implications.

Protected method

toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)

TopicImportProps (interface)

class @aws-cdk/aws-sns.TopicImportProps

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.TopicImportProps;
// TopicImportProps is an interface
import { TopicImportProps } from '@aws-cdk/aws-sns';

Reference to an external topic.

topicArn
Type:string
topicName
Type:string

TopicPolicy

class @aws-cdk/aws-sns.TopicPolicy(scope, id, props)

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.TopicPolicy;
const { TopicPolicy } = require('@aws-cdk/aws-sns');
import { TopicPolicy } from '@aws-cdk/aws-sns';

Applies a policy to SNS topics.

Extends:

@aws-cdk/cdk.Construct

Parameters:
document

The IAM policy document for this policy.

Type:@aws-cdk/aws-iam.PolicyDocument (readonly)
apply(aspect)

Inherited from @aws-cdk/cdk.Construct

Applies the aspect to this Constructs node

Parameters:aspect (@aws-cdk/cdk.IAspect) –
prepare()

Inherited from @aws-cdk/cdk.Construct

Perform final modifications before synthesis

This method can be implemented by derived constructs in order to perform

final changes before synthesis. prepare() will be called after child

constructs have been prepared.

This is an advanced framework feature. Only use this if you

understand the implications.

Protected method

toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)

TopicPolicyProps (interface)

class @aws-cdk/aws-sns.TopicPolicyProps

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.TopicPolicyProps;
// TopicPolicyProps is an interface
import { TopicPolicyProps } from '@aws-cdk/aws-sns';
topics

The set of topics this policy applies to.

Type:ITopic[]

TopicProps (interface)

class @aws-cdk/aws-sns.TopicProps

Language-specific names:

using Amazon.CDK.AWS.SNS;
import software.amazon.awscdk.services.sns.TopicProps;
// TopicProps is an interface
import { TopicProps } from '@aws-cdk/aws-sns';

Properties for a new SNS topic

displayName

A developer-defined string that can be used to identify this SNS topic.

Type:string (optional)
Default:None
topicName

A name for the topic.

If you don’t specify a name, AWS CloudFormation generates a unique

physical ID and uses that ID for the topic name. For more information,

see Name Type.

Type:string (optional)
Default:Generated name