Show / Hide Table of Contents

Class TopicPolicy

The policy for an SNS Topic.

Inheritance
object
Resource
TopicPolicy
Implements
IResource
IConstruct
IDependable
IEnvironmentAware
Inherited Members
Resource.IsOwnedResource(IConstruct)
Resource.IsResource(IConstruct)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(string, IArnComponents)
Resource.GetResourceNameAttribute(string)
Resource.Env
Resource.PhysicalName
Resource.Stack
Namespace: Amazon.CDK.AWS.SNS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class TopicPolicy : Resource, IResource, IConstruct, IDependable, IEnvironmentAware
Syntax (vb)
Public Class TopicPolicy Inherits Resource Implements IResource, IConstruct, IDependable, IEnvironmentAware
Remarks

Policies define the operations that are allowed on this resource.

You almost never need to define this construct directly.

All AWS resources that support resource policies have a method called addToResourcePolicy(), which will automatically create a new resource policy if one doesn't exist yet, otherwise it will add to the existing policy.

Prefer to use addToResourcePolicy() instead.

ExampleMetadata: infused

Examples
var topic = new Topic(this, "Topic");
             var policyDocument = new PolicyDocument(new PolicyDocumentProps {
                 AssignSids = true,
                 Statements = new [] {
                     new PolicyStatement(new PolicyStatementProps {
                         Actions = new [] { "sns:Subscribe" },
                         Principals = new [] { new AnyPrincipal() },
                         Resources = new [] { topic.TopicArn }
                     }) }
             });

             var topicPolicy = new TopicPolicy(this, "Policy", new TopicPolicyProps {
                 Topics = new [] { topic },
                 PolicyDocument = policyDocument
             });

Synopsis

Constructors

TopicPolicy(Construct, string, ITopicPolicyProps)

The policy for an SNS Topic.

Properties

Document

The IAM policy document for this policy.

PROPERTY_INJECTION_ID

Uniquely identifies this class.

Methods

CreateSSLPolicyDocument(string)

Adds a statement to enforce encryption of data in transit when publishing to the topic.

Constructors

TopicPolicy(Construct, string, ITopicPolicyProps)

The policy for an SNS Topic.

public TopicPolicy(Construct scope, string id, ITopicPolicyProps props)
Parameters
scope Construct
id string
props ITopicPolicyProps
Remarks

Policies define the operations that are allowed on this resource.

You almost never need to define this construct directly.

All AWS resources that support resource policies have a method called addToResourcePolicy(), which will automatically create a new resource policy if one doesn't exist yet, otherwise it will add to the existing policy.

Prefer to use addToResourcePolicy() instead.

ExampleMetadata: infused

Examples
var topic = new Topic(this, "Topic");
             var policyDocument = new PolicyDocument(new PolicyDocumentProps {
                 AssignSids = true,
                 Statements = new [] {
                     new PolicyStatement(new PolicyStatementProps {
                         Actions = new [] { "sns:Subscribe" },
                         Principals = new [] { new AnyPrincipal() },
                         Resources = new [] { topic.TopicArn }
                     }) }
             });

             var topicPolicy = new TopicPolicy(this, "Policy", new TopicPolicyProps {
                 Topics = new [] { topic },
                 PolicyDocument = policyDocument
             });

Properties

Document

The IAM policy document for this policy.

public virtual PolicyDocument Document { get; }
Property Value

PolicyDocument

Remarks

Policies define the operations that are allowed on this resource.

You almost never need to define this construct directly.

All AWS resources that support resource policies have a method called addToResourcePolicy(), which will automatically create a new resource policy if one doesn't exist yet, otherwise it will add to the existing policy.

Prefer to use addToResourcePolicy() instead.

ExampleMetadata: infused

PROPERTY_INJECTION_ID

Uniquely identifies this class.

public static string PROPERTY_INJECTION_ID { get; }
Property Value

string

Remarks

Policies define the operations that are allowed on this resource.

You almost never need to define this construct directly.

All AWS resources that support resource policies have a method called addToResourcePolicy(), which will automatically create a new resource policy if one doesn't exist yet, otherwise it will add to the existing policy.

Prefer to use addToResourcePolicy() instead.

ExampleMetadata: infused

Methods

CreateSSLPolicyDocument(string)

Adds a statement to enforce encryption of data in transit when publishing to the topic.

protected virtual PolicyStatement CreateSSLPolicyDocument(string topicArn)
Parameters
topicArn string
Returns

PolicyStatement

Remarks

For more information, see https://docs.aws.amazon.com/sns/latest/dg/sns-security-best-practices.html#enforce-encryption-data-in-transit.

Implements

IResource
Constructs.IConstruct
Constructs.IDependable
IEnvironmentAware
Back to top Generated by DocFX