forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Persistent Disk Asynchronous Replication (part 1) (G…
- Loading branch information
Showing
8 changed files
with
176 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
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
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
30 changes: 30 additions & 0 deletions
30
mmv1/templates/terraform/custom_expand/disk_consistency_group_policy.erb
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,30 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2020 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
-%> | ||
func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
l := v.([]interface{}) | ||
|
||
if len(l) == 0 || l[0] == nil { | ||
return nil, nil | ||
} | ||
raw := l[0] | ||
original := raw.(map[string]interface{}) | ||
if isEnabled, ok := original["enabled"]; ok { | ||
if !isEnabled.(bool) { | ||
return nil, nil | ||
} | ||
} | ||
transformed := make(map[string]interface{}) | ||
return transformed, nil | ||
} |
22 changes: 22 additions & 0 deletions
22
mmv1/templates/terraform/custom_flatten/disk_consistency_group_policy.erb
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,22 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2022 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { | ||
if v == nil { | ||
return nil | ||
} | ||
transformed := make(map[string]interface{}) | ||
transformed["enabled"] = true | ||
return []interface{}{transformed} | ||
} |
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,23 @@ | ||
resource "google_compute_disk" "primary" { | ||
provider = google-beta | ||
|
||
name = "<%= ctx[:vars]['disk_name'] %>" | ||
type = "pd-ssd" | ||
zone = "us-central1-a" | ||
|
||
physical_block_size_bytes = 4096 | ||
} | ||
|
||
resource "google_compute_disk" "secondary" { | ||
provider = google-beta | ||
|
||
name = "<%= ctx[:vars]['secondary_disk_name'] %>" | ||
type = "pd-ssd" | ||
zone = "us-east1-c" | ||
|
||
async_primary_disk { | ||
disk = google_compute_disk.primary.id | ||
} | ||
|
||
physical_block_size_bytes = 4096 | ||
} |
26 changes: 26 additions & 0 deletions
26
mmv1/templates/terraform/examples/region_disk_async.tf.erb
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,26 @@ | ||
resource "google_compute_region_disk" "primary" { | ||
provider = google-beta | ||
|
||
name = "<%= ctx[:vars]['region_disk_name'] %>" | ||
type = "pd-ssd" | ||
region = "us-central1" | ||
physical_block_size_bytes = 4096 | ||
|
||
replica_zones = ["us-central1-a", "us-central1-f"] | ||
} | ||
|
||
resource "google_compute_region_disk" "secondary" { | ||
provider = google-beta | ||
|
||
name = "<%= ctx[:vars]['secondary_region_disk_name'] %>" | ||
type = "pd-ssd" | ||
region = "us-east1" | ||
physical_block_size_bytes = 4096 | ||
|
||
async_primary_disk { | ||
disk = google_compute_region_disk.primary.id | ||
} | ||
|
||
replica_zones = ["us-east1-b", "us-east1-c"] | ||
} | ||
|
9 changes: 9 additions & 0 deletions
9
mmv1/templates/terraform/examples/resource_policy_consistency_group.tf.erb
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,9 @@ | ||
resource "google_compute_resource_policy" "cgroup" { | ||
provider = google-beta | ||
|
||
name = "<%= ctx[:vars]['name'] %>" | ||
region = "europe-west1" | ||
disk_consistency_group_policy { | ||
enabled = true | ||
} | ||
} |