Skip to content

Commit

Permalink
Add name to google_kms_crypto_key_version datasource (GoogleCloud…
Browse files Browse the repository at this point in the history
…Platform#5065)

Co-authored-by: upodroid <[email protected]>
  • Loading branch information
upodroid authored and khajduczenia committed Oct 12, 2021
1 parent 327f4d2 commit 8588d76
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
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
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

0 comments on commit 8588d76

Please sign in to comment.