mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-05 02:01:05 +00:00
30fe927df6
<!-- This change is generated by MagicModules. --> /cc @kierachell
36 lines
803 B
Go
36 lines
803 B
Go
package google
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
)
|
|
|
|
func dataSourceGoogleKmsCryptoKey() *schema.Resource {
|
|
dsSchema := datasourceSchemaFromResourceSchema(resourceKmsCryptoKey().Schema)
|
|
addRequiredFieldsToSchema(dsSchema, "name")
|
|
addRequiredFieldsToSchema(dsSchema, "key_ring")
|
|
|
|
return &schema.Resource{
|
|
Read: dataSourceGoogleKmsCryptoKeyRead,
|
|
Schema: dsSchema,
|
|
}
|
|
|
|
}
|
|
|
|
func dataSourceGoogleKmsCryptoKeyRead(d *schema.ResourceData, meta interface{}) error {
|
|
config := meta.(*Config)
|
|
|
|
keyRingId, err := parseKmsKeyRingId(d.Get("key_ring").(string), config)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
cryptoKeyId := kmsCryptoKeyId{
|
|
KeyRingId: *keyRingId,
|
|
Name: d.Get("name").(string),
|
|
}
|
|
|
|
d.SetId(cryptoKeyId.cryptoKeyId())
|
|
|
|
return resourceKmsCryptoKeyRead(d, meta)
|
|
}
|