Skip to main content

KMS Key with Rotation

πŸ“¦ Overview​

This Terraform module provisions an AWS KMS key with automatic rotation enabled, helping maintain cryptographic hygiene and meet compliance standards.

It’s ideal for organizations that want to enforce secure key lifecycle practices without managing key rollover manually.


βœ… Key Features​

  • Creates a customer-managed KMS key
  • Enables automatic annual key rotation
  • Supports alias, description, and tagging
  • Usable across services like S3, Lambda, and EBS
  • Ensures secure encryption workflows with minimal admin overhead

πŸ’Ό Use Cases​

  • Compliance-driven environments (e.g., HIPAA, FedRAMP, PCI)
  • Encrypting sensitive workloads that require key freshness
  • Projects with rotating personnel or long-term cryptographic assets
  • Teams standardizing encryption hygiene across services

πŸ“₯ Input Variables​

NameTypeDescription
regionstringAWS region to deploy the KMS key
aliasstringAlias for the key (e.g., alias/rotating-key)
descriptionstringDescription of the key for auditing and discovery
environmentstringDeployment environment (e.g., dev, staging, prod)

πŸ“€ Outputs​

NameDescription
key_idThe unique identifier of the KMS key
key_arnThe ARN of the provisioned KMS key
alias_nameThe alias assigned to the KMS key

πŸš€ Deployment Readiness​

  • βœ… Compatible with Terraform 1.0+
  • βœ… Tested with AWS provider 5.x
  • πŸ§ͺ Requires permissions for kms:CreateKey, kms:EnableKeyRotation, etc.

πŸ› οΈ Example Usage​

module "kms_key_rotation" {
source = "git::ssh://git@github.com/archiphire/aws-level-1-modules.git//security/kms-key-rotation?ref=v1.0.0"

region = "us-east-1"
alias = "alias/archiphire-rotating-key"
description = "KMS key with auto-rotation enabled"
environment = "prod"
}
terraform init
terraform plan
terraform apply

or

tofu init
tofu plan
tofu apply

🧹 Cleanup Options​

Terraform Destroy (for test environments):

terraform destroy

or

tofu destroy

Manual Deletion (for production):

aws kms schedule-key-deletion --key-id "key_id" --pending-window-in-days 7

Use aws kms list-keys and describe-key to locate your key.

πŸ›‘οΈ Notes​

This is a Level 1 security module with key rotation enabled by default. To enforce access boundaries or integrate cross-account usage, extend with KMS key policies or grants.

πŸ”’ Deployment Package Notice​

This module is part of the Level 1 AWS License Tier. To access the full deployment package and source code, subscribe to Archiphire.