generated from terraform-modules/template_aws_module
-
Notifications
You must be signed in to change notification settings - Fork 1
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
7 changed files
with
69 additions
and
1 deletion.
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
Binary file not shown.
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 @@ | ||
| ../defaults.tf |
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,20 @@ | ||
| locals { | ||
| lambda_file = format("%v.zip", local._defaults["lambda_file"]) | ||
| lambda_code_files = [ | ||
| "ddns-lambda.py", | ||
| ] | ||
| # this gets a sha256hash of each file, and then a sha256 hash of the comma-separated hashes. This will help determine | ||
| # to make a new zip file or not | ||
| lambda_code_files_hashes = { for f in local.lambda_code_files : f => filesha256(f) } | ||
| lambda_files_hash = sha256(join(",", values(local.lambda_code_files_hashes))) | ||
| } | ||
|
|
||
| resource "null_resource" "zip" { | ||
| triggers = { | ||
| lambda_files_hash = local.lambda_files_hash | ||
| } | ||
|
|
||
| provisioner "local-exec" { | ||
| command = "zip ${local.lambda_file} -j -r ${join(" ", local.lambda_code_files)}" | ||
| } | ||
| } |
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
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 @@ | ||
| locals { | ||
| lambda_environment_variables = lookup(var.lambda_environment_variables, "DynamoDBName", null) != null ? var.lambda_environment_variables : merge( | ||
| var.lambda_environment_variables, | ||
| tomap({ "DynamoDBName" = local.dynamodb_table_name }), | ||
| ) | ||
| lambda_file = format("%v/code/%v.zip", path.module, local._defaults["lambda_file"]) | ||
| } | ||
|
|
||
| resource "aws_lambda_function" "lambda" { | ||
| function_name = local.lambda_name | ||
| handler = local._defaults["lambda_handler"] | ||
| memory_size = 128 | ||
| reserved_concurrent_executions = -1 | ||
| role = aws_iam_role.role.arn | ||
| runtime = "python3.9" | ||
| source_code_hash = filebase64sha256(local.lambda_file) | ||
| filename = local.lambda_file | ||
| timeout = 30 | ||
| # version = "$LATEST" | ||
|
|
||
| environment { | ||
| variables = local.lambda_environment_varaibles | ||
| } | ||
| timeouts {} | ||
| tracing_config { | ||
| mode = "PassThrough" | ||
| } | ||
| tags = merge( | ||
| local.base_tags, | ||
| var.tags, | ||
| map("Name", local.lambda_name) | ||
| ) | ||
| } |
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