0.7.2
resource "template_file" "lambda" {
template = "${file("${path.module}/templates/lambda.js.tpl")}"
vars {
environment = "${var.environment}"
id = "${var.id}"
}
}
resource "archive_file" "lambda" {
type = "zip"
source_content = "${template_file.lambda.rendered}"
source_content_filename = "lambda.js"
output_path = "${path.module}/lambda/lambda.zip"
}
resource "aws_lambda_function" "force_ebs_backup_lambda" {
filename = "${archive_file.lambda.output_path}"
source_code_hash = "${archive_file.lambda.output_sha}"
...
}
Update - It's the same with data sources based templates too.
terraform plan keeps showing that there is change in the source_code_hash of the lambda
Hash should not change with no change in content
terraform plan keeps showing that there is change in the source_code_hash of the lambda
/cc @BSick7
Somewhat related: #8492 works to migrate archive_file to datasource to prevent recreation in atlas.
I came here to file the same issue:
my understanding that archive_file.file.output_sha is generating SHA1, while Lambda expecting/providing SHA256.
archive_file.file.output_sha is generating SHA1, while Lambda expecting/providing SHA256.
Going through the code, I had come to the same realization. Calculating the sha256 as needed from the file instead of using the the output_sha as a workaround.
The fix #8492 to make archive_file a datasource includes an exported attribute output_base64sha256.
@BSick7 Awesome, good to know!
Closed vis #8492 - this will be released in Terraform 0.7.8
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
Closed vis #8492 - this will be released in Terraform 0.7.8