Skip to content

Commit 7e04cee

Browse files
authored
add new compute_instance_from_template resource (#1652)
This was done as its own resource as suggested in slack, since we don't have the option of making all fields Computed in google_compute_instance. There's precedent in the aws provider for this sort of thing (see ami_copy, ami_from_instance). When I started working on this I assumed I could do it in the compute_instance resource and so I went ahead and reordered the schema to make it easier to work with in the future. Now it's not quite relevant, but I left it in as its own commit that can be looked at separately from the other changes. Fixes #1582.
1 parent cf44511 commit 7e04cee

15 files changed

+824
-261
lines changed

google/field_helpers.go

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ func ParseInstanceGroupFieldValue(instanceGroup string, d TerraformResourceData,
6262
return parseZonalFieldValue("instanceGroups", instanceGroup, "project", "zone", d, config, false)
6363
}
6464

65+
func ParseInstanceTemplateFieldValue(instanceTemplate string, d TerraformResourceData, config *Config) (*GlobalFieldValue, error) {
66+
return parseGlobalFieldValue("instanceTemplates", instanceTemplate, "project", d, config, false)
67+
}
68+
6569
func ParseSecurityPolicyFieldValue(securityPolicy string, d TerraformResourceData, config *Config) (*GlobalFieldValue, error) {
6670
return parseGlobalFieldValue("securityPolicies", securityPolicy, "project", d, config, true)
6771
}

google/provider.go

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ func Provider() terraform.ResourceProvider {
120120
"google_compute_health_check": resourceComputeHealthCheck(),
121121
"google_compute_image": resourceComputeImage(),
122122
"google_compute_instance": resourceComputeInstance(),
123+
"google_compute_instance_from_template": resourceComputeInstanceFromTemplate(),
123124
"google_compute_instance_group": resourceComputeInstanceGroup(),
124125
"google_compute_instance_group_manager": resourceComputeInstanceGroupManager(),
125126
"google_compute_instance_template": resourceComputeInstanceTemplate(),

0 commit comments

Comments
 (0)