Created
December 5, 2020 19:26
-
-
Save karl-cardenas-coding/42a2996b2a39ebdec9ae018662407c05 to your computer and use it in GitHub Desktop.
An example of using AWS Code Signing with a Lambda
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
####################################### | |
# Lambda Resources Option 3 | |
####################################### | |
#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 = aws_signer_signing_job.build_signing_job.signed_object[0]["s3"][0]["key"] | |
s3_key = local.lambdaSource | |
function_name = var.lambda-name | |
handler = "lambda_function.lambda_handler" | |
memory_size = 128 | |
runtime = "python3.8" | |
role = var.lambda-role | |
timeout = 45 | |
code_signing_config_arn = aws_lambda_code_signing_config.abc-signer-profile-config.arn | |
# For option 1 | |
# depends_on = [data.archive_file.lambda_zip] | |
# For option 2 | |
# depends_on = [null_resource.build_upload] | |
tags = var.tags | |
} | |
data "aws_s3_bucket_objects" "signedLambdas" { | |
bucket = var.code-bucket | |
prefix = "signed/" | |
} | |
locals { | |
signedSourceList = data.aws_s3_bucket_objects.signedLambdas.keys | |
lambdaSource = try(local.signedSourceList[0], null) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment