Repository navigation
Expand file tree
/
Copy pathlambda.tf
More file actions
62 lines (47 loc) · 1.48 KB
/
Copy pathlambda.tf
File metadata and controls
62 lines (47 loc) · 1.48 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
data "aws_iam_policy" "ReadOnlyAccess" {
arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}
data "aws_iam_policy" "DynamoDBAccess" {
arn = "arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess"
}
resource "aws_iam_role" "WildRole" {
name = "WildRole1"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "policy-attach-1" {
role = "${aws_iam_role.WildRole.name}"
policy_arn = "${data.aws_iam_policy.DynamoDBAccess.arn}"
}
resource "aws_iam_role_policy_attachment" "policy-attach-2" {
role = "${aws_iam_role.WildRole.name}"
policy_arn = "${data.aws_iam_policy.ReadOnlyAccess.arn}"
}
resource "aws_lambda_function" "test_lambda" {
function_name = "RequestUnicorn"
filename = "lambda_function.zip"
runtime = "nodejs6.10"
handler = "index.js"
role = "${aws_iam_role.WildRole.arn}"
}
/*
resource "aws_lambda_permission" "apigw" {
statement_id = "AllowAPIGatewayInvoke"
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.main.arn}"
principal = "apigateway.amazonaws.com"
source_arn = "arn:aws:execute-api:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:${aws_api_gateway_re}
*/