Certopolis

AWS Certified DevOps Engineer – Professional

KMS key rotation: automatic, on-demand, manual, multi-Region

AWS KMS rotates key material automatically only for symmetric encryption keys whose material KMS generated. The KMS Developer Guide says the default rotation period is 365 days. Asymmetric keys, HMAC keys and keys in custom key stores must be rotated manually, by creating a new key and pointing an alias at it.

Automatic vs on-demand vs manual rotation

Automatic rotation is optional for customer managed keys and is supported only on symmetric encryption keys with AWS_KMS origin. If you do not set RotationPeriodInDays, the period is 365 days. AWS managed keys are rotated every year and you cannot turn that on or off.

On-demand rotation starts a rotation immediately, whether or not automatic rotation is enabled, and does not change the automatic schedule. It is supported on symmetric encryption keys with AWS_KMS origin and on those with imported key material.

Rotation changes the key material only. AWS KMS keeps the older material, and when you decrypt it picks the material that encrypted the ciphertext, so nothing needs re-encrypting. A key that is disabled or pending deletion is not rotated.

How does manual rotation work?

Asymmetric KMS keys, HMAC KMS keys and keys in custom key stores support neither automatic nor on-demand rotation. Manual rotation means creating a new KMS key and using it in place of the current one.

The original key must stay enabled, because only it can decrypt or verify what it produced. Applications should refer to the key through an alias, so that rotation is a change of the alias target instead of a code change. Aliases work for cryptographic operations such as GenerateMac, VerifyMac, Sign and Encrypt, but not for operations that manage keys, such as DisableKey or ScheduleKeyDeletion.

For manually rotated symmetric encryption keys, omit KeyId when calling Decrypt. AWS KMS finds the key that encrypted the ciphertext.

What is different for multi-Region keys and deletion?

Related multi-Region keys share the same key ID and key material, so data encrypted in one Region can be decrypted in another without re-encrypting. Key rotation is a shared property. You enable automatic rotation, or start on-demand rotation, only on the primary key. AWS KMS copies the setting and the new key material to every replica.

Other properties are not shared. A replica key has its own key policy, grants, aliases and tags, and you manage each key independently. Multi-Region keys are not global: AWS never replicates one into a Region for you.

Deleting a key is irreversible. ScheduleKeyDeletion sets a waiting period of 7 to 30 days, 30 by default. During it the key is in the Pending deletion state and cannot be used in any cryptographic operation, and you can still cancel the deletion. A primary key is not deleted until all of its replica keys are deleted. AWS suggests disabling a key instead when you might need it again.

Where the exam catches people

  • Believing automatic rotation can be enabled on an HMAC or asymmetric key: those need manual rotation with a new key and an alias.
  • Believing the old key can be disabled after a manual rotation: it must stay enabled to decrypt or verify what it produced.
  • Believing rotation must be enabled on each replica of a multi-Region key: it is set on the primary only and copied to the replicas.
  • Believing a replica key inherits the primary key's key policy: each replica has its own key policy.
  • Believing a key pending deletion can still decrypt: it cannot be used in any cryptographic operation during the waiting period.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. A company's release pipeline in AWS CodeBuild signs every release manifest with an HMAC KMS key, calling GenerateMac through the alias alias/release-mac. Deployment hosts call VerifyMac with the same alias before they install a release. The hosts must still be able to verify any manifest signed in the last two years. A new security standard requires the key material behind alias/release-mac to be replaced every year, and the pipeline must keep signing through that alias. Which combination of steps should the DevOps engineer take to meet these requirements? (Select THREE.)

    Right. In the game that’s Renown for your Security and Compliance building.

    Not that one: C,D,E is right. In the game your Security and Compliance building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The old keys stay enabled because they are the only way to check the MACs they made. And the hosts need to know which key made each MAC: VerifyMac requires the KeyId of that key, and a call through the alias after it has moved fails for every older manifest. Recording the signing key's ARN with the manifest solves that.

    Written from docs.aws.amazon.com/kms/latest/developerguide/rotate-keys-manually.html

  2. A company's payment service runs in us-east-1, with standby copies in eu-west-1 and ap-southeast-2. An AWS CloudFormation template creates the service's KMS key in us-east-1 as an AWS::KMS::Key with MultiRegion set to true. A second template, which a StackSet deploys to the other two Regions, creates an AWS::KMS::ReplicaKey from it in each Region. Automatic rotation is off today. A new standard requires the key material that the service uses in all three Regions to change every 180 days, without re-encrypting stored data, and each Region must keep decrypting data written in the others. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Security and Compliance building.

    Not that one: C is right. In the game your Security and Compliance building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    It is set on the primary only; AWS KMS creates the new material there every 180 days and copies it to both replicas before any key encrypts with it, so all three Regions move together and still decrypt each other's data. Old material is kept, so nothing is re-encrypted. The replica template needs no change.

    Written from docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html

  3. A company retires microservices through a decommissioning pipeline in AWS CodePipeline. Each service encrypts its data under its own customer managed AWS KMS key, and the pipeline holds an IAM role with full AWS KMS permissions on those keys. When a service is retired, any call that tries to encrypt or decrypt with its key must fail from that moment. The platform team wants a month in which it can put the key back into service if a forgotten dependency breaks. After that month, nobody should have to come back and clean up the key. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Security and Compliance building.

    Not that one: A is right. In the game your Security and Compliance building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    A waiting period of 30 days, the longest allowed, gives the team its month: CancelKeyDeletion stops the clock and leaves the key Disabled, so EnableKey then returns it to service. If nobody cancels, AWS KMS removes the key and its aliases when the period ends, with no further step from the pipeline.

    Written from docs.aws.amazon.com/kms/latest/developerguide/deleting-keys.html

Ask for something