-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsns.tf
79 lines (74 loc) · 2.01 KB
/
sns.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# SNS topic for instance creation lifecyclehook
resource "aws_sns_topic" "dns_register_topic" {
name = "dns_register_topic"
//TODO: Move this to /assets/deliver_policy.json as a file instead of an inline policy.
delivery_policy = <<EOF
{
"http": {
"defaultHealthyRetryPolicy": {
"minDelayTarget": 20,
"maxDelayTarget": 20,
"numRetries": 3,
"numMaxDelayRetries": 0,
"numNoDelayRetries": 0,
"numMinDelayRetries": 0,
"backoffFunction": "linear"
},
"disableSubscriptionOverrides": false,
"defaultThrottlePolicy": {
"maxReceivesPerSecond": 1
}
}
}
EOF
depends_on = [
aws_lambda_function.register
]
}
# SNS topic for instance termination lifecyclehook
resource "aws_sns_topic" "dns_deregister_topic" {
name = "dns_deregister_topic"
//TODO: Move this to /assets/deliver_policy.json as a file instead of an inline policy.
delivery_policy = <<EOF
{
"http": {
"defaultHealthyRetryPolicy": {
"minDelayTarget": 20,
"maxDelayTarget": 20,
"numRetries": 3,
"numMaxDelayRetries": 0,
"numNoDelayRetries": 0,
"numMinDelayRetries": 0,
"backoffFunction": "linear"
},
"disableSubscriptionOverrides": false,
"defaultThrottlePolicy": {
"maxReceivesPerSecond": 1
}
}
}
EOF
depends_on = [
aws_lambda_function.deregister
]
}
# DNS registration SNS - Lambda subscription
resource "aws_sns_topic_subscription" "sns_register_lambda_subscription" {
topic_arn = aws_sns_topic.dns_register_topic.arn
protocol = "lambda"
endpoint = aws_lambda_function.register.arn
depends_on = [
aws_lambda_function.register,
aws_sns_topic.dns_register_topic
]
}
# DNS deregistration SNS - Lambda subscription
resource "aws_sns_topic_subscription" "sns_deregister_lambda_subscription" {
topic_arn = aws_sns_topic.dns_deregister_topic.arn
protocol = "lambda"
endpoint = aws_lambda_function.deregister.arn
depends_on = [
aws_lambda_function.deregister,
aws_sns_topic.dns_deregister_topic
]
}