Class TopicPolicy
The policy for an SNS Topic.
Inherited Members
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
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
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