# ITopic

Represents an SNS topic.

Extends: ITopic
Extends: IResource, INotificationRuleTarget, ITopicRef
Implemented by: Topic, TopicBase

- Source: [`aws-sns/lib/topic-base.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-sns/lib/topic-base.ts#L19)
- Type last changed: v2.227.0 · 21 Nov 2025

## Properties

- `contentBasedDeduplication`: boolean — Enables content-based deduplication for FIFO topics.

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `fifo`: boolean — Whether this topic is an Amazon SNS FIFO queue.

  If false, this is a standard topic.

- `masterKey`: [IKey](/cdk/api/v2/docs/aws-cdk-lib.aws_kms.IKey.html) = None — A KMS Key, either managed by this CDK app, or imported.

  This property applies only to server-side encryption.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

- `topicArn`: string — The ARN of the topic.

- `topicName`: string — The name of the topic.

- `topicRef`: [TopicReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_sns.TopicReference.html) — A reference to a Topic resource.

## Methods

- `addSubscription(subscription: ITopicSubscription): Subscription` — Subscribe some endpoint to this topic.

- `addToResourcePolicy(statement: PolicyStatement): 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 `addToResourcePolicy`. If
  the topic is imported (`Topic.import`), then this is a no-op.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — 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: Construct): NotificationRuleTargetConfig` — Returns a target configuration for notification rule.

- `grantPublish(identity: IGrantable): Grant` — Grant topic publishing permissions to the given identity.

- `grantSubscribe(identity: IGrantable): Grant` — Grant topic subscribing permissions to the given identity.

- `metric(metricName: string, props?: MetricOptions): Metric` — Return the given named metric for this Topic.

- `metricNumberOfMessagesPublished(props?: MetricOptions): Metric` — The number of messages published to your Amazon SNS topics.

  Sum over 5 minutes

- `metricNumberOfNotificationsDelivered(props?: MetricOptions): Metric` — The number of messages successfully delivered from your Amazon SNS topics to subscribing endpoints.

  Sum over 5 minutes

- `metricNumberOfNotificationsFailed(props?: MetricOptions): Metric` — The number of messages that Amazon SNS failed to deliver.

  Sum over 5 minutes

- `metricNumberOfNotificationsFilteredOut(props?: MetricOptions): Metric` — The number of messages that were rejected by subscription filter policies.

  Sum over 5 minutes

- `metricNumberOfNotificationsFilteredOutInvalidAttributes(props?: MetricOptions): Metric` — The number of messages that were rejected by subscription filter policies because the messages' attributes are invalid.

  Sum over 5 minutes

- `metricNumberOfNotificationsFilteredOutNoMessageAttributes(props?: MetricOptions): Metric` — The number of messages that were rejected by subscription filter policies because the messages have no attributes.

  Sum over 5 minutes

- `metricPublishSize(props?: MetricOptions): Metric` — Metric for the size of messages published through this topic.

  Average over 5 minutes

- `metricSMSMonthToDateSpentUSD(props?: MetricOptions): Metric` — The charges you have accrued since the start of the current calendar month for sending SMS messages.

  Maximum over 5 minutes

- `metricSMSSuccessRate(props?: MetricOptions): Metric` — The rate of successful SMS message deliveries.

  Sum over 5 minutes

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
