Control: 2.8 Ensure rotation for customer created CMKs is enabled
Description
AWS Key Management Service (KMS) allows customers to rotate the backing key which is key material stored within the KMS which is tied to the key ID of the Customer Created customer master key (CMK). It is the backing key that is used to perform cryptographic operations such as encryption and decryption. Automated key rotation currently retains all prior backing keys so that decryption of encrypted data can take place transparently. It is recommended that CMK key rotation be enabled.
Rotating encryption keys helps reduce the potential impact of a compromised key as data encrypted with a new key cannot be accessed with a previous key that may have been exposed.
Remediation
Via the Management Console:
- Sign in to the AWS Management Console and open the IAM console.
 - In the left navigation pane, choose 
Encryption Keys. - Select a customer created master key (CMK).
 - Under the 
Key Policysection, move down toKey Rotation. - Check the 
Rotate this key every yearcheckbox. 
Via CLI
- Run the following command to enable key rotation:
 
aws kms enable-key-rotation --key-id <kms_key_id>
Usage
Run the control in your terminal:
powerpipe control run aws_compliance.control.cis_v120_2_8Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run aws_compliance.control.cis_v120_2_8 --shareSQL
This control uses a named query:
select  arn as resource,  case    when origin = 'EXTERNAL' then 'skip'    when customer_master_key_spec <> 'SYMMETRIC_DEFAULT' then 'skip'    when key_state = 'PendingDeletion' then 'skip'    when key_state = 'Disabled' then 'skip'    when not key_rotation_enabled then 'alarm'    else 'ok'  end as status,  case    when origin = 'EXTERNAL' then title || ' has imported key material.'    when customer_master_key_spec <> 'SYMMETRIC_DEFAULT' then title || ' is non-symmetric customer key.'    when key_state = 'PendingDeletion' then title || ' is pending deletion.'    when key_state = 'Disabled' then title || ' is disabled.'    when not key_rotation_enabled then title || ' key rotation disabled.'    else title || ' key rotation enabled.'  end as reason    , region, account_idfrom  aws_kms_keywhere  key_manager = 'CUSTOMER';