IaC Bazaar
AWSLive-tested

KMS Key with Policy Patterns

Customer-managed KMS keys with sane key policies, aliases, rotation, and multi-region replicas.

terraformAWS#aws

Compare Secrets & Key Management across clouds →

Part of: AWS Production Landing Zone

aws-kmsterraform v1.7

Verification

Live-tested

Really deployed to a cloud sandbox, verified against its outputs and assertions, then destroyed - with the teardown confirmed.

Conformance

  • Static validation (fmt · validate · tflint)
  • Security scan clean (Checkov)
  • Plan test superseded by live test

Provenance

Functional

  • Live-tested - applied, verified, destroyed

Last verified 2026-06-11 · how we verify

Verify this download

cosign · sha-256

Don't take our word for it. Every release is signed with cosign - check the bytes against our pinned public key before you trust them.

# 1. Our pinned public key - fetch once, trust out-of-band
curl -O https://www.iac-bazaar.com/cosign.pub

# 2. This module's Sigstore bundle
curl -o aws-kms-1.0.0.sigstore.json \
  https://www.iac-bazaar.com/api/artifacts/aws-kms/signature

# 3. Verify the tarball you downloaded
cosign verify-blob \
  --key cosign.pub \
  --bundle aws-kms-1.0.0.sigstore.json \
  aws-kms-1.0.0.tar.gz
# → Verified OK

# 4. (optional) confirm the checksum too
echo "194647e06c066e3fa769783e8f836c9446d97780f34cbdf3e3faaf2b1f27aafa  aws-kms-1.0.0.tar.gz" | sha256sum -c

Use it from the registry

terraform · opentofu
module "kms" {
  source  = "www.iac-bazaar.com/iac-bazaar/aws-kms/aws"
  version = "1.0.0"
}

Paid module — needs a purchase (or a subscription that covers it) plus a registry token from /account/tokens. Full setup: registry docs.

Inputs & outputs

Create a free account to read this module's contract

The declared contract — every input name, type, default and description, plus every output — is shown to signed-in accounts, not to anonymous visitors.

A free account sees the contract of every Free module. This one is Basic, so its contract unlocks when you buy it.

Documentation

aws-kms

Customer-managed KMS key with a least-privilege, lockout-safe key policy, automatic rotation on by default, aliases, and optional multi-region replicas. Works with Terraform and OpenTofu (>= 1.6), AWS provider >= 6.0, < 7.0. The generated key policy follows the AWS reference pattern — account root keeps kms:* so the key is never orphaned, while administrators, users, and AWS service principals get only the actions they need.

Status: static-validated, live-test pending. Ships under live-test quarantine — validated with tofu fmt, tofu validate, and tflint. Real apply → verify → destroy against an AWS account is pending a cloud sandbox. KMS destroy is non-immediate by design: terraform destroy only schedules deletion (deletion_window_in_days, 7–30 days), and the key remains billable (~$1/mo) and recoverable until the window elapses. This is an expected exception to the marketplace's instant-destroyConfirmed semantics, not a teardown failure.

What you get:

  • aws_kms_key — symmetric or asymmetric/HMAC, with rotation, a deletion window, and an optional multi-region primary.
  • aws_kms_key_policy — a generated least-privilege document (override with a full policy JSON string if you need to).
  • aws_kms_alias — one or more alias/<name> aliases pointed at the key.
  • aws_kms_replica_key — cross-region replicas of a multi-region primary.

Secure defaults

  • Rotation on (enable_key_rotation = true) for symmetric encryption keys; automatically nulled for asymmetric/HMAC specs that do not support it.
  • Generated least-privilege policy: root keeps kms:* (the non-lockout safeguard), administration and cryptographic use are split into separate statements, and service principals are pinned to your account via kms:CallerAccount. Key-user grant creation is restricted to AWS resources (kms:GrantIsForAWSResource).
  • 30-day deletion window by default — the maximum recovery runway.
  • bypass_policy_lockout_safety_check defaults to false; the safety check stays on.
  • Reserved aws/* alias names and AWS-managed keys are rejected by validation.

Provider pin

aws = {
  source  = "hashicorp/aws"
  version = ">= 6.0, < 7.0"
}

License

Commercial — LicenseRef-IaCBazaar-Commercial. © IaC Bazaar. Original work (not derived from a third-party module).

Usage code & full reference unlock after purchase

The complete copy-paste usage, the full input/output reference, and operational notes ship with your licence - shown here and bundled in the download.

  • Usage
  • Inputs
  • Outputs

Related modules