hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.46k stars 4.54k forks source link

Support for source_content in azurerm_storage_share_file #9927

Open amasover opened 3 years ago

amasover commented 3 years ago

Community Note

Description

Thanks to the maintainers/implementers for your hard work on azurerm_storage_share_file! It would be nice to also have a source_content argument to define files inline, similar to azurerm_storage_blob.

New or Affected Resource(s)

Potential Terraform Configuration

resource "azurerm_storage_share_file" "example" {
  name             = "my-shopping-list.txt"
  storage_share_id = azurerm_storage_share.example.id
  source_content   = <<-EOT
    My shopping list:
    * eggs
    * bananas
    * kiwis
    * milk tea
  EOT
}

References

Kukunin commented 3 years ago

This feature would allow rendering templates in to share files

hterik commented 2 years ago

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.

edvardvb commented 1 year ago

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!

FakieHeelflip commented 7 months ago

Sadly I recognize no effort to implement this feature. Are there any plans to support this?

NSimpragaVolur commented 7 months ago

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_fileon 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.

lkurzyniec commented 7 months ago

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
}
syepes commented 5 months ago

+1

lineardraft commented 1 week ago

+1