-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
98 lines (80 loc) · 1.79 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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
terraform {
required_providers {
aws = {
version = "3.4.0"
}
}
}
module "apigw" {
source = "armorfret/apigw-lambda/aws"
version = "0.1.6"
source_bucket = var.lambda_bucket
source_version = var.lambda_version
function_name = "feefifofum_${var.config_bucket}"
environment_variables = {
S3_BUCKET = "${var.config_bucket}"
S3_KEY = "config.yaml"
}
access_policy_document = data.aws_iam_policy_document.lambda_perms.json
hostname = var.hostname
}
module "publish_user" {
source = "armorfret/s3-publish/aws"
version = "0.2.4"
logging_bucket = var.logging_bucket
publish_bucket = var.data_bucket
}
module "config_user" {
source = "armorfret/s3-publish/aws"
version = "0.2.4"
logging_bucket = var.logging_bucket
publish_bucket = var.config_bucket
}
resource "aws_sqs_queue" "data_queue" {
name = var.data_queue
policy = data.aws_iam_policy_document.sqs_perms.json
}
data "aws_iam_policy_document" "lambda_perms" {
statement {
actions = [
"s3:ListBucket",
"s3:GetObject",
]
resources = [
"arn:aws:s3:::${var.config_bucket}/*",
"arn:aws:s3:::${var.config_bucket}",
]
}
statement {
actions = [
"s3:ListBucket",
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
]
resources = [
"arn:aws:s3:::${var.data_bucket}/*",
"arn:aws:s3:::${var.data_bucket}",
]
}
statement {
actions = [
"sqs:SendMessage",
"sqs:ReceiveMessage",
"sqs:DeleteMessage",
]
resources = [
"${aws_sqs_queue.data_queue.arn}",
]
}
statement {
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
]
resources = [
"arn:aws:logs:*:*:*",
]
}
}