Created
February 14, 2019 23:03
-
-
Save 100daysofdevops/fb07c9c4c01ba865b6cc7993cd4eb67e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "aws" { | |
region = "us-west-2" | |
} | |
resource "aws_sns_topic" "topic" { | |
name = "s3-event-notification-topic" | |
policy = <<POLICY | |
{ | |
"Version":"2012-10-17", | |
"Statement":[{ | |
"Effect": "Allow", | |
"Principal": {"AWS":"*"}, | |
"Action": "SNS:Publish", | |
"Resource": "arn:aws:sns:*:*:s3-event-notification-topic", | |
"Condition":{ | |
"ArnLike":{"aws:SourceArn":"${aws_s3_bucket.bucket.arn}"} | |
} | |
}] | |
} | |
POLICY | |
} | |
resource "aws_s3_bucket" "bucket" { | |
bucket = "s3-event-notification-topic-mydemo-bucket" | |
} | |
resource "aws_s3_bucket_notification" "bucket_notification" { | |
bucket = "${aws_s3_bucket.bucket.id}" | |
topic { | |
topic_arn = "${aws_sns_topic.topic.arn}" | |
events = ["s3:ObjectRemoved:*"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment