Class TopicPolicy
Provides an SNS topic policy resource
NOTE: If a Principal is specified as just an AWS account ID rather than an ARN, AWS silently converts it to the ARN for the root user, causing future deployments to differ. To avoid this problem, just specify the full ARN, e.g.
arn:aws:iam::123456789012:root
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var test = new Aws.Sns.Topic("test", new Aws.Sns.TopicArgs
{
});
var snsTopicPolicy = test.Arn.Apply(arn => Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
{
PolicyId = "__default_policy_ID",
Statements =
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
{
Actions =
{
"SNS:Subscribe",
"SNS:SetTopicAttributes",
"SNS:RemovePermission",
"SNS:Receive",
"SNS:Publish",
"SNS:ListSubscriptionsByTopic",
"SNS:GetTopicAttributes",
"SNS:DeleteTopic",
"SNS:AddPermission",
},
Condition =
{
{
{ "test", "StringEquals" },
{ "values",
{
@var.Account_id,
} },
{ "variable", "AWS:SourceOwner" },
},
},
Effect = "Allow",
Principals =
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalArgs
{
Identifiers =
{
"*",
},
Type = "AWS",
},
},
Resources =
{
arn,
},
Sid = "__default_statement_ID",
},
},
}));
var @default = new Aws.Sns.TopicPolicy("default", new Aws.Sns.TopicPolicyArgs
{
Arn = test.Arn,
Policy = snsTopicPolicy.Apply(snsTopicPolicy => snsTopicPolicy.Json),
});
}
}
Inherited Members
Namespace: Pulumi.Aws.Sns
Assembly: Pulumi.Aws.dll
Syntax
public class TopicPolicy : CustomResource
Constructors
View SourceTopicPolicy(String, TopicPolicyArgs, CustomResourceOptions)
Create a TopicPolicy resource with the given unique name, arguments, and options.
Declaration
public TopicPolicy(string name, TopicPolicyArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| TopicPolicyArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceArn
The ARN of the SNS topic
Declaration
public Output<string> Arn { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Policy
The fully-formed AWS policy as JSON.
Declaration
public Output<string> Policy { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Methods
View SourceGet(String, Input<String>, TopicPolicyState, CustomResourceOptions)
Get an existing TopicPolicy resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static TopicPolicy Get(string name, Input<string> id, TopicPolicyState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| TopicPolicyState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| TopicPolicy |