Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created August 29, 2022 18:37
Show Gist options
  • Select an option

  • Save KyMidd/4458bdd909ccf60bfa92c02ef9e0504b to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/4458bdd909ccf60bfa92c02ef9e0504b to your computer and use it in GitHub Desktop.
# Zip up lambda when it changes
data "archive_file" "lambda" {
type = "zip"
source_file = "lambda.js"
output_path = "lambda.zip"
}
resource "aws_lambda_function" "lambda_function" {
filename = "lambda.zip"
function_name = "HttpHeaderShim"
role = aws_iam_role.lambda_role.arn
handler = "lambda.handler"
# Publishes new versions on source update, required for Lambda@Edge with CloudFront
publish = true
# Hash the source file, if it changes, lambda will be updated
source_code_hash = data.archive_file.lambda.output_base64sha256
runtime = "nodejs12.x"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment