-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.tf
69 lines (58 loc) · 1.59 KB
/
data.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
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
data "aws_kms_secrets" "secret_value" {
secret {
name = "slack_webhook_url"
payload = var.encripted_slack_webhook_url
}
}
data "aws_iam_policy_document" "assume_role" {
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
actions = ["sts:AssumeRole"]
}
}
data "aws_iam_policy_document" "inline_policy" {
statement {
actions = [
"secretsmanager:GetSecretValue"
]
resources = [
aws_secretsmanager_secret.secret.arn
]
}
statement {
actions = [
"ce:ListSavingsPlansPurchaseRecommendationGeneration",
"ce:ListCostAllocationTags",
"ce:GetCostAndUsage",
"ce:ListCostCategoryDefinitions",
"ce:GetCostForecast"
]
resources = [
"arn:aws:ce:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:/GetCostAndUsage",
"arn:aws:ce:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:/GetCostForecast"
]
}
statement {
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
]
resources = [
"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:log-group:/aws/lambda/*"
]
}
}
data "archive_file" "lambda_deployment_package" {
depends_on = [null_resource.pip_installation]
type = "zip"
source_dir = "${path.module}/lambda"
output_path = "${path.module}/cost_monitor.zip"
output_file_mode = "0666"
}