Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Avoid Duplicate #117

Closed
olekukonko opened this issue Jul 2, 2019 · 1 comment
Closed

Avoid Duplicate #117

olekukonko opened this issue Jul 2, 2019 · 1 comment

Comments

@olekukonko
Copy link

This is a duplicate of the issue created hashicorp/hcl#274

I have a configuration file that is over 900 lines and realised its all duplication.

Instead of writing

provider "A" {
  var1 = "X"
  var2  = "Y"
}

provider "B" {
  var1 = "X"
  var2  = "Y"
}

provider "C" {
  var1 = "X"
  var2  = "Y"
  var3  = "Z"
}

extra "D" {
  var1 = "X"
  var2  = "Y"
}

It would be nice to be able to write it as follows

provider "A" , "B", "C" ; extra "D" {
  var1 = "X"
  var2  = "Y"
}
provider "C" "var3" = "Z" 

Another possibility would be the ability to set variables using $

$tmp {
  var1 = "X"
  var2  = "Y"
}

provider "A"  = $tmp
provider "B"  = $tmp
provider "C" {
  $tmp
  var3  = "Z"
}
extra "D"  = $tmp

Rational

Configuration sometimes contain duplicate values, Been able to concatenate values or set variables makes HCL a much more powerful configuration language.

@apparentlymart
Copy link
Contributor

Hi @olekukonko! Thanks for opening this issue.

HCL intentionally does not have complicated repetition features itself because its information model needs to be relatively simple in order to support the static analysis operations that applications like Terraform need to perform. There won't be any features like this at the HCL level, because that is too general a layer to solve this problem while maintaining the interface that applications depend on.

Instead, please start a discussion about this in the Terraform repository about repetitive provider configurations in particular. If there will be any changes made to the language to reduce this repetition then they will be at the Terraform layer, not at the HCL layer.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants