-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
data "aws_iam_policy_document" "lambda_assume_role" { | ||
statement { | ||
effect = "Allow" | ||
|
||
principals { | ||
type = "Service" | ||
identifiers = ["lambda.amazonaws.com"] | ||
} | ||
|
||
actions = ["sts:AssumeRole"] | ||
} | ||
} | ||
|
||
resource "aws_iam_role" "iam_for_lambda" { | ||
name = "LambdaIam" | ||
assume_role_policy = data.aws_iam_policy_document.lambda_assume_role.json | ||
} | ||
|
||
data "aws_iam_policy_document" "lambda_policy_doc" { | ||
statement { | ||
effect = "Allow" | ||
actions = var.lambda_iam_actions | ||
|
||
resources = var.lambda_iam_resources | ||
} | ||
} | ||
|
||
resource "aws_iam_policy" "lambda_permissions" { | ||
name = "lambda_permissions" | ||
path = "/" | ||
description = "IAM policy for Lambda" | ||
policy = data.aws_iam_policy_document.lambda_policy_doc.json | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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. | ||
filename = "lambda_function_payload.zip" | ||
function_name = "lambda_function_name" | ||
role = aws_iam_role.iam_for_lambda.arn | ||
handler = "index.test" | ||
|
||
source_code_hash = data.archive_file.lambda.output_base64sha256 | ||
|
||
runtime = "nodejs18.x" | ||
|
||
environment { | ||
variables = { | ||
foo = "bar" | ||
} | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
provider "aws" { | ||
region = var.region | ||
access_key = var.access_key | ||
secret_key = var.secret_key | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
variable access_key { | ||
type = string | ||
} | ||
|
||
variable secret_key { | ||
type = string | ||
} | ||
|
||
variable region { | ||
type = string | ||
} | ||
|
||
variable lambda_name { | ||
type = string | ||
} | ||
|
||
variable env_vars { | ||
type = list(object({ | ||
name = string | ||
value = string | ||
})) | ||
} | ||
|
||
variable lambda_iam_actions { | ||
type = list(string) | ||
} | ||
|
||
variable lambda_iam_resources { | ||
type = list(string) | ||
} |