Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Use templatefile function when possible rather than template_file resource #196

Closed
invidian opened this issue Mar 19, 2020 · 4 comments · Fixed by #1046
Closed

Use templatefile function when possible rather than template_file resource #196

invidian opened this issue Mar 19, 2020 · 4 comments · Fixed by #1046
Assignees
Labels
technical-debt Technical debt-related issues

Comments

@invidian
Copy link
Member

Prior to Terraform 0.12, template_file resource was used to do templating in Terraform. With 0.12, now templatefile function should be used instead.

invidian added a commit that referenced this issue Mar 20, 2020
Part of #196

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
invidian added a commit that referenced this issue Mar 20, 2020
Part of #196

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
invidian added a commit that referenced this issue May 18, 2020
Since Terraform 0.12, Terraform provides built-in templatefile() function,
which provides the same functionality as template_file data source from
template provider, so it is preferred to use this one.

This commit changes Ignition configuration to use this new function.

Unfortunately, not all uses of template_file can be replaced, as one is
used with count, so we would have to duplicate the function call or use
'null_resource' instead, which is not very beneficial.

The other use is about building CLC snippets, which changing is out of
scope for this commit.

Part of #196.

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
invidian added a commit that referenced this issue May 18, 2020
Since Terraform 0.12, Terraform provides built-in templatefile() function,
which provides the same functionality as template_file data source from
template provider, so it is preferred to use this one.

This commit changes Ignition configuration to use this new function.

Unfortunately, not all uses of template_file can be replaced, as one is
used with count, so we would have to duplicate the function call or use
'null_resource' instead, which is not very beneficial.

The other use is about building CLC snippets, which changing is out of
scope for this commit.

Part of #196.

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
@invidian
Copy link
Member Author

More context:

This commit changes the template method we use in Packet Terraform files
where possible, from template_file data source coming from 3rd party
Terraform provider to built-in 'templatefile' function, which is
available from Terraform 0.12, as it provides the exact same
functionality, but do not require downloading 3rd party provider.
Also 'template' provider recommends using this function:
https://www.terraform.io/docs/providers/template/d/file.html.

invidian added a commit that referenced this issue May 25, 2020
This commit changes the template method we use in Packet Terraform files
where possible, from template_file data source coming from 3rd party
Terraform provider to built-in 'templatefile' function, which is
available from Terraform 0.12, as it provides the exact same
functionality, but do not require downloading 3rd party provider.

Also 'template' provider recommends using this function:
https://www.terraform.io/docs/providers/template/d/file.html.

Part of #196

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
@invidian
Copy link
Member Author

Just found out some pros and cons about it:

  • Good thing about templatefile() is that it allows you to pass complex type to the template, like lists, so you can iterate inside the template
  • If you want to calculate the result of templatefile() with use of count, you need to use some helper, e.g. null_resource, where with template_file you can use the count directly.

IMO templatefile() seems still better, as we use null provider anyway for other things and we could completely get rid of template provider. This would mean less download for the end user.

invidian added a commit that referenced this issue May 28, 2020
This commit changes the template method we use in baremetal Terraform
code responsible for generating workers Ignition configs from
template_file data source coming from 3rd party Terraform provider
to built-in 'templatefile' function, which is available from
Terraform 0.12, as it provides the exact same functionality, but
do not require downloading 3rd party provider.

Also 'template' provider recommends using this function:
https://www.terraform.io/docs/providers/template/d/file.html.

This also allows passing parameters to the template in complex types
(like lists) and call functions like 'join' inside the template, which
better separates data from how they are rendered.

Part of #196

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
invidian added a commit that referenced this issue May 28, 2020
This commit changes the template method we use in baremetal Terraform
code responsible for generating workers Ignition configs from
template_file data source coming from 3rd party Terraform provider
to built-in 'templatefile' function, which is available from
Terraform 0.12, as it provides the exact same functionality, but
do not require downloading 3rd party provider.

Also 'template' provider recommends using this function:
https://www.terraform.io/docs/providers/template/d/file.html.

This also allows passing parameters to the template in complex types
(like lists) and call functions like 'join' inside the template, which
better separates data from how they are rendered.

Part of #196

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
invidian added a commit that referenced this issue May 28, 2020
This commit changes the template method we use in baremetal Terraform
code responsible for generating workers Ignition configs from
template_file data source coming from 3rd party Terraform provider
to built-in 'templatefile' function, which is available from
Terraform 0.12, as it provides the exact same functionality, but
do not require downloading 3rd party provider.

Also 'template' provider recommends using this function:
https://www.terraform.io/docs/providers/template/d/file.html.

This also allows passing parameters to the template in complex types
(like lists) and call functions like 'join' inside the template, which
better separates data from how they are rendered.

Part of #196

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
invidian added a commit that referenced this issue May 29, 2020
This commit changes the template method we use in baremetal Terraform
code responsible for generating workers Ignition configs from
template_file data source coming from 3rd party Terraform provider
to built-in 'templatefile' function, which is available from
Terraform 0.12, as it provides the exact same functionality, but
do not require downloading 3rd party provider.

Also 'template' provider recommends using this function:
https://www.terraform.io/docs/providers/template/d/file.html.

This also allows passing parameters to the template in complex types
(like lists) and call functions like 'join' inside the template, which
better separates data from how they are rendered.

Part of #196

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
invidian added a commit that referenced this issue May 29, 2020
This commit changes the template method we use in baremetal Terraform
code responsible for generating workers Ignition configs from
template_file data source coming from 3rd party Terraform provider
to built-in 'templatefile' function, which is available from
Terraform 0.12, as it provides the exact same functionality, but
do not require downloading 3rd party provider.

Also 'template' provider recommends using this function:
https://www.terraform.io/docs/providers/template/d/file.html.

This also allows passing parameters to the template in complex types
(like lists) and call functions like 'join' inside the template, which
better separates data from how they are rendered.

Part of #196

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
@invidian invidian added the technical-debt Technical debt-related issues label Jun 9, 2020
@invidian
Copy link
Member Author

Turns out template provider is now deprecated: https://github.com/hashicorp/terraform-provider-template.

@knrt10
Copy link
Member

knrt10 commented Oct 5, 2020

On it

@knrt10 knrt10 self-assigned this Oct 5, 2020
knrt10 added a commit that referenced this issue Oct 6, 2020
template_file is deprecated

closes: #196
Signed-off-by: knrt10 <kautilya@kinvolk.io>
knrt10 added a commit that referenced this issue Oct 6, 2020
template_file is deprecated.

closes: #196
Signed-off-by: knrt10 <kautilya@kinvolk.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
technical-debt Technical debt-related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants