forked from claranet/terraform-aws-asg-instance-alarms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambda.tf
62 lines (49 loc) · 1.05 KB
/
lambda.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
module "lambda" {
source = "github.com/claranet/terraform-aws-lambda?ref=v1.1.0"
function_name = var.name
description = "Manages ASG instance alarms"
handler = "lambda.lambda_handler"
runtime = "python3.6"
layers = var.lambda_layers
timeout = 30
source_path = "${path.module}/lambda.py"
environment = {
variables = {
ALARM_TEMPLATES_BUCKET = aws_s3_bucket.alarm_templates.id
}
}
policy = {
json = data.aws_iam_policy_document.lambda.json
}
}
data "aws_iam_policy_document" "lambda" {
statement {
effect = "Allow"
actions = [
"autoscaling:DescribeAutoScalingGroups",
]
resources = [
"*",
]
}
statement {
effect = "Allow"
actions = [
"cloudwatch:DeleteAlarms",
"cloudwatch:DescribeAlarms",
"cloudwatch:PutMetricAlarm",
]
resources = [
"*",
]
}
statement {
effect = "Allow"
actions = [
"s3:GetObject",
]
resources = [
"arn:aws:s3:::${aws_s3_bucket.alarm_templates.id}/*",
]
}
}