Skip to content

Commit 2fa644e

Browse files
fix zone issue (#816)
1 parent b77ae29 commit 2fa644e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

cai2hcl/compute_instance.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ func (c *ComputeInstanceConverter) convertResourceData(asset *caiasset.Asset) (*
116116
hclData["metadata"] = convertMetadata(instance.Metadata)
117117

118118
if instance.Zone == "" {
119-
instance.Zone = parseFieldValue(asset.Name, "zones")
119+
hclData["zone"] = parseFieldValue(asset.Name, "zones")
120+
} else {
121+
hclData["zone"] = parseFieldValue(instance.Zone, "zones")
120122
}
121-
hclData["zone"] = instance.Zone
122123

123124
ctyVal, err := mapToCtyValWithSchema(hclData, c.schema)
124125
if err != nil {

testdata/full_compute_instance.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@
135135
"bar",
136136
"foo"
137137
]
138-
}
138+
},
139+
"zone": "projects/test-project/zones/us-central1-a"
139140
}
140141
}
141142
},

0 commit comments

Comments
 (0)