Class Topic
A new SNS topic.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.SNS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Topic : TopicBase, ITopic, INotificationRuleTarget, ITopicRef, IEncryptedResource, IResource, IConstruct, IDependable, IEnvironmentAware
Syntax (vb)
Public Class Topic Inherits TopicBase Implements ITopic, INotificationRuleTarget, ITopicRef, IEncryptedResource, IResource, IConstruct, IDependable, IEnvironmentAware
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.SNS;
var topic = new Topic(this, "MyTopic");
var topicRule = new TopicRule(this, "TopicRule", new TopicRuleProps {
Sql = IotSql.FromStringAsVer20160323("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'"),
Actions = new [] {
new SnsTopicAction(topic, new SnsTopicActionProps {
MessageFormat = SnsActionMessageFormat.JSON
}) }
});
Synopsis
Constructors
| Topic(Construct, string, ITopicProps?) | A new SNS topic. |
Properties
| AutoCreatePolicy | Controls automatic creation of policy objects. |
| ContentBasedDeduplication | Enables content-based deduplication for FIFO topics. |
| Fifo | Whether this topic is an Amazon SNS FIFO queue. |
| MasterKey | A KMS Key, either managed by this CDK app, or imported. |
| PROPERTY_INJECTION_ID | Uniquely identifies this class. |
| TopicArn | The ARN of the topic. |
| TopicName | The name of the topic. |
Methods
| AddLoggingConfig(ILoggingConfig) | Adds a delivery status logging configuration to the topic. |
| FromTopicArn(Construct, string, string) | Import an existing SNS topic provided an ARN. |
| FromTopicAttributes(Construct, string, ITopicAttributes) | Import an existing SNS topic provided a topic attributes. |
Constructors
Topic(Construct, string, ITopicProps?)
A new SNS topic.
public Topic(Construct scope, string id, ITopicProps? props = null)
Parameters
- scope Construct
- id string
- props ITopicProps
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.SNS;
var topic = new Topic(this, "MyTopic");
var topicRule = new TopicRule(this, "TopicRule", new TopicRuleProps {
Sql = IotSql.FromStringAsVer20160323("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'"),
Actions = new [] {
new SnsTopicAction(topic, new SnsTopicActionProps {
MessageFormat = SnsActionMessageFormat.JSON
}) }
});
Properties
AutoCreatePolicy
Controls automatic creation of policy objects.
protected override bool AutoCreatePolicy { get; }
Property Value
Overrides
Remarks
Set by subclasses.
ContentBasedDeduplication
Enables content-based deduplication for FIFO topics.
public override bool ContentBasedDeduplication { get; }
Property Value
Overrides
Remarks
ExampleMetadata: infused
Fifo
Whether this topic is an Amazon SNS FIFO queue.
public override bool Fifo { get; }
Property Value
Overrides
Remarks
If false, this is a standard topic.
MasterKey
A KMS Key, either managed by this CDK app, or imported.
public override IKey? MasterKey { get; }
Property Value
Overrides
Remarks
This property applies only to server-side encryption.
PROPERTY_INJECTION_ID
Uniquely identifies this class.
public static string PROPERTY_INJECTION_ID { get; }
Property Value
Remarks
ExampleMetadata: infused
TopicArn
The ARN of the topic.
public override string TopicArn { get; }
Property Value
Overrides
Remarks
ExampleMetadata: infused
TopicName
The name of the topic.
public override string TopicName { get; }
Property Value
Overrides
Remarks
ExampleMetadata: infused
Methods
AddLoggingConfig(ILoggingConfig)
Adds a delivery status logging configuration to the topic.
public virtual void AddLoggingConfig(ILoggingConfig config)
Parameters
- config ILoggingConfig
Remarks
ExampleMetadata: infused
FromTopicArn(Construct, string, string)
Import an existing SNS topic provided an ARN.
public static ITopic FromTopicArn(Construct scope, string id, string topicArn)
Parameters
- scope Construct
The parent creating construct.
- id string
The construct's name.
- topicArn string
topic ARN (i.e. arn:aws:sns:us-east-2:444455556666:MyTopic).
Returns
Remarks
ExampleMetadata: infused
FromTopicAttributes(Construct, string, ITopicAttributes)
Import an existing SNS topic provided a topic attributes.
public static ITopic FromTopicAttributes(Construct scope, string id, ITopicAttributes attrs)
Parameters
- scope Construct
The parent creating construct.
- id string
The construct's name.
- attrs ITopicAttributes
the attributes of the topic to import.
Returns
Remarks
ExampleMetadata: infused