forked from IssaDiallo/terraform-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
32 lines (27 loc) · 798 Bytes
/
Copy pathmain.tf
File metadata and controls
32 lines (27 loc) · 798 Bytes
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
# Specify the provider and access details
provider "aws" {
region = var.aws_region
}
data "aws_iam_policy_document" "policy" {
statement {
sid = "lambda-policy-poc"
effect = "Allow"
principals {
identifiers = ["lambda.amazonaws.com"]
type = "Service"
}
actions = ["sts:AssumeRole"]
}
}
resource "aws_iam_role" "iam_for_lambda" {
name = "iam_for_lambda"
assume_role_policy = "${data.aws_iam_policy_document.policy.json}"
}
resource "aws_lambda_function" "lambda" {
function_name = local.function_name
filename = "${data.archive_file.zip.output_path}"
source_code_hash = "${data.archive_file.zip.output_base64sha256}"
role = aws_iam_role.iam_for_lambda.arn
handler = local.handler
runtime = local.runtime
}