-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
43 lines (35 loc) · 1.03 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
resource "aws_sqs_queue" "queue" {
name = var.sqs_name
tags = {
"Name" = var.tag_name
"Environmeent" = var.env_name
}
}
resource "aws_sqs_queue_policy" "sqs_policy" {
queue_url = aws_sqs_queue.queue.id
policy = data.template_file.sqs_policy_vars.rendered
}
# this resource is conditionally created if dependency var argument is supplied
# when instantianting a module.
# Used for data ingestion to subscribe raised bucket_notification to queue.
resource "aws_s3_bucket_notification" "bucket_notification" {
depends_on = [
var.dependency
]
count = var.dependency != [] ? 1 : 0
bucket = var.bucket_id
queue {
id = aws_sqs_queue.queue.id
queue_arn = aws_sqs_queue.queue.arn
events = ["s3:ObjectCreated:*"]
filter_suffix = ".log"
}
}
# policy separation and template implementation.
data "template_file" "sqs_policy_vars" {
template = file("${path.module}/${var.policy}")
vars = {
resource_arn = aws_sqs_queue.queue.arn
bucket_arn = var.bucket_arn
}
}