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.
More on Loops, Conditionals, Dynamic Blocks and Functions
How does `count` work?BeginnerHow does `for_each` work?BeginnerWhen should you choose `for_each` over `count`?IntermediateHow do you use `for_each` with a list of objects?IntermediateWhat does "The for_each value depends on resource attributes that cannot be determined until apply" mean?AdvancedHow do you create a resource conditionally?Beginner