For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/ansible-gcp-high-google-kms-crypto-key-rotation-period.md.
A documentation index is available at /llms.txt.
KMS crypto keys must have a rotation_period of 90 days or less to limit key lifetime and reduce the blast radius if a key is compromised.
For Ansible resources using google.cloud.gcp_kms_crypto_key or gcp_kms_crypto_key, the rotation_period property must be a duration string in seconds ending with an s. The numeric value must be less than or equal to 7776000 (90 days). Resources missing rotation_period, lacking the s suffix, or with a value greater than 7776000 are flagged.
Secure configuration example:
- name:Create KMS crypto key with 90-day rotationgoogle.cloud.gcp_kms_crypto_key:name:my-keykey_ring:projects/my-project/locations/global/keyRings/my-keyringpurpose:ENCRYPT_DECRYPTrotation_period:"7776000s"state:present
Compliant Code Examples
- name:create a key ringgoogle.cloud.gcp_kms_key_ring:name:key-key-ringlocation:us-central1project:'{{ gcp_project }}'auth_kind:'{{ gcp_cred_kind }}'service_account_file:'{{ gcp_cred_file }}'state:presentregister:keyring- name:create a crypto keygoogle.cloud.gcp_kms_crypto_key:name:test_objectkey_ring:projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ringproject:test_projectauth_kind:serviceaccountrotation_period:7776000sservice_account_file:/tmp/auth.pemstate:present
Non-Compliant Code Examples
---- name:create a key ringgoogle.cloud.gcp_kms_key_ring:name:key-key-ringlocation:us-central1project:"{{ gcp_project }}"auth_kind:"{{ gcp_cred_kind }}"service_account_file:"{{ gcp_cred_file }}"state:presentregister:keyring- name:create a crypto keygoogle.cloud.gcp_kms_crypto_key:name:test_objectkey_ring:projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ringproject:test_projectauth_kind:serviceaccountrotation_period:"315356000s"service_account_file:"/tmp/auth.pem"state:present- name:create a crypto key2google.cloud.gcp_kms_crypto_key:name:test_objectkey_ring:projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ringproject:test_projectauth_kind:serviceaccountservice_account_file:"/tmp/auth.pem"state:present
1
2
rulesets:- Ansible / GCP # Rules to enforce / GCP.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.