-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
55 lines (50 loc) · 1.34 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
provider "aws" {
version = "2.4.0"
region = "eu-west-1"
access_key = "anaccesskey"
secret_key = "asecretkey"
skip_credentials_validation = true
skip_requesting_account_id = true
skip_metadata_api_check = true
s3_force_path_style = true
endpoints {
s3 = "http://localhost:4572"
sns = "http://localhost:4575"
sqs = "http://localhost:4576"
}
}
resource "aws_sqs_queue" "queue" {
name = "s3-event-notification-queue"
policy = <<POLICY
{
"Version":"2012-10-17",
"Statement":[
{
"Effect" : "Allow",
"Principal":"*",
"Action":"sqs:SendMessage",
"Resource":"arn:aws:sqs:*:*:s3-event-notification-queue",
"Condition":{
"ArnEquals":{"aws:SourceArn":"${aws_s3_bucket.bucket.arn}"}
}
}
]
}
POLICY
}
resource "random_string" "id" {
length = "5"
special = false
upper = false
}
resource "aws_s3_bucket" "bucket" {
bucket = "mybucket-s3-g2-${random_string.id.result}"
}
resource "aws_s3_bucket_notification" "bucket_notification" {
#count = "${var.event ? 1 : 0}"
bucket = "${aws_s3_bucket.bucket.id}"
queue {
queue_arn = "${aws_sqs_queue.queue.arn}"
events = ["s3:ObjectCreated:Put"]
}
}