Member-only story

Unable To Get Terraform To Recognize Changes To Your Golang Program? — Here’s What To Do.

Don’t let this stop you from learning lambda

Aravind
2 min readJun 24, 2023
Photo by Elisa Ventur on Unsplash

Problem

So you’ve toiled and made further changes to your main.go file and wish to quickly deploy it to AWS.

You’re new to this and you run the usual command shown below to apply your Terraform changes.

AWS_PROFILE=<your-profile-name> terraform apply

Terraform thinks for a few minutes and provides this output which has you baffling.

You absolutely made changes to your go.main file. You also ran go build -o bin/main main.go to create a brand new executable.

Within terraform, you have defined a datasource block to zip up the file, like so…

data "archive_file" "lambda_zip" {
type = "zip"
source_file = "bin/main"
output_path = "bin/lambda_function_payload.zip"
}

and you have referenced this in your lambda file, like so…

resource "aws_lambda_function" "sqs_parser" {
filename = "bin/lambda_function_payload.zip"
function_name = "sqs-parser"
role = aws_iam_role.iam_for_lambda.arn
handler = "main"
runtime = "go1.x"
}

--

--

Aravind
Aravind

Written by Aravind

I help you continuously improve your life, ranging from health, serverless/devops & mindset. Personal views.

No responses yet