Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Add Snapshot location to compute snapshot (#3896) (#442)
Browse files Browse the repository at this point in the history
* added storage locations

* add storage locations to field

* tweak cmek logic

* fix the decoder logic and cleanup whitespaces

* remove duplicate entry

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Sep 4, 2020
1 parent 5e860a3 commit 7173605
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/resources/google_compute_disk.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Properties that can be accessed from the `google_compute_disk` resource:

* `kms_key_name`: The name of the encryption key that is stored in Google Cloud KMS.

* `kms_key_service_account`: The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.
* `kms_key_service_account`: The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.

* `source_image_id`: The ID value of the image used to create this disk. This value identifies the exact image that was used to create this persistent disk. For example, if you created the persistent disk from an image that was later deleted and recreated under the same name, the source image ID would identify the exact version of the image that was used.

Expand All @@ -93,7 +93,7 @@ Properties that can be accessed from the `google_compute_disk` resource:

* `kms_key_name`: The name of the encryption key that is stored in Google Cloud KMS. Your project's Compute Engine System service account (`service-{{PROJECT_NUMBER}}@compute-system.iam.gserviceaccount.com`) must have `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature.

* `kms_key_service_account`: The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.
* `kms_key_service_account`: The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.

* `source_snapshot`: The source snapshot used to create this disk. You can provide this as a partial or full URL to the resource. If the snapshot is in another project than this disk, you must supply a full URL. For example, the following are valid values: * `https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot` * `projects/project/global/snapshots/snapshot` * `global/snapshots/snapshot`

Expand Down
6 changes: 6 additions & 0 deletions docs/resources/google_compute_snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Properties that can be accessed from the `google_compute_snapshot` resource:

* `storage_bytes`: A size of the storage used by the snapshot. As snapshots share storage, this number is expected to change with snapshot creation/deletion.

* `storage_locations`: Cloud Storage bucket storage location of the snapshot (regional or multi-regional).

* `licenses`: A list of public visible licenses that apply to this snapshot. This can be because the original image had licenses attached (such as a Windows image). snapshotEncryptionKey nested object Encrypts the snapshot using a customer-supplied encryption key.

* `labels`: Labels to apply to this Snapshot.
Expand All @@ -57,12 +59,16 @@ Properties that can be accessed from the `google_compute_snapshot` resource:

* `kms_key_name`: The name of the encryption key that is stored in Google Cloud KMS.

* `kms_key_service_account`: The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.

* `source_disk_encryption_key`: The customer-supplied encryption key of the source snapshot. Required if the source snapshot is protected by a customer-supplied encryption key.

* `raw_key`: Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource.

* `kms_key_name`: The name of the encryption key that is stored in Google Cloud KMS.

* `kms_key_service_account`: The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.


## GCP Permissions

Expand Down
1 change: 1 addition & 0 deletions docs/resources/google_compute_snapshots.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ See [google_compute_snapshot.md](google_compute_snapshot.md) for more detailed i
* `names`: an array of `google_compute_snapshot` name
* `descriptions`: an array of `google_compute_snapshot` description
* `storage_bytes`: an array of `google_compute_snapshot` storage_bytes
* `storage_locations`: an array of `google_compute_snapshot` storage_locations
* `licenses`: an array of `google_compute_snapshot` licenses
* `labels`: an array of `google_compute_snapshot` labels
* `label_fingerprints`: an array of `google_compute_snapshot` label_fingerprint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ class SnapshotSnapshotEncryptionKey

attr_reader :kms_key_name

attr_reader :kms_key_service_account

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@raw_key = args['rawKey']
@sha256 = args['sha256']
@kms_key_name = args['kmsKeyName']
@kms_key_service_account = args['kmsKeyServiceAccount']
end

def to_s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ class SnapshotSourceDiskEncryptionKey

attr_reader :kms_key_name

attr_reader :kms_key_service_account

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@raw_key = args['rawKey']
@kms_key_name = args['kmsKeyName']
@kms_key_service_account = args['kmsKeyServiceAccount']
end

def to_s
Expand Down
2 changes: 2 additions & 0 deletions libraries/google_compute_snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ComputeSnapshot < GcpResourceBase
attr_reader :name
attr_reader :description
attr_reader :storage_bytes
attr_reader :storage_locations
attr_reader :licenses
attr_reader :labels
attr_reader :label_fingerprint
Expand All @@ -52,6 +53,7 @@ def parse
@name = @fetched['name']
@description = @fetched['description']
@storage_bytes = @fetched['storageBytes']
@storage_locations = @fetched['storageLocations']
@licenses = @fetched['licenses']
@labels = @fetched['labels']
@label_fingerprint = @fetched['labelFingerprint']
Expand Down
2 changes: 2 additions & 0 deletions libraries/google_compute_snapshots.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ComputeSnapshots < GcpResourceBase
filter_table_config.add(:names, field: :name)
filter_table_config.add(:descriptions, field: :description)
filter_table_config.add(:storage_bytes, field: :storage_bytes)
filter_table_config.add(:storage_locations, field: :storage_locations)
filter_table_config.add(:licenses, field: :licenses)
filter_table_config.add(:labels, field: :labels)
filter_table_config.add(:label_fingerprints, field: :label_fingerprint)
Expand Down Expand Up @@ -81,6 +82,7 @@ def transformers
'name' => ->(obj) { return :name, obj['name'] },
'description' => ->(obj) { return :description, obj['description'] },
'storageBytes' => ->(obj) { return :storage_bytes, obj['storageBytes'] },
'storageLocations' => ->(obj) { return :storage_locations, obj['storageLocations'] },
'licenses' => ->(obj) { return :licenses, obj['licenses'] },
'labels' => ->(obj) { return :labels, obj['labels'] },
'labelFingerprint' => ->(obj) { return :label_fingerprint, obj['labelFingerprint'] },
Expand Down

0 comments on commit 7173605

Please sign in to comment.