-
Notifications
You must be signed in to change notification settings - Fork 90
depends_on should wait for template_dir generation #74
Comments
Moving relevant comment over: I took a second look at the template provider documentation for
There is a note prior to that to not use the That said, I would very much like to not have this limitation as otherwise it's not clear how to even use |
As a test I rewrote it to use resource "local_file" "policies" {
for_each = fileset(var.policies, "**/*")
filename = "${path.cwd}/policies/${each.value}"
sensitive_content = templatefile("${var.policies}/${each.value}", {
email = var.recipient_email
sqs_url = aws_sqs_queue.foo.id
})
}
resource "aws_s3_bucket_object" "policies" {
depends_on = [local_file.policies]
for_each = fileset("${path.cwd}/policies/", "**/*")
bucket = data.aws_s3_bucket.this.id
key = "policies/${each.value}"
source = "${path.cwd}/policies/${each.value}"
etag = filemd5("${path.cwd}/policies/${each.value}")
} |
This is a decent workaround: resource "aws_s3_bucket_object" "policies" {
for_each = fileset(var.policy_templates, "**/*")
bucket = data.aws_s3_bucket.this.id
key = "policies/${each.value}"
content = templatefile("${var.policy_templates}/${each.value}", {
email = var.recipient_email
sqs_url = aws_sqs_queue.foo.id
})
} |
This issue was originally opened by @aosman-tibco as hashicorp/terraform#23684. It was migrated here as a result of the provider split. The original body of the issue is below.
Terraform Version
Terraform Configuration Files
Expected Behavior
Templates are generated and aws_s3_bucket_object is aware of them (causing them to be uploaded)
Actual Behavior
Templates are generated and aws_s3_bucket_object is not aware of them, therefore no action is taken. A second apply is required to upload the generated files.
If the generated files are deleted, the aws_s3_bucket_object detects the source files as missing then then deletes the resources (even if the files are generated again). A second apply is required to upload the generated files.
Steps to Reproduce
terraform init
terraform apply
Additional Context
References
The text was updated successfully, but these errors were encountered: