Skip to content

Commit 7fbab20

Browse files
committed
Fixes import error
1 parent d359eb8 commit 7fbab20

File tree

3 files changed

+79
-23
lines changed

3 files changed

+79
-23
lines changed

mmv1/products/storage/ProjectManagementHub.yaml

+71-11
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ name: 'ProjectManagementHub'
1717
kind: 'storage#managementhub'
1818
# Resource description for the provider documentation.
1919
description: |
20-
RESOURCE_DESCRIPTION
21-
references:
22-
guides:
23-
# Link to quickstart in the API's Guides section. For example:
24-
# 'Create and connect to a database': 'https://cloud.google.com/alloydb/docs/quickstart/create-and-connect'
25-
'QUICKSTART_TITLE': 'QUICKSTART_URL'
26-
# Link to the REST API reference for the resource. For example,
27-
# https://cloud.google.com/alloydb/docs/reference/rest/v1/projects.locations.backups
28-
api: 'API_REFERENCE_URL'
20+
The Project Management Hub resource represents GCS Management Hub operating on
21+
individual GCP project. Management Hub is a singleton resource and individual
22+
instance exists on each GCP project.
23+
24+
Management Hub is for Storage Admins to manage GCP storage assets at scale for
25+
performance, cost, security & compliance.
26+
27+
docs:
28+
warning: |
29+
Management Hub is a singleton resource which cannot be created or
30+
deleted. A single instance of Management Hub exist for each GCP Project.
31+
Terraform does not create or destroy this resource. Terraform resource
32+
creation for this resource is simply an update operation on existing
33+
resource with specified properties. Terraform deletion won't have any effect
34+
on this resource rather it will only remove it from the state file.
2935
# Marks the resource as beta-only. Ensure a beta version block is present in
3036
# provider.yaml.
3137
# min_version: beta
@@ -44,6 +50,7 @@ custom_code:
4450
pre_delete: templates/terraform/constants/storage_management_hub.go.tmpl
4551
pre_read: templates/terraform/constants/storage_management_hub.go.tmpl
4652
pre_update: templates/terraform/constants/storage_management_hub.go.tmpl
53+
custom_create: templates/terraform/custom_create/storage_project_management_hub.go.tmpl
4754
# Overrides the URL for the resource's standard Update method. (If unset, the
4855
# self_link URL is used by default.) https://google.aip.dev/134
4956
# Terraform field names enclosed in double curly braces are replaced with
@@ -75,21 +82,32 @@ properties:
7582
immutable: true
7683
url_param_only: true
7784
description: |
78-
NAME_DESCRIPTION
85+
Identifier of the GCP project. For GCP project, this field can be project
86+
name or project number.
7987
- name: 'editionConfig'
8088
type: String
8189
required: false
8290
default_from_api: true
91+
description: |
92+
Edition configuration of the Management Hub resource. Valid values are
93+
INHERIT, DISABLED and STANDARD.
8394
- name: 'updateTime'
8495
type: String
8596
output: true
97+
description: |
98+
The time at which the Management Hub resource is last updated.
8699
- name: 'filter'
87100
type: NestedObject
88-
description:
101+
description: |
102+
Filter over location and bucket using include or exclude semantics.
103+
Resources that match the include or exclude filter are exclusively
104+
included or excluded from the Management Hub plan.
89105
properties:
90106
- name: excludedCloudStorageBuckets
91107
type: NestedObject
92108
required: false
109+
description: |
110+
Buckets to exclude from the Management Hub plan.
93111
conflicts:
94112
- 'filter.0.included_cloud_storage_buckets'
95113
at_least_one_of:
@@ -106,11 +124,21 @@ properties:
106124
properties:
107125
- name: bucketId
108126
type: String
127+
description: |
128+
Id of the bucket.
129+
Only one of the bucket_id and bucket_id_regex should be
130+
specified.
109131
- name: bucketIdRegex
110132
type: String
133+
description: |
134+
ID regex of the bucket.
135+
Only one of the bucket_id and bucket_id_regex should be
136+
specified.
111137
- name: includedCloudStorageBuckets
112138
type: NestedObject
113139
required: false
140+
description: |
141+
Buckets to include in the Management Hub plan.
114142
conflicts:
115143
- 'filter.0.excluded_cloud_storage_buckets'
116144
at_least_one_of:
@@ -128,12 +156,22 @@ properties:
128156
- name: bucketId
129157
type: String
130158
required: false
159+
description: |
160+
Id of the bucket.
161+
Only one of the bucket_id and bucket_id_regex should be
162+
specified.
131163
- name: bucketIdRegex
132164
type: String
133165
required: false
166+
description: |
167+
ID regex of the bucket.
168+
Only one of the bucket_id and bucket_id_regex should be
169+
specified.
134170
- name: excludedCloudStorageLocations
135171
type: NestedObject
136172
required: false
173+
description: |
174+
Locations to exclude from the Management Hub plan.
137175
conflicts:
138176
- 'filter.0.included_cloud_storage_locations'
139177
at_least_one_of:
@@ -145,11 +183,15 @@ properties:
145183
- name: locations
146184
type: Array
147185
required: true
186+
description: |
187+
List of locations.
148188
item_type:
149189
type: String
150190
- name: includedCloudStorageLocations
151191
type: NestedObject
152192
required: false
193+
description: |
194+
Locations to include in the Management Hub plan.
153195
conflicts:
154196
- 'filter.0.excluded_cloud_storage_locations'
155197
at_least_one_of:
@@ -161,5 +203,23 @@ properties:
161203
- name: locations
162204
type: Array
163205
required: true
206+
description: |
207+
List of locations.
164208
item_type:
165209
type: String
210+
- name: 'effectiveManagementHubEdition'
211+
output: true
212+
description: |
213+
The Management Hub edition that is effective for the resource.
214+
type: NestedObject
215+
properties:
216+
- name: managementHub
217+
type: String
218+
output: true
219+
description: |
220+
The Management Hub resource that is applied for the target resource.
221+
- name: managementHubEdition
222+
type: String
223+
output: true
224+
description: |
225+
The `ManagementHub` edition that is applicable for the resource.

mmv1/templates/terraform/custom_create/storage_project_management_hub.go.tmpl

+7-11
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
}
66

77
obj := make(map[string]interface{})
8-
editionConfigProp, err := expandStorageManagementHubEditionConfig(d.Get("edition_config"), d, config)
8+
editionConfigProp, err := expandStorageProjectManagementHubEditionConfig(d.Get("edition_config"), d, config)
99
if err != nil {
1010
return err
1111
} else if v, ok := d.GetOkExists("edition_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(editionConfigProp)) && (ok || !reflect.DeepEqual(v, editionConfigProp)) {
1212
obj["editionConfig"] = editionConfigProp
1313
}
14-
filterProp, err := expandStorageManagementHubFilter(d.Get("filter"), d, config)
14+
filterProp, err := expandStorageProjectManagementHubFilter(d.Get("filter"), d, config)
1515
if err != nil {
1616
return err
1717
} else if v, ok := d.GetOkExists("filter"); !tpgresource.IsEmptyValue(reflect.ValueOf(filterProp)) && (ok || !reflect.DeepEqual(v, filterProp)) {
@@ -23,7 +23,7 @@
2323
return err
2424
}
2525

26-
log.Printf("[DEBUG] Creating new ManagementHub: %#v", obj)
26+
log.Printf("[DEBUG] Patching ManagementHub: %#v", obj)
2727
billingProject := ""
2828

2929
// err == nil indicates that the billing_project value was found
@@ -32,15 +32,11 @@
3232
}
3333

3434
headers := make(http.Header)
35-
updateMask := []string{}
35+
updateMask := []string{"filter"}
3636

3737
if d.HasChange("edition_config") {
3838
updateMask = append(updateMask, "editionConfig")
3939
}
40-
41-
if d.HasChange("filter") {
42-
updateMask = append(updateMask, "filter")
43-
}
4440
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
4541
// won't set it
4642
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
@@ -61,7 +57,7 @@
6157
Headers: headers,
6258
})
6359
if err != nil {
64-
return fmt.Errorf("Error creating ManagementHub: %s", err)
60+
return fmt.Errorf("Error patching ManagementHub: %s", err)
6561
}
6662

6763
// Store the ID now
@@ -71,6 +67,6 @@
7167
}
7268
d.SetId(id)
7369

74-
log.Printf("[DEBUG] Finished creating ManagementHub %q: %#v", d.Id(), res)
70+
log.Printf("[DEBUG] Finished patching ManagementHub %q: %#v", d.Id(), res)
7571

76-
return resourceStorageManagementHubRead(d, meta)
72+
return resourceStorageProjectManagementHubRead(d, meta)

mmv1/third_party/terraform/services/storage/resource_storage_project_management_hub_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"testing"
55

66
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7-
"github.com/hashicorp/terraform-provider-google/envvar"
87
"github.com/hashicorp/terraform-provider-google/google/acctest"
8+
"github.com/hashicorp/terraform-provider-google/google/envvar"
99
)
1010

1111
func TestAccStorageProjectManagementHub_update(t *testing.T) {

0 commit comments

Comments
 (0)