This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
118 lines (104 loc) · 2.42 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.44.0"
}
}
backend "s3" {
bucket = "shopware-gh-import"
key = "tf"
region = "eu-central-1"
}
}
provider "aws" {
region = "eu-central-1"
}
module "lambda_function" {
source = "terraform-aws-modules/lambda/aws"
function_name = "gh-slack-import"
handler = "bootstrap"
runtime = "provided.al2"
memory_size = 128
architectures = ["arm64"]
timeout = 60
source_path = [{
path = "lambda/slack"
commands = [
"CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bootstrap",
":zip",
],
patterns = [
"!.*",
"bootstrap",
]
}]
environment_variables = merge(
var.lambda_env,
{
"SQS_IMPORT_QUEUE" = aws_sqs_queue.gh-import-queue.url
}
)
create_lambda_function_url = true
attach_policy_statements = true
policy_statements = {
sqs = {
effect = "Allow",
actions = ["sqs:SendMessage"],
resources = [aws_sqs_queue.gh-import-queue.arn]
}
}
}
module "queue" {
source = "terraform-aws-modules/lambda/aws"
function_name = "gh-slack-queue"
handler = "bootstrap"
runtime = "provided.al2"
memory_size = 2048
architectures = ["arm64"]
timeout = 300
source_path = [{
path = "lambda/importer"
commands = [
"CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bootstrap",
":zip",
],
patterns = [
"!.*",
"bootstrap",
]
}]
environment_variables = merge(
var.lambda_env,
{
"SQS_IMPORT_QUEUE" = aws_sqs_queue.gh-import-queue.url
}
)
layers = [
"arn:aws:lambda:eu-central-1:094913474201:layer:shyim-git-arm64:3"
]
attach_policy_statements = true
policy_statements = {
sqs = {
effect = "Allow",
actions = ["sqs:ReceiveMessage", "sqs:DeleteMessage", "sqs:GetQueueAttributes"],
resources = [aws_sqs_queue.gh-import-queue.arn]
}
}
event_source_mapping = {
sqs = {
event_source_arn = aws_sqs_queue.gh-import-queue.arn
function_response_types = ["ReportBatchItemFailures"]
scaling_config = {
maximum_concurrency = 2
}
}
}
}
resource "aws_sqs_queue" "gh-import-queue" {
name = "gh-import-queue"
visibility_timeout_seconds = 300
}
output "url" {
value = module.lambda_function.lambda_function_url
}