Include GCP Project in terraform HCL2 output

This has been included in the JSON output but was missing from HCL2
This commit is contained in:
Peter Rifel 2021-07-01 08:15:52 -04:00
parent 159943eb8e
commit 3c1cc72d51
No known key found for this signature in database
GPG Key ID: BC6469E5B16DB2B6
3 changed files with 7 additions and 2 deletions

View File

@ -17,7 +17,8 @@ output "region" {
}
provider "google" {
region = "us-test1"
project = "us-test1"
region = "us-test1"
}
resource "google_compute_disk" "d1-etcd-events-ha-gce-example-com" {

View File

@ -17,7 +17,8 @@ output "region" {
}
provider "google" {
region = "us-test1"
project = "us-test1"
region = "us-test1"
}
resource "google_compute_disk" "d1-etcd-events-minimal-gce-example-com" {

View File

@ -42,6 +42,9 @@ func (t *TerraformTarget) finishHCL2(taskMap map[string]fi.Task) error {
}
providerBlock := rootBody.AppendNewBlock("provider", []string{providerName})
providerBody := providerBlock.Body()
if t.Cloud.ProviderID() == kops.CloudProviderGCE {
providerBody.SetAttributeValue("project", cty.StringVal(t.Project))
}
providerBody.SetAttributeValue("region", cty.StringVal(t.Cloud.Region()))
for k, v := range tfGetProviderExtraConfig(t.clusterSpecTarget) {
providerBody.SetAttributeValue(k, cty.StringVal(v))