Open todd-dsm opened 2 years ago
Hi @todd-dsm I agree that completion of regions and similar would be a great feature.
It seems relatively realistic to offer completion in this context:
provider "google" {
region = # <- HERE
}
Even that would however require some additions to the provider protocol and most importantly to providers themselves, such that e.g. google
provider can provide completion candidates for the region
field. i.e. it will require cooperation with a few teams and basically the whole provider maintainer ecosystem - it's not impossible, just clarifying that this is more than just a VS Code extension feature.
With a module (as in your example), the additional difficulty is understanding the relationship between the module input and a resource field. In order for this to work I expect that we'd have to introduce some changes to the variable
block, which module authors would use to draw such relationships.
For example:
variable "gcp_region" {
options = [
"us-west2",
"eu-west1",
"us-east1",
]
}
or
variable "gcp_region" {
options = google_compute_regions.available.names
}
data "google_compute_regions" "available" { }
These are all very hypothetical and don't account for any Terraform Core internals, which could may it difficult to implement either of the two approaches above.
Is there a particular UX you would expect on the module author side here?
Understood. Let's throw it on the books - even as a low priority. Someone may have time some day?!
🤷
@todd-dsm Is there a particular UX you would expect on the module author side here?
nothing I can think of beyond what was noted above.
Versions
Terraform
macOS
Extension
Problem Statement
Would be cool if there were suggestions for $cloud_region, like:
Might be helpful for definitions of modules/providers/
terraform.tfvars
, etc..Expected User Experience
During the assignment:
region + [TAB]
[SPACE] = [SPACE]
is automatically dropped into the line for convenience, then the cursor lands between 2 double quotes.'los'
or'west'
, should narrow the list of optionsk
orj
if using vim mode(?!)[ENTER]
key and"us-west2"
is populated inside the double quotes.This would be somewhat helpful to those of us helping companies with global ambitions; I always have to look this stuff up.