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

Add name to google_kms_crypto_key_version datasource #9762

Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .changelog/5065.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
kms: added `name` field to `google_kms_crypto_key_version` datasource
```
11 changes: 11 additions & 0 deletions google/data_source_google_kms_crypto_key_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func dataSourceGoogleKmsCryptoKeyVersion() *schema.Resource {
Required: true,
ForceNew: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"version": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -81,6 +85,9 @@ func dataSourceGoogleKmsCryptoKeyVersionRead(d *schema.ResourceData, meta interf
if err := d.Set("version", flattenKmsCryptoKeyVersionVersion(res["name"], d)); err != nil {
return fmt.Errorf("Error setting CryptoKeyVersion: %s", err)
}
if err := d.Set("name", flattenKmsCryptoKeyVersionName(res["name"], d)); err != nil {
return fmt.Errorf("Error setting CryptoKeyVersion: %s", err)
}
if err := d.Set("state", flattenKmsCryptoKeyVersionState(res["state"], d)); err != nil {
return fmt.Errorf("Error setting CryptoKeyVersion: %s", err)
}
Expand Down Expand Up @@ -135,6 +142,10 @@ func flattenKmsCryptoKeyVersionVersion(v interface{}, d *schema.ResourceData) in
return v
}

func flattenKmsCryptoKeyVersionName(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenKmsCryptoKeyVersionState(v interface{}, d *schema.ResourceData) interface{} {
return v
}
Expand Down
9 changes: 6 additions & 3 deletions website/docs/d/kms_crypto_key_version.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ data "google_kms_key_ring" "my_key_ring" {

data "google_kms_crypto_key" "my_crypto_key" {
name = "my-crypto-key"
key_ring = data.google_kms_key_ring.my_key_ring.self_link
key_ring = data.google_kms_key_ring.my_key_ring.id
}

data "google_kms_crypto_key_version" "my_crypto_key_version" {
crypto_key = data.google_kms_key.my_key.self_link
crypto_key = data.google_kms_key.my_key.id
}
```

## Argument Reference

The following arguments are supported:

* `crypto_key` - (Required) The `self_link` of the Google Cloud Platform CryptoKey to which the key version belongs.
* `crypto_key` - (Required) The `self_link` of the Google Cloud Platform CryptoKey to which the key version belongs. This is also the `id` field of the
`google_kms_crypto_key` resource/datasource.

* `version` - (Optional) The version number for this CryptoKeyVersion. Defaults to `1`.

Expand All @@ -49,6 +50,8 @@ exported:

* `id` - an identifier for the resource with format `//cloudkms.googleapis.com/v1/{{crypto_key}}/cryptoKeyVersions/{{version}}`

* `name` - The resource name for this CryptoKeyVersion in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`

* `state` - The current state of the CryptoKeyVersion. See the [state reference](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion.CryptoKeyVersionState) for possible outputs.

* `protection_level` - The ProtectionLevel describing how crypto operations are performed with this CryptoKeyVersion. See the [protection_level reference](https://cloud.google.com/kms/docs/reference/rest/v1/ProtectionLevel) for possible outputs.
Expand Down