Bad workmen – a Terraform Lambda deployment story

You know the old adage of “a bad workman blames their tools”? Well, guilty as charged…

When I built my AWS-cardspotter project with Terraform, the main goal was to learn Terraform, which I had no/limited/not-enough experience with at the time. Looking back at that initial deployment (it’s awful, please don’t judge me, or use as a reference point for anything in production workloads…), one of the criticisms I’d laid against Terraform was the need for a separate built step, bundling the Lambda’s code to a zip archive prior to being deployed with Terraform. As you might have guessed from the title and opening of this post, I was wrong.

Introducing the all powerful (well, useful) archive_file data block:

data "archive_file" "spotter_lambda_archive" {
  type        = "zip"
  source_dir = "../AWS-card-spotter/Lambda/"
  output_path = "AWS-card-spotter_LAMBDA.zip"
}

Simple as that.


Andrew

Leave a comment

Your email address will not be published. Required fields are marked *