-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for new Instance Settings resource and a test into a b…
…eta provider. (#9313) (#16472) [upstream:f218e989981c0ff81605d43e2095564edbc7116f] Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
83063a6
commit 478fda5
Showing
3 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:new-resource | ||
`google_compute_instance_settings` | ||
``` |
56 changes: 56 additions & 0 deletions
56
google/services/compute/resource_compute_instance_settings_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
package compute_test | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-provider-google/google/acctest" | ||
) | ||
|
||
func testAccComputeInstanceSettings_basic(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_compute_instance_settings" "gce_instance_settings" { | ||
provider = google-beta | ||
zone = "us-east7-b" | ||
metadata { | ||
items = { | ||
foo = "baz" | ||
} | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccComputeInstanceSettings_update(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_compute_instance_settings" "gce_instance_settings" { | ||
provider = google-beta | ||
zone = "us-east7-b" | ||
metadata { | ||
items = { | ||
foo = "bar" | ||
baz = "qux" | ||
} | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccComputeInstanceSettings_delete(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_compute_instance_settings" "gce_instance_settings" { | ||
provider = google-beta | ||
zone = "us-east7-b" | ||
metadata { | ||
items = { | ||
baz = "qux" | ||
} | ||
} | ||
} | ||
`, context) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
--- | ||
# ---------------------------------------------------------------------------- | ||
# | ||
# *** AUTO GENERATED CODE *** Type: MMv1 *** | ||
# | ||
# ---------------------------------------------------------------------------- | ||
# | ||
# This file is automatically generated by Magic Modules and manual | ||
# changes will be clobbered when the file is regenerated. | ||
# | ||
# Please read more about how to change this file in | ||
# .github/CONTRIBUTING.md. | ||
# | ||
# ---------------------------------------------------------------------------- | ||
subcategory: "Compute Engine" | ||
description: |- | ||
Represents an Instance Settings resource. | ||
--- | ||
|
||
# google\_compute\_instance\_settings | ||
|
||
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. | ||
|
||
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. | ||
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. | ||
|
||
To get more information about InstanceSettings, see: | ||
|
||
* [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/instanceSettings) | ||
* How-to Guides | ||
* [Update Instance Settings](https://cloud.google.com/compute/docs/metadata/setting-custom-metadata#set-custom-project-zonal-metadata) | ||
|
||
<div class = "oics-button" style="float: right; margin: 0 0 -15px"> | ||
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%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"> | ||
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> | ||
</a> | ||
</div> | ||
## Example Usage - Instance Settings Basic | ||
|
||
|
||
```hcl | ||
resource "google_compute_instance_settings" "gce_instance_settings" { | ||
provider = google-beta | ||
zone = "us-east7-b" | ||
metadata { | ||
items = { | ||
foo = "baz" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
|
||
* `zone` - | ||
(Required) | ||
A reference to the zone where the machine resides. | ||
|
||
|
||
- - - | ||
|
||
|
||
* `metadata` - | ||
(Optional) | ||
The metadata key/value pairs assigned to all the instances in the corresponding scope. | ||
Structure is [documented below](#nested_metadata). | ||
|
||
* `project` - (Optional) The ID of the project in which the resource belongs. | ||
If it is not provided, the provider project is used. | ||
|
||
|
||
<a name="nested_metadata"></a>The `metadata` block supports: | ||
|
||
* `items` - | ||
(Optional) | ||
A metadata key/value items map. The total size of all keys and values must be less than 512KB | ||
|
||
## Attributes Reference | ||
|
||
In addition to the arguments listed above, the following computed attributes are exported: | ||
|
||
* `id` - an identifier for the resource with format `projects/{{project}}/zones/{{zone}}/instanceSettings` | ||
|
||
* `fingerprint` - | ||
The fingerprint used for optimistic locking of this resource. Used | ||
internally during updates. | ||
|
||
|
||
## Timeouts | ||
|
||
This resource provides the following | ||
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: | ||
|
||
- `create` - Default is 20 minutes. | ||
- `update` - Default is 20 minutes. | ||
- `delete` - Default is 20 minutes. | ||
|
||
## Import | ||
|
||
|
||
InstanceSettings can be imported using any of these accepted formats: | ||
|
||
* `projects/{{project}}/zones/{{zone}}/instanceSettings` | ||
* `{{project}}/{{zone}}` | ||
* `{{zone}}` | ||
|
||
|
||
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: | ||
|
||
```tf | ||
import { | ||
id = "projects/{{project}}/zones/{{zone}}/instanceSettings" | ||
to = google_compute_instance_settings.default | ||
} | ||
``` | ||
|
||
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: | ||
|
||
``` | ||
$ terraform import google_compute_instance_settings.default projects/{{project}}/zones/{{zone}}/instanceSettings | ||
$ terraform import google_compute_instance_settings.default {{project}}/{{zone}} | ||
$ terraform import google_compute_instance_settings.default {{zone}} | ||
``` | ||
|
||
## User Project Overrides | ||
|
||
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |