AWS Amazon SNS Topic Policy
This page shows how to write Terraform and CloudFormation for Amazon SNS Topic Policy and write them securely.
aws_sns_topic_policy (Terraform)
The Topic Policy in Amazon SNS can be configured in Terraform with the resource name aws_sns_topic_policy
. The following sections describe 4 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_sns_topic_policy" "invalid_policy_a" {
arn = aws_sns_topic.test_a.arn
policy = <<EOF
{
"Version": "2012-10-17",
resource "aws_sns_topic_policy" "sns_policy_allow_no_wildcard" {
arn = "arn:aws:sns:us-east-1:123456789012:test-topic"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
resource "aws_sns_topic_policy" "policy_statement_allow_principal_without_wildcard" {
arn = aws_sns_topic.test_topic.arn
policy = <<EOF
{
"Version": "2012-10-17",
resource "aws_sns_topic_policy" "sns_policy_allow_no_wildcard" {
arn = "arn:aws:sns:us-east-1:123456789012:test-topic"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
Parameters
Explanation in Terraform Registry
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 terraform plans to differ. To avoid this problem, just specify the full ARN, e.g.,
arn:aws:iam::123456789012:root
AWS::SNS::TopicPolicy (CloudFormation)
The TopicPolicy in SNS can be configured in CloudFormation with the resource name AWS::SNS::TopicPolicy
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: AWS::SNS::TopicPolicy
Properties:
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowAllToRequestEnrichment
Type: AWS::SNS::TopicPolicy
Properties:
Topics:
- !Ref SNSAllConfigurationTopic
PolicyDocument:
Statement:
Type: AWS::SNS::TopicPolicy
Properties:
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: UploadTopicPolicy
Type: AWS::SNS::TopicPolicy
Properties:
PolicyDocument:
Id: CaptureTopicPolicy
Version: '2012-10-17'
Statement:
Type: AWS::SNS::TopicPolicy
Properties:
Topics:
- !Ref SNSRestorePost
PolicyDocument:
Id: SNSTopicPolicy
"Type": "AWS::SNS::TopicPolicy",
"Properties": {
"PolicyDocument": {
"Id": "MyTopicPolicy",
"Version": "2012-10-17",
"Statement": [
"Type" : "AWS::SNS::TopicPolicy",
"Properties" : {
"PolicyDocument" : {
"Id" : "MyTopicPolicy",
"Version" : "2012-10-17",
"Statement" : [ {
"Type" : "AWS::SNS::TopicPolicy",
"Properties" : {
"PolicyDocument" : {
"Id" : "MyTopicPolicy",
"Version" : "2012-10-17",
"Statement" : [ {
"Type" : "AWS::SNS::TopicPolicy",
"Properties" : {
"PolicyDocument" : {
"Id" : "MyTopicPolicy",
"Version" : "2012-10-17",
"Statement" : [ {
"Type" : "AWS::SNS::TopicPolicy",
"Properties" : {
"PolicyDocument" : {
"Id" : "MyTopicPolicy",
"Version" : "2012-10-17",
"Statement" : [ {
Parameters
-
PolicyDocument
required - Json -
Topics
required - List
Explanation in CloudFormation Registry
The
AWS::SNS::TopicPolicy
resource associates Amazon SNS topics with a policy. For an example snippet, see Declaring an Amazon SNS policy in the AWS CloudFormation User Guide.
Frequently asked questions
What is AWS Amazon SNS Topic Policy?
AWS Amazon SNS Topic Policy is a resource for Amazon SNS of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS Amazon SNS Topic Policy?
For Terraform, the Cigna/confectionery, stelligent/config-lint and stelligent/config-lint source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the ec-europa/eubfr-data-lake, matsuura0831/aws and kevinbmccall14/affidavit_generator_serverless source code examples are useful. See the CloudFormation Example section for further details.