Interview Prep/Terraform/Loops, Conditionals, Dynamic Blocks and Functions

How do you trigger a resource when a file changes?

IntermediateConceptLoops, Conditionals, Dynamic Blocks and Functions
Answer

Hash the file and use that in a trigger or attribute.

resource "aws_s3_object" "cfg" {
  bucket = aws_s3_bucket.b.id
  key    = "app.conf"
  source = "app.conf"
  etag   = filemd5("app.conf")
}

filebase64sha256 is typical for Lambda source_code_hash.

All Terraform questions Roadmap: Terraform

More on Loops, Conditionals, Dynamic Blocks and Functions