A google_kms_crypto_key is used to test a Google CryptoKey resource
describe google_kms_crypto_key(project: 'chef-gcp-inspec', location: 'europe-west2', key_ring_name: 'kms-key-ring', name: 'kms-key') do
it { should exist }
its('crypto_key_name') { should cmp 'kms-key' }
its('primary_state') { should eq "ENABLED" }
its('purpose') { should eq "ENCRYPT_DECRYPT" }
its('next_rotation_time') { should be > Time.now - 100000 }
its('create_time') { should be > Time.now - 365*60*60*24*10 }
end
describe google_kms_crypto_key(project: 'chef-gcp-inspec', location: 'europe-west2', key_ring_name: 'kms-key-ring', name: "nonexistent") do
it { should_not exist }
end
describe google_kms_crypto_key(project: 'chef-inspec-gcp', location: 'us-east1', key_ring_name: 'key-ring', name: 'crypto-key') do
its('create_time_date') { should be > Time.now - 365*60*60*24*10 }
end
describe google_kms_crypto_key(project: 'chef-inspec-gcp', location: 'us-east1', key_ring_name: 'key-ring', name: 'crypto-key') do
its('next_rotation_time_date') { should be > Time.now - 100000 }
end
describe google_kms_crypto_key(project: 'chef-inspec-gcp', location: 'us-east1', key_ring_name: 'key-ring', name: 'crypto-key') do
its('purpose') { should eq "ENCRYPT_DECRYPT" }
end
describe google_kms_crypto_key(project: 'chef-inspec-gcp', location: 'us-east1', key_ring_name: 'key-ring', name: 'crypto-key') do
its('primary_state') { should eq "ENABLED" }
end
Properties that can be accessed from the google_kms_crypto_key resource:
crypto_key_namecreate_timelabelspurposePossible values:
rotation_periods (seconds). It must be greater than a day (ie, 86400).version_templatealgorithmprotection_levelPossible values:
next_rotation_timekey_ring'projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}'.Ensure the Cloud Key Management Service (KMS) API is enabled for the current project.
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs.chef.io/inspec/resources/google_kms_crypto_key/