Open amasover opened 3 years ago
This feature would allow rendering templates in to share files
See https://github.com/hashicorp/terraform/issues/17008#issuecomment-920222911 and https://github.com/hashicorp/terraform/issues/21308 on why using tempfile for scenarios like this will likely not be supported, and why providers should prefer source_content over source-path.
Are there any plans to support this? :)
We need to create the files from templates, and we can't store the content in version control, so we currently have to provision a local file via templatefile
to a git-ignored folder, which leads to a convoluted workflow with a lot of unnecessary and noisy diffs.
The opportunity to use templatefile
and pass it directly as the source to this resource would reduce complexity a lot for us!
Sadly I recognize no effort to implement this feature. Are there any plans to support this?
Same need here - I got a lot of configuration files I volume-mount to my containers using azurerm_storage_share_file
.
The configuration files live in version control as .tpl
templates, and it would be awesome if azurerm_storage_share_file
supported source_content
, because as it stands now I need to create a local_sensitive_file
on the runner before I can upload it to the azurerm_storage_share_file
.
This, as was previously said, creates a lot of noisy diffs and introduces complexity into the workflow! With the source_content
, the configuration files can be created directly from the data.template_file
's rendered
property, instead of the local_sensitive_file
.
As a workaround, I'm using external, as follows:
data "external" "supply_variables" {
program = [
"bash",
"${path.module}/supply-variables.sh",
]
query = {
env = "dev"
module_path = path.module
}
}
#!/bin/bash
set -e
eval "$(jq -r '@sh "ENV=\(.env) MODULE_PATH=\(.module_path)"')"
source_path="$MODULE_PATH/some-template.josn"
destination_path="$MODULE_PATH/some-template-supplied.json"
cp -f "$source_path" "$destination_path"
env_token='${env}'
sed -i "s|$env_token|$ENV|" $destination_path
jq -n --arg path "$destination_path" '{"result_file_path":$path}'
resource "azurerm_storage_share_file" "share_file" {
name = "some-config.json"
storage_share_id = azurerm_storage_share.this.id
source = data.external.supply_variables.result.result_file_path
}
+1
+1
Community Note
Description
Thanks to the maintainers/implementers for your hard work on
azurerm_storage_share_file
! It would be nice to also have asource_content
argument to define files inline, similar toazurerm_storage_blob
.New or Affected Resource(s)
Potential Terraform Configuration
References
5132