Skip to content

Instantly share code, notes, and snippets.

@karl-cardenas-coding
Last active December 5, 2020 19:11
Show Gist options
  • Save karl-cardenas-coding/77f7335b3d3d8e50501d5f73781bcece to your computer and use it in GitHub Desktop.
Save karl-cardenas-coding/77f7335b3d3d8e50501d5f73781bcece to your computer and use it in GitHub Desktop.
Example of AWS Lambda with code signing - option 2
######################################
# Lambda Resources Option 2
######################################
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"]
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]
}
// This creates a zip file of our python file and uploads to AWS S3
resource "null_resource" "build_upload" {
# Change the trigger to whatever makes the most sense for your usecase.
triggers = {
time = timestamp()
}
provisioner "local-exec" {
command = <<EOT
zip lambda.zip ./lambda_function.py
aws s3 cp --profile=${var.profile} lambda.zip s3://${var.code-bucket}/unsigned
EOT
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment