-
Notifications
You must be signed in to change notification settings - Fork 7
/
sqs.tf
52 lines (47 loc) · 1.44 KB
/
sqs.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
/**
* Copyright (C) 2019-2021 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
resource "aws_sqs_queue" "beekeeper" {
name = local.queue_alias
message_retention_seconds = var.message_retention_seconds
receive_wait_time_seconds = var.receive_wait_time_seconds
redrive_policy = "{\"deadLetterTargetArn\":\"${aws_sqs_queue.beekeeper_dead_letter.arn}\",\"maxReceiveCount\":4}"
tags = var.beekeeper_tags
}
resource "aws_sqs_queue" "beekeeper_dead_letter" {
name = "${local.queue_alias}-dead-letter"
message_retention_seconds = var.message_retention_seconds
receive_wait_time_seconds = var.receive_wait_time_seconds
tags = var.beekeeper_tags
}
resource "aws_sns_topic_subscription" "beekeeper_apiary" {
topic_arn = var.apiary_metastore_listener_arn
protocol = "sqs"
endpoint = aws_sqs_queue.beekeeper.arn
}
resource "aws_sqs_queue_policy" "beekeeper" {
queue_url = aws_sqs_queue.beekeeper.id
policy = <<POLICY
{
"Version": "2012-10-17",
"Id": "Allow Apiary Metadata Events",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "sqs:SendMessage",
"Resource": "${aws_sqs_queue.beekeeper.arn}",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "${var.apiary_metastore_listener_arn}"
}
}
}
]
}
POLICY
}