Created
July 22, 2022 20:04
-
-
Save nhammad/82c5a655df3e4ba3f380d687f36e52d4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
data "archive_file" "lambda_zip" { | |
type = "zip" | |
source_file = "${path.module}/src/scheulde_test.py" | |
output_file_mode = "0666" | |
output_path = "${path.module}/bin/scheulde_test.py.zip" | |
} | |
resource "aws_lambda_function" "processing_lambda" { | |
filename = data.archive_file.lambda_zip.output_path | |
function_name = local.processing_lambda_name | |
handler = "scheulde_test.lambda_handler" | |
source_code_hash = data.archive_file.lambda_zip.output_base64sha256 | |
role = aws_iam_role.processing_lambda_role.arn | |
runtime = "python3.9" | |
timeout = 900 | |
memory_size = 10240 | |
tags = var.config.tags | |
} | |
resource "aws_iam_role" "processing_lambda_role" { | |
name = local.processing_lambda_role_name | |
path = "/service-role/" | |
permissions_boundary = local.config.permission_boundary_arn | |
assume_role_policy = data.aws_iam_policy_document.assume-role-policy_document.json | |
inline_policy { | |
name = "test_policy" | |
policy = data.aws_iam_policy_document.test_policy_document.json | |
} | |
} | |
data "aws_iam_policy_document" "assume-role-policy_document" { | |
statement { | |
actions = ["sts:AssumeRole"] | |
principals { | |
type = "Service" | |
identifiers = ["lambda.amazonaws.com"] | |
} | |
} | |
} | |
data "aws_iam_policy_document" "test_policy_document" { | |
statement { | |
actions = [ | |
"logs:CreateLogGroup", | |
"logs:CreateLogStream", | |
"logs:PutLogEvents", | |
"logs:AssociateKmsKey" | |
] | |
resources = ["*"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment