-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathmain.tf
More file actions
71 lines (58 loc) · 1.35 KB
/
main.tf
File metadata and controls
71 lines (58 loc) · 1.35 KB
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
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
}
# Configure the AWS Provider
provider "aws" {
region = "us-east-1"
}
resource "aws_iam_role" "iam_for_lambda" {
name = "iam_for_lambda"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
resource "aws_lambda_layer_version" "test_layer" {
layer_name = "hot_reload_layer"
compatible_runtimes = ["nodejs16.x"]
s3_bucket = "hot-reload"
s3_key = "${abspath(path.root)}/layer_src"
}
resource "aws_lambda_function" "test_lambda" {
# If the file is not in the current working directory you will need to include a
# path.module in the filename.
function_name = "hotreloadlambda"
role = aws_iam_role.iam_for_lambda.arn
handler = "index.handler"
s3_bucket = "hot-reload"
s3_key = "${abspath(path.root)}/lambda_src"
layers = [aws_lambda_layer_version.test_layer.arn]
runtime = "nodejs16.x"
environment {
variables = {
foo = "bar"
}
}
}
output "hot_reloading_lambda_arn" {
value = aws_lambda_function.test_lambda.arn
}
output "hot_reloading_layer_arn" {
value = aws_lambda_layer_version.test_layer.arn
}