Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for snapshot chain name #6487

Merged
merged 3 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions mmv1/products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12944,6 +12944,13 @@ objects:
- snapshot_schedule_policy.0.snapshot_properties.0.guest_flush
description: |
Whether to perform a 'guest aware' snapshot.
- !ruby/object:Api::Type::String
name: 'chainName'
allow_empty_object: true
jesse-l marked this conversation as resolved.
Show resolved Hide resolved
description: |
Creates the new snapshot in the snapshot chain labeled with the
specified name. The chain name must be 1-63 characters long and comply
with RFC1035.
- !ruby/object:Api::Type::NestedObject
name: 'groupPlacementPolicy'
conflicts:
Expand Down Expand Up @@ -14042,6 +14049,16 @@ objects:
name: 'diskSizeGb'
description: 'Size of the snapshot, specified in GB.'
output: true
- !ruby/object:Api::Type::String
name: 'chainName'
allow_empty_object: true
description: |
Creates the new snapshot in the snapshot chain labeled with the
specified name. The chain name must be 1-63 characters long and
comply with RFC1035. This is an uncommon option only for advanced
service owners who needs to create separate snapshot chains, for
example, for chargeback tracking. When you describe your snapshot
resource, this field is visible only if it has a non-empty value.
jesse-l marked this conversation as resolved.
Show resolved Hide resolved
- !ruby/object:Api::Type::String
name: 'name'
required: true
Expand Down
13 changes: 13 additions & 0 deletions mmv1/products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,11 @@ overrides: !ruby/object:Overrides::ResourceOverrides
primary_resource_id: "hourly"
vars:
name: "policy"
- !ruby/object:Provider::Terraform::Examples
name: "resource_policy_snapshot_schedule_chain_name"
primary_resource_id: "hourly"
vars:
name: "policy"
properties:
region: !ruby/object:Overrides::Terraform::PropertyOverride
required: false
Expand Down Expand Up @@ -2688,6 +2693,14 @@ overrides: !ruby/object:Overrides::ResourceOverrides
vars:
snapshot_name: "my-snapshot"
disk_name: "debian-disk"
- !ruby/object:Provider::Terraform::Examples
name: "snapshot_chainname"
primary_resource_id: "snapshot"
primary_resource_name: "fmt.Sprintf(\"tf-test-snapshot-chainname%s\", context[\"random_suffix\"])"
vars:
snapshot_name: "my-snapshot"
disk_name: "debian-disk"
chain_name: 'snapshot-chain'
properties:
id: !ruby/object:Overrides::Terraform::PropertyOverride
name: 'snapshot_id'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resource "google_compute_resource_policy" "hourly" {
name = "<%= ctx[:vars]['name'] %>"
region = "us-central1"
description = "chain name snapshot"
snapshot_schedule_policy {
schedule {
hourly_schedule {
hours_in_cycle = 20
start_time = "23:00"
}
}
retention_policy {
max_retention_days = 14
on_source_disk_delete = "KEEP_AUTO_SNAPSHOTS"
}
snapshot_properties {
labels = {
my_label = "value"
}
storage_locations = ["us"]
guest_flush = true
chain_name = "test-schedule-chain-name"
}
}
}
23 changes: 23 additions & 0 deletions mmv1/templates/terraform/examples/snapshot_chainname.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
resource "google_compute_snapshot" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['snapshot_name'] %>"
source_disk = google_compute_disk.persistent.id
zone = "us-central1-a"
chain_name = "<%= ctx[:vars]['chain_name'] %>"
labels = {
my_label = "value"
}
storage_locations = ["us-central1"]
}

data "google_compute_image" "debian" {
family = "debian-11"
project = "debian-cloud"
}

resource "google_compute_disk" "persistent" {
name = "<%= ctx[:vars]['disk_name'] %>"
image = data.google_compute_image.debian.self_link
size = 10
type = "pd-ssd"
zone = "us-central1-a"
}