aws-cdk-lib.aws_sns.TopicBase

class TopicBase

LanguageType name
.NETAmazon.CDK.AWS.SNS.TopicBase
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awssns#TopicBase
Javasoftware.amazon.awscdk.services.sns.TopicBase
Pythonaws_cdk.aws_sns.TopicBase
TypeScript (source)aws-cdk-lib » aws_sns » TopicBase

Implements IConstruct, IDependable, IResource, ITopic, INotificationRuleTarget

Extends Resource

Implemented by Topic

Either a new or imported Topic.

Initializer

new TopicBase(scope: Construct, id: string, props?: ResourceProps)

Parameters

  • scope Construct
  • id string
  • props ResourceProps

Properties

NameTypeDescription
autoCreatePolicybooleanControls automatic creation of policy objects.
envResourceEnvironmentThe environment this resource belongs to.
fifobooleanWhether this topic is an Amazon SNS FIFO queue.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.
topicArnstringThe ARN of the topic.
topicNamestringThe name of the topic.

autoCreatePolicy

Type: boolean

Controls automatic creation of policy objects.

Set by subclasses.


env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


fifo

Type: boolean

Whether this topic is an Amazon SNS FIFO queue.

If false, this is a standard topic.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.


topicArn

Type: string

The ARN of the topic.


topicName

Type: string

The name of the topic.

Methods

NameDescription
addSubscription(topicSubscription)Subscribe some endpoint to this topic.
addToResourcePolicy(statement)Adds a statement to the IAM resource policy associated with this topic.
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
bindAsNotificationRuleTarget(_scope)Represents a notification target That allows SNS topic to associate with this rule target.
grantPublish(grantee)Grant topic publishing permissions to the given identity.
metric(metricName, props?)Return the given named metric for this Topic.
metricNumberOfMessagesPublished(props?)The number of messages published to your Amazon SNS topics.
metricNumberOfNotificationsDelivered(props?)The number of messages successfully delivered from your Amazon SNS topics to subscribing endpoints.
metricNumberOfNotificationsFailed(props?)The number of messages that Amazon SNS failed to deliver.
metricNumberOfNotificationsFilteredOut(props?)The number of messages that were rejected by subscription filter policies.
metricNumberOfNotificationsFilteredOutInvalidAttributes(props?)The number of messages that were rejected by subscription filter policies because the messages' attributes are invalid.
metricNumberOfNotificationsFilteredOutNoMessageAttributes(props?)The number of messages that were rejected by subscription filter policies because the messages have no attributes.
metricPublishSize(props?)Metric for the size of messages published through this topic.
metricSMSMonthToDateSpentUSD(props?)The charges you have accrued since the start of the current calendar month for sending SMS messages.
metricSMSSuccessRate(props?)The rate of successful SMS message deliveries.
toString()Returns a string representation of this construct.

addSubscription(topicSubscription)

public addSubscription(topicSubscription: ITopicSubscription): Subscription

Parameters

  • topicSubscription ITopicSubscription

Returns

  • Subscription

Subscribe some endpoint to this topic.


addToResourcePolicy(statement)

public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult

Parameters

  • statement PolicyStatement

Returns

  • AddToResourcePolicyResult

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 imported (Topic.import), then this is a no-op.


applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


bindAsNotificationRuleTarget(_scope)

public bindAsNotificationRuleTarget(_scope: Construct): NotificationRuleTargetConfig

Parameters

  • _scope Construct

Returns

  • NotificationRuleTargetConfig

Represents a notification target That allows SNS topic to associate with this rule target.


grantPublish(grantee)

public grantPublish(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable

Returns

  • Grant

Grant topic publishing permissions to the given identity.


metric(metricName, props?)

public metric(metricName: string, props?: MetricOptions): Metric

Parameters

  • metricName string
  • props MetricOptions

Returns

  • Metric

Return the given named metric for this Topic.


metricNumberOfMessagesPublished(props?)

public metricNumberOfMessagesPublished(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The number of messages published to your Amazon SNS topics.

Sum over 5 minutes


metricNumberOfNotificationsDelivered(props?)

public metricNumberOfNotificationsDelivered(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

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

Sum over 5 minutes


metricNumberOfNotificationsFailed(props?)

public metricNumberOfNotificationsFailed(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The number of messages that Amazon SNS failed to deliver.

Sum over 5 minutes


metricNumberOfNotificationsFilteredOut(props?)

public metricNumberOfNotificationsFilteredOut(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

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

Sum over 5 minutes


metricNumberOfNotificationsFilteredOutInvalidAttributes(props?)

public metricNumberOfNotificationsFilteredOutInvalidAttributes(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

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

Sum over 5 minutes


metricNumberOfNotificationsFilteredOutNoMessageAttributes(props?)

public metricNumberOfNotificationsFilteredOutNoMessageAttributes(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

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

Sum over 5 minutes


metricPublishSize(props?)

public metricPublishSize(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Metric for the size of messages published through this topic.

Average over 5 minutes


metricSMSMonthToDateSpentUSD(props?)

public metricSMSMonthToDateSpentUSD(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

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

Maximum over 5 minutes


metricSMSSuccessRate(props?)

public metricSMSSuccessRate(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The rate of successful SMS message deliveries.

Sum over 5 minutes


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.