Namespace Pulumi.Aws.Sns
Classes
GetTopic
GetTopicArgs
GetTopicResult
PlatformApplication
Provides an SNS platform application resource
Example Usage
Apple Push Notification Service (APNS)
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var apnsApplication = new Aws.Sns.PlatformApplication("apnsApplication", new Aws.Sns.PlatformApplicationArgs
{
Platform = "APNS",
PlatformCredential = "<APNS PRIVATE KEY>",
PlatformPrincipal = "<APNS CERTIFICATE>",
});
}
}
Google Cloud Messaging (GCM)
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var gcmApplication = new Aws.Sns.PlatformApplication("gcmApplication", new Aws.Sns.PlatformApplicationArgs
{
Platform = "GCM",
PlatformCredential = "<GCM API KEY>",
});
}
}
PlatformApplicationArgs
PlatformApplicationState
SmsPreferences
Provides a way to set SNS SMS preferences.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var updateSmsPrefs = new Aws.Sns.SmsPreferences("updateSmsPrefs", new Aws.Sns.SmsPreferencesArgs
{
});
}
}
SmsPreferencesArgs
SmsPreferencesState
Topic
Provides an SNS topic resource
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var userUpdates = new Aws.Sns.Topic("userUpdates", new Aws.Sns.TopicArgs
{
});
}
}
Example with Delivery Policy
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var userUpdates = new Aws.Sns.Topic("userUpdates", new Aws.Sns.TopicArgs
{
DeliveryPolicy = @"{
""http"": {
""defaultHealthyRetryPolicy"": {
""minDelayTarget"": 20,
""maxDelayTarget"": 20,
""numRetries"": 3,
""numMaxDelayRetries"": 0,
""numNoDelayRetries"": 0,
""numMinDelayRetries"": 0,
""backoffFunction"": ""linear""
},
""disableSubscriptionOverrides"": false,
""defaultThrottlePolicy"": {
""maxReceivesPerSecond"": 1
}
}
}
",
});
}
}
Example with Server-side encryption (SSE)
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var userUpdates = new Aws.Sns.Topic("userUpdates", new Aws.Sns.TopicArgs
{
KmsMasterKeyId = "alias/aws/sns",
});
}
}
Message Delivery Status Arguments
The <endpoint>_success_feedback_role_arn and <endpoint>_failure_feedback_role_arn arguments are used to give Amazon SNS write access to use CloudWatch Logs on your behalf. The <endpoint>_success_feedback_sample_rate argument is for specifying the sample rate percentage (0-100) of successfully delivered messages. After you configure the <endpoint>_failure_feedback_role_arn argument, then all failed message deliveries generate CloudWatch Logs.
TopicArgs
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),
});
}
}
TopicPolicyArgs
TopicPolicyState
TopicState
TopicSubscription
Provides a resource for subscribing to SNS topics. Requires that an SNS topic exist for the subscription to attach to. This resource allows you to automatically place messages sent to SNS topics in SQS queues, send them as HTTP(S) POST requests to a given endpoint, send SMS messages, or notify devices / applications. The most likely use case will probably be SQS queues.
NOTE: If the SNS topic and SQS queue are in different AWS regions, it is important for the "aws.sns.TopicSubscription" to use an AWS provider that is in the same region of the SNS topic. If the "aws.sns.TopicSubscription" is using a provider with a different region than the SNS topic, the subscription will fail to create.
NOTE: Setup of cross-account subscriptions from SNS topics to SQS queues requires the provider to have access to BOTH accounts.
NOTE: If SNS topic and SQS queue are in different AWS accounts but the same region it is important for the "aws.sns.TopicSubscription" to use the AWS provider of the account with the SQS queue. If "aws.sns.TopicSubscription" is using a Provider with a different account than the SQS queue, the provider creates the subscriptions but does not keep state and tries to re-create the subscription at every apply.
NOTE: If SNS topic and SQS queue are in different AWS accounts and different AWS regions it is important to recognize that the subscription needs to be initiated from the account with the SQS queue but in the region of the SNS topic.