Description
Cloud KMS automatic rotation creates a new primary version of a symmetric ENCRYPT_DECRYPT key. Choose rotation_period for the sensitivity of the data and your policy. Asymmetric keys need a separate replacement process.
Potential impact
Existing data still uses its original key version. Destroying that version while the data depends on it can prevent decryption.
Remediation
When first setting up a rotation schedule, set both the interval and the first rotation time in Cloud KMS. This google.cloud 1.13.0 Ansible task sends only the interval, so use it on a key that already has a schedule. Verify the next rotation time and test the application with the new primary version. Keep access to older key versions while existing data still needs them.
Examples
Set the project to the one that owns the key ring. Replace /tmp/auth.pem with the path to your service account JSON credentials file. The two tasks in the first excerpt are alternatives for the same key.
Before
- name: create a crypto key
google.cloud.gcp_kms_crypto_key:
name: test_object
key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
project: test_project
auth_kind: serviceaccount
rotation_period: "315356000s"
service_account_file: "/tmp/auth.pem"
state: present
- name: create a crypto key2
google.cloud.gcp_kms_crypto_key:
name: test_object
key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
The first task specifies about ten years. The second omits the interval, which alone leaves an existing schedule in place.
After
- name: create a crypto key
google.cloud.gcp_kms_crypto_key:
name: test_object
key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
project: test_project
auth_kind: serviceaccount
rotation_period: 7776000s
service_account_file: /tmp/auth.pem
state: present
7776000s is 90 days. Use it when that interval meets your policy.