Skip to content

Commit a7cc54d

Browse files
committed
Merge branch 'main' into parameter-manager-regional-parameter-version-render-datasource-support
2 parents 6f709bc + deae311 commit a7cc54d

File tree

214 files changed

+5146
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+5146
-154
lines changed

.github/workflows/downstreams.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- 'FEATURE-BRANCH-*'
99
merge_group:
1010
types: [checks_requested]
11-
11+
pull_request:
1212

1313
concurrency:
1414
group: ${{ github.event_name == 'merge_group' && format('merge-group-{0}', github.event.merge_group.head_sha) || github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('commit-{0}', github.sha) }}

mmv1/api/resource.go

+44-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ type Resource struct {
337337
// fine-grained resources and legacy resources.
338338
ApiResourceTypeKind string `yaml:"api_resource_type_kind,omitempty"`
339339

340-
ImportPath string `yaml:"-"`
340+
ImportPath string `yaml:"-"`
341+
SourceYamlFile string `yaml:"-"`
341342
}
342343

343344
func (r *Resource) UnmarshalYAML(unmarshal func(any) error) error {
@@ -1787,3 +1788,45 @@ func (r Resource) CaiIamAssetNameTemplate(productBackendName string) string {
17871788
}
17881789
return fmt.Sprintf("//%s.googleapis.com/%s/{{%s}}", productBackendName, caiBaseUrl, r.IamParentResourceName())
17891790
}
1791+
1792+
func urlContainsOnlyAllowedKeys(templateURL string, allowedKeys []string) bool {
1793+
// Create regex to match anything between {{ and }}
1794+
re := regexp.MustCompile(`{{\s*([^}]+)\s*}}`)
1795+
1796+
// Find all matches in the template URL
1797+
matches := re.FindAllStringSubmatch(templateURL, -1)
1798+
1799+
// Create a map of allowed keys for O(1) lookup
1800+
allowedKeysMap := make(map[string]bool)
1801+
for _, key := range allowedKeys {
1802+
allowedKeysMap[key] = true
1803+
}
1804+
1805+
// Check each found key against the allowed keys
1806+
for _, match := range matches {
1807+
if len(match) < 2 {
1808+
continue
1809+
}
1810+
1811+
// Trim spaces from the key
1812+
key := strings.TrimSpace(match[1])
1813+
1814+
// If the key isn't in our allowed list, return false
1815+
if !allowedKeysMap[key] {
1816+
return false
1817+
}
1818+
}
1819+
1820+
return true
1821+
}
1822+
1823+
func (r Resource) ShouldGenerateSweepers() bool {
1824+
allowedKeys := []string{"project", "region", "location", "zone", "billing_account"}
1825+
if !urlContainsOnlyAllowedKeys(r.ListUrlTemplate(), allowedKeys) {
1826+
return false
1827+
}
1828+
if r.ExcludeSweeper || r.CustomCode.CustomDelete != "" || r.CustomCode.PreDelete != "" || r.CustomCode.PostDelete != "" || r.ExcludeDelete {
1829+
return false
1830+
}
1831+
return true
1832+
}

mmv1/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func GenerateProduct(productChannel chan string, providerToGenerate provider.Pro
256256

257257
resource := &api.Resource{}
258258
api.Compile(resourceYamlPath, resource, overrideDirectory)
259+
resource.SourceYamlFile = resourceYamlPath
259260

260261
resource.TargetVersionName = *version
261262
resource.Properties = resource.AddLabelsRelatedFields(resource.PropertiesWithExcluded(), nil)

mmv1/products/apphub/Application.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ custom_code:
4040
constants: 'templates/terraform/constants/apphub_application.go.tmpl'
4141
custom_diff:
4242
- 'apphubApplicationCustomizeDiff'
43+
sweeper:
44+
regions:
45+
- "us-central1"
46+
- "us-east1"
47+
- "global"
4348
examples:
4449
- name: 'apphub_application_basic'
4550
primary_resource_id: 'example'

mmv1/products/artifactregistry/Repository.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ custom_code:
5454
constants: 'templates/terraform/constants/artifact_registry_repository.go.tmpl'
5555
encoder: 'templates/terraform/encoders/location_from_region.go.tmpl'
5656
pre_create: 'templates/terraform/pre_create/artifact_registry_remote_repository.go.tmpl'
57+
sweeper:
58+
regions:
59+
- "us-central1"
60+
- "us"
5761
examples:
5862
- name: 'artifact_registry_repository_basic'
5963
primary_resource_id: 'my-repo'

mmv1/products/biglake/Catalog.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ timeouts:
2929
update_minutes: 20
3030
delete_minutes: 20
3131
custom_code:
32+
sweeper:
33+
regions:
34+
- "US"
3235
examples:
3336
- name: 'bigquery_biglake_catalog'
3437
primary_resource_id: 'default'

mmv1/products/bigqueryanalyticshub/DataExchange.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ iam_policy:
4141
- 'projects/{{project}}/locations/{{location}}/dataExchanges/{{data_exchange_id}}'
4242
- '{{data_exchange_id}}'
4343
custom_code:
44+
sweeper:
45+
regions:
46+
- "US"
4447
examples:
4548
- name: 'bigquery_analyticshub_data_exchange_basic'
4649
primary_resource_id: 'data_exchange'

mmv1/products/bigqueryconnection/Connection.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ iam_policy:
4545
custom_code:
4646
encoder: 'templates/terraform/encoders/bigquery_connection.go.tmpl'
4747
post_create: 'templates/terraform/post_create/bigquery_connection_id.go.tmpl'
48+
sweeper:
49+
regions:
50+
- "US"
51+
- "EU"
52+
- "aws-us-east-1"
53+
- "azure-eastus2"
4854
examples:
4955
- name: 'bigquery_connection_cloud_resource'
5056
primary_resource_id: 'connection'

mmv1/products/bigqueryreservation/CapacityCommitment.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ timeouts:
3737
custom_code:
3838
constants: 'templates/terraform/constants/bigquery_reservation_capacity_commitment.go.tmpl'
3939
custom_import: 'templates/terraform/custom_import/bigquery_reservation_capacity_commitment_set_id.go.tmpl'
40+
sweeper:
41+
regions:
42+
- "us-west2"
4043
examples:
4144
- name: 'bigquery_reservation_capacity_commitment_basic'
4245
primary_resource_id: 'commitment'

mmv1/products/certificatemanager/Certificate.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ custom_code:
4040
constants: 'templates/terraform/constants/cert_manager.tmpl'
4141
schema_version: 1
4242
state_upgraders: true
43+
sweeper:
44+
regions:
45+
- "us-central1"
46+
- "us-east1"
47+
- "us-south1"
48+
- "us-west1"
49+
- "us-west2"
4350
examples:
4451
- name: 'certificate_manager_google_managed_certificate_dns'
4552
primary_resource_id: 'default'

mmv1/products/certificatemanager/DnsAuthorization.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ async:
3838
custom_code:
3939
schema_version: 1
4040
state_upgraders: true
41+
sweeper:
42+
regions:
43+
- "global"
44+
- "us-central1"
4145
examples:
4246
- name: 'certificate_manager_dns_authorization_basic'
4347
primary_resource_id: 'default'

mmv1/products/certificatemanager/TrustConfig.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ async:
4040
result:
4141
resource_inside_response: false
4242
custom_code:
43+
sweeper:
44+
regions:
45+
- "global"
46+
- "us-central1"
4347
examples:
4448
- name: 'certificate_manager_trust_config'
4549
primary_resource_id: 'default'

mmv1/products/cloudbuild/Trigger.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ custom_diff:
4646
- 'stepTimeoutCustomizeDiff'
4747
schema_version: 2
4848
state_upgraders: true
49+
sweeper:
50+
regions:
51+
- "us-central1"
52+
- "global"
4953
examples:
5054
- name: 'cloudbuild_trigger_filename'
5155
primary_resource_id: 'filename-trigger'

mmv1/products/cloudbuildv2/Connection.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ iam_policy:
4949
custom_code:
5050
exclude_tgc: true
5151
legacy_long_form_project: true
52+
sweeper:
53+
regions:
54+
- "us-west1"
55+
- "us-central1"
5256
examples:
5357
- name: 'cloudbuildv2_connection'
5458
primary_resource_id: 'my-connection'

mmv1/products/cloudfunctions2/Function.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ custom_code:
5656
constants: 'templates/terraform/constants/cloudfunctions2_function.go.tmpl'
5757
encoder: 'templates/terraform/encoders/cloudfunctions2_runtime_update_policy.go.tmpl'
5858
taint_resource_on_failed_create: true
59+
sweeper:
60+
regions:
61+
- "us-central1"
62+
- "us-west1"
63+
- "europe-west6"
5964
examples:
6065
- name: 'cloudfunctions2_basic'
6166
primary_resource_id: 'function'

mmv1/products/cloudrun/Service.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ error_retry_predicates:
6060
schema_version: 2
6161
state_upgrade_base_schema_version: 1
6262
state_upgraders: true
63+
sweeper:
64+
regions:
65+
- "us-central1"
66+
- "europe-west1"
67+
- "europe-north1"
6368
examples:
6469
- name: 'cloud_run_service_basic'
6570
primary_resource_id: 'default'

mmv1/products/colab/Runtime.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,24 @@ async:
3131
full_url: 'https://{{location}}-aiplatform.googleapis.com/v1/{{op_id}}'
3232
custom_code:
3333
encoder: 'templates/terraform/encoders/colab_runtime.go.tmpl'
34+
post_create: 'templates/terraform/post_create/colab_runtime.go.tmpl'
35+
custom_update: 'templates/terraform/custom_update/colab_runtime.go.tmpl'
36+
constants: 'templates/terraform/constants/colab_runtime.go.tmpl'
3437
examples:
3538
- name: 'colab_runtime_basic'
3639
primary_resource_id: 'runtime'
3740
primary_resource_name: 'fmt.Sprintf("tf-test-colab-runtime%s", context["random_suffix"])'
3841
region_override: 'us-central1'
3942
vars:
4043
runtime_name: 'colab-runtime'
44+
- name: 'colab_runtime_stopped'
45+
primary_resource_id: 'runtime'
46+
primary_resource_name: 'fmt.Sprintf("tf-test-colab-runtime%s", context["random_suffix"])'
47+
region_override: 'us-central1'
48+
vars:
49+
runtime_name: 'colab-runtime'
50+
ignore_read_extra:
51+
- 'desired_state'
4152
- name: 'colab_runtime_full'
4253
primary_resource_id: 'runtime'
4354
primary_resource_name: 'fmt.Sprintf("tf-test-colab-runtime%s", context["random_suffix"])'
@@ -47,16 +58,31 @@ examples:
4758
key_name: 'my-crypto-key'
4859
test_vars_overrides:
4960
key_name: 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name'
61+
ignore_read_extra:
62+
- 'desired_state'
63+
- 'auto_upgrade'
64+
virtual_fields:
65+
- name: 'desired_state'
66+
description: |
67+
Desired state of the Colab Runtime. Set this field to `RUNNING` to start the runtime, and `STOPPED` to stop it.
68+
type: String
69+
default_value: "RUNNING"
70+
- name: 'auto_upgrade'
71+
description: |
72+
Triggers an upgrade anytime the runtime is started if it is upgradable.
73+
type: Boolean
5074
parameters:
5175
- name: 'location'
5276
type: String
5377
required: true
5478
url_param_only: true
5579
description: 'The location for the resource: https://cloud.google.com/colab/docs/locations'
80+
immutable: true
5681
- name: 'name'
5782
type: String
5883
url_param_only: true
5984
description: 'The resource name of the Runtime'
85+
immutable: true
6086
properties:
6187
- name: notebookRuntimeTemplateRef
6288
type: NestedObject
@@ -65,18 +91,42 @@ properties:
6591
properties:
6692
- name: 'notebookRuntimeTemplate'
6793
type: String
94+
immutable: true
6895
required: true
6996
description: 'The resource name of the NotebookRuntimeTemplate based on which a NotebookRuntime will be created.'
7097
diff_suppress_func: 'tpgresource.ProjectNumberDiffSuppress'
7198
- name: 'runtimeUser'
7299
type: String
73100
required: true
101+
immutable: true
74102
description: 'The user email of the NotebookRuntime.'
75103
- name: 'displayName'
76104
type: String
105+
immutable: true
77106
description:
78107
Required. The display name of the Runtime.
79108
required: true
80109
- name: description
81110
type: String
111+
immutable: true
82112
description: 'The description of the Runtime.'
113+
- name: state
114+
type: String
115+
description: |
116+
Output only. The state of the runtime.
117+
output: true
118+
- name: isUpgradable
119+
type: Boolean
120+
description: |
121+
Output only. Checks if the NotebookRuntime is upgradable.
122+
output: true
123+
- name: expirationTime
124+
type: String
125+
description: |
126+
Output only. Timestamp when this NotebookRuntime will be expired.
127+
output: true
128+
- name: notebookRuntimeType
129+
type: String
130+
description: |
131+
Output only. The type of the notebook runtime.
132+
output: true

mmv1/products/colab/RuntimeTemplate.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ iam_policy:
4141
- 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates/{{runtime_template}}'
4242
- '{{runtime_template}}'
4343
custom_code:
44-
post_create: 'templates/terraform/post_create/colab_runtime_template.tmpl'
44+
post_create: 'templates/terraform/post_create/colab_runtime_template.go.tmpl'
4545
examples:
4646
- name: 'colab_runtime_template_basic'
4747
primary_resource_id: 'runtime-template'

mmv1/products/compute/Address.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ async:
5151
collection_url_key: 'items'
5252
custom_code:
5353
post_create: 'templates/terraform/post_create/labels.tmpl'
54+
sweeper:
55+
regions:
56+
- "us-west1"
57+
- "us-west2"
58+
- "us-central1"
59+
- "us-east1"
60+
- "europe-west1"
5461
examples:
5562
- name: 'address_basic'
5663
primary_resource_id: 'ip_address'

mmv1/products/compute/ForwardingRule.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ custom_code:
4747
custom_diff:
4848
- 'forwardingRuleCustomizeDiff'
4949
legacy_long_form_project: true
50+
sweeper:
51+
regions:
52+
- "us-west2"
53+
- "us-central1"
54+
- "europe-west1"
55+
- "europe-west4"
56+
- "us-west1"
5057
examples:
5158
- name: 'internal_http_lb_with_mig_backend'
5259
primary_resource_id: 'google_compute_forwarding_rule'

mmv1/products/compute/InterconnectAttachment.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ kind: 'compute#interconnectAttachment'
1717
description: |
1818
Represents an InterconnectAttachment (VLAN attachment) resource. For more
1919
information, see Creating VLAN Attachments.
20+
references:
21+
guides:
22+
'Create a Interconnect attachment': 'https://cloud.google.com/network-connectivity/docs/interconnect/how-to/dedicated/creating-vlan-attachments'
23+
api: 'https://cloud.google.com/compute/docs/reference/rest/v1/interconnectAttachments'
2024
docs:
2125
base_url: 'projects/{{project}}/regions/{{region}}/interconnectAttachments'
2226
has_self_link: true

mmv1/products/compute/PublicAdvertisedPrefix.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,18 @@ properties:
7676
- name: 'ipCidrRange'
7777
type: String
7878
description:
79-
The IPv4 address range, in CIDR format, represented by this public
80-
advertised prefix.
79+
The address range, in CIDR format, represented by this public advertised
80+
prefix.
8181
required: true
8282
- name: 'pdpScope'
8383
type: Enum
8484
description: |
8585
Specifies how child public delegated prefix will be scoped. pdpScope
8686
must be one of: GLOBAL, REGIONAL
87+
* REGIONAL: The public delegated prefix is regional only. The
88+
provisioning will take a few minutes.
89+
* GLOBAL: The public delegated prefix is global only. The provisioning
90+
will take ~4 weeks.
8791
enum_values:
8892
- 'GLOBAL'
8993
- 'REGIONAL'

0 commit comments

Comments
 (0)