Last active
December 6, 2020 01:02
-
-
Save karl-cardenas-coding/cdffce4a3a1e576f542e3aad6cae543a to your computer and use it in GitHub Desktop.
Revisions
-
karl-cardenas-coding revised this gist
Dec 6, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,13 +5,15 @@ resource "aws_lambda_function" "test_lambda" { s3_bucket = var.code-bucket s3_key = local.signedSourceList[index(local.trimPrefix, "lambda")] # ^ Returns "signed/lambda-3ed11736-6655-4448-935d-659cd0428b90.zip" .... .... } resource "aws_lambda_function" "test_lambda_2" { s3_bucket = var.code-bucket s3_key = local.signedSourceList[index(local.trimPrefix, "postBooks")] # ^ Returns "signed/postBooks-fa44bbee-9f5b-455d-7cfd-14450e4679d.zip" .... .... } -
karl-cardenas-coding revised this gist
Dec 6, 2020 . 1 changed file with 10 additions and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,19 @@ ################################################ # Lambda Resources Option 3 - Multiple Lambdas ################################################ #In this scenario the Lambda is zipped and upload outside of the terraform execution resource "aws_lambda_function" "test_lambda" { s3_bucket = var.code-bucket s3_key = local.signedSourceList[index(local.trimPrefix, "lambda")] .... .... } resource "aws_lambda_function" "test_lambda_2" { s3_bucket = var.code-bucket s3_key = local.signedSourceList[index(local.trimPrefix, "postBooks")] .... .... } data "aws_s3_bucket_objects" "signedLambdas" { @@ -27,5 +23,6 @@ data "aws_s3_bucket_objects" "signedLambdas" { locals { signedSourceList = data.aws_s3_bucket_objects.signedLambdas.keys lambdaSource = try(local.signedSourceList[0], null) trimPrefix = [ for item in local.signedSourceList : split("-", trimprefix(item, "signed/"))[0]] } -
karl-cardenas-coding created this gist
Dec 6, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ # Lambda Resources Option 3 ####################################### #In this scenario the Lambda is zipped and upload outside of the terraform execution resource "aws_lambda_function" "test_lambda-lambda-1" { s3_bucket = var.code-bucket s3_key = local.signedSourceList[index(local.trimPrefix, "getBooks")] .... .... tags = var.tags } #In this scenario the Lambda is zipped and upload outside of the terraform execution resource "aws_lambda_function" "test_lambda-lambda-2" { s3_bucket = var.code-bucket s3_key = local.signedSourceList[index(local.trimPrefix, "postBooks")] .... .... tags = var.tags } data "aws_s3_bucket_objects" "signedLambdas" { bucket = var.code-bucket prefix = "signed/" } locals { signedSourceList = data.aws_s3_bucket_objects.signedLambdas.keys trimPrefix = [ for item in local.signedSourceList : split("-", trimprefix(item, "signed/"))[0]] }