Skip to content

Support an updated template_file until string templates are in terraform core #47

@nitrocode

Description

@nitrocode

Have a question? Please checkout our Slack Community or visit our Slack Archive.

Slack Community

Describe the Feature

The templatefile function cannot use a string. It has to use a file that has been created prior to the terraform commands.

Feature would be similar to the archived template_file data source

Unfortunately hashicorp/terraform-provider-template has been archived before darwin osx supported binary was released.

This maybe... would be a stop gap solution until PR hashicorp/terraform#28700 is implemented.

Expected Behavior

Allow creating template strings without having to create the file

Use Case

For example, if you use a data source with templated variables like the data source aws_iam_policy_document, you could previously feed in its json text into the template_file data source and allow replacements. With templatefile, you can no longer do this easily.

Describe Ideal Solution

Ideal solution would be to implement a templatestring() but custom providers cannot add new functions.

So the ideal solution would be to recreate the original data source template_file.

Alternatives Considered

  • Manually create a template file containing the iam policy document, add in the appropriate variables, then use templatefile to replace them.
  • Use multiple replace functions which is pretty hacky and could cause issues (example)

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions