-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.tf
More file actions
49 lines (45 loc) · 1.19 KB
/
Copy pathmain.tf
File metadata and controls
49 lines (45 loc) · 1.19 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
provider "aws" {
version = "2.7.0"
region = "us-west-2"
access_key = "access_key"
secret_key = "secret_key"
skip_credentials_validation = true
skip_requesting_account_id = true
skip_metadata_api_check = true
endpoints {
lambda = "${var.localhost}:4574"
cloudwatch = "${var.localhost}:4582"
iam = "${var.localhost}:4593"
}
}
data "archive_file" "lambda_zip" {
type = "zip"
source_file = "index.js"
output_path = "lambda_function.zip"
}
resource "aws_lambda_function" "test_lambda" {
filename = "lambda_function.zip"
function_name = "test_lambda"
role = aws_iam_role.iam_for_lambda_tf.arn
handler = "index.handler"
source_code_hash = data.archive_file.lambda_zip.output_base64sha256
runtime = "nodejs8.10"
}
resource "aws_iam_role" "iam_for_lambda_tf" {
name = "iam_for_lambda_tf"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}