Skip to content

Commit 478fda5

Browse files
Adding support for new Instance Settings resource and a test into a beta provider. (#9313) (#16472)
[upstream:f218e989981c0ff81605d43e2095564edbc7116f] Signed-off-by: Modular Magician <[email protected]>
1 parent 83063a6 commit 478fda5

File tree

3 files changed

+191
-0
lines changed

3 files changed

+191
-0
lines changed

.changelog/9313.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_compute_instance_settings`
3+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
package compute_test
4+
5+
import (
6+
"github.com/hashicorp/terraform-provider-google/google/acctest"
7+
)
8+
9+
func testAccComputeInstanceSettings_basic(context map[string]interface{}) string {
10+
return acctest.Nprintf(`
11+
12+
resource "google_compute_instance_settings" "gce_instance_settings" {
13+
provider = google-beta
14+
zone = "us-east7-b"
15+
metadata {
16+
items = {
17+
foo = "baz"
18+
}
19+
}
20+
}
21+
22+
`, context)
23+
}
24+
25+
func testAccComputeInstanceSettings_update(context map[string]interface{}) string {
26+
return acctest.Nprintf(`
27+
28+
resource "google_compute_instance_settings" "gce_instance_settings" {
29+
provider = google-beta
30+
zone = "us-east7-b"
31+
metadata {
32+
items = {
33+
foo = "bar"
34+
baz = "qux"
35+
}
36+
}
37+
}
38+
39+
`, context)
40+
}
41+
42+
func testAccComputeInstanceSettings_delete(context map[string]interface{}) string {
43+
return acctest.Nprintf(`
44+
45+
resource "google_compute_instance_settings" "gce_instance_settings" {
46+
provider = google-beta
47+
zone = "us-east7-b"
48+
metadata {
49+
items = {
50+
baz = "qux"
51+
}
52+
}
53+
}
54+
55+
`, context)
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
# ----------------------------------------------------------------------------
3+
#
4+
# *** AUTO GENERATED CODE *** Type: MMv1 ***
5+
#
6+
# ----------------------------------------------------------------------------
7+
#
8+
# This file is automatically generated by Magic Modules and manual
9+
# changes will be clobbered when the file is regenerated.
10+
#
11+
# Please read more about how to change this file in
12+
# .github/CONTRIBUTING.md.
13+
#
14+
# ----------------------------------------------------------------------------
15+
subcategory: "Compute Engine"
16+
description: |-
17+
Represents an Instance Settings resource.
18+
---
19+
20+
# google\_compute\_instance\_settings
21+
22+
Represents an Instance Settings resource. Instance settings are centralized configuration parameters that allow users to configure the default values for specific VM parameters that are normally set using GCE instance API methods.
23+
24+
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
25+
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.
26+
27+
To get more information about InstanceSettings, see:
28+
29+
* [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/instanceSettings)
30+
* How-to Guides
31+
* [Update Instance Settings](https://cloud.google.com/compute/docs/metadata/setting-custom-metadata#set-custom-project-zonal-metadata)
32+
33+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
34+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.jpy.wang%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=instance_settings_basic&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
35+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
36+
</a>
37+
</div>
38+
## Example Usage - Instance Settings Basic
39+
40+
41+
```hcl
42+
43+
resource "google_compute_instance_settings" "gce_instance_settings" {
44+
provider = google-beta
45+
zone = "us-east7-b"
46+
metadata {
47+
items = {
48+
foo = "baz"
49+
}
50+
}
51+
}
52+
53+
```
54+
55+
## Argument Reference
56+
57+
The following arguments are supported:
58+
59+
60+
* `zone` -
61+
(Required)
62+
A reference to the zone where the machine resides.
63+
64+
65+
- - -
66+
67+
68+
* `metadata` -
69+
(Optional)
70+
The metadata key/value pairs assigned to all the instances in the corresponding scope.
71+
Structure is [documented below](#nested_metadata).
72+
73+
* `project` - (Optional) The ID of the project in which the resource belongs.
74+
If it is not provided, the provider project is used.
75+
76+
77+
<a name="nested_metadata"></a>The `metadata` block supports:
78+
79+
* `items` -
80+
(Optional)
81+
A metadata key/value items map. The total size of all keys and values must be less than 512KB
82+
83+
## Attributes Reference
84+
85+
In addition to the arguments listed above, the following computed attributes are exported:
86+
87+
* `id` - an identifier for the resource with format `projects/{{project}}/zones/{{zone}}/instanceSettings`
88+
89+
* `fingerprint` -
90+
The fingerprint used for optimistic locking of this resource. Used
91+
internally during updates.
92+
93+
94+
## Timeouts
95+
96+
This resource provides the following
97+
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
98+
99+
- `create` - Default is 20 minutes.
100+
- `update` - Default is 20 minutes.
101+
- `delete` - Default is 20 minutes.
102+
103+
## Import
104+
105+
106+
InstanceSettings can be imported using any of these accepted formats:
107+
108+
* `projects/{{project}}/zones/{{zone}}/instanceSettings`
109+
* `{{project}}/{{zone}}`
110+
* `{{zone}}`
111+
112+
113+
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import InstanceSettings using one of the formats above. For example:
114+
115+
```tf
116+
import {
117+
id = "projects/{{project}}/zones/{{zone}}/instanceSettings"
118+
to = google_compute_instance_settings.default
119+
}
120+
```
121+
122+
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), InstanceSettings can be imported using one of the formats above. For example:
123+
124+
```
125+
$ terraform import google_compute_instance_settings.default projects/{{project}}/zones/{{zone}}/instanceSettings
126+
$ terraform import google_compute_instance_settings.default {{project}}/{{zone}}
127+
$ terraform import google_compute_instance_settings.default {{zone}}
128+
```
129+
130+
## User Project Overrides
131+
132+
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).

0 commit comments

Comments
 (0)