Expand description
Cross-service KMS hook.
Services that accept a KmsKeyId (Secrets Manager, SSM
SecureString, S3 SSE-KMS, SQS, SNS, DynamoDB) call into this
module so that:
- The supplied key is resolved (alias
aws/<service>and bare aliases included), auto-provisioning AWS-managed keys on first use to match real AWS. - Each call is recorded in
KmsUsageStateso test code can assert through/_fakecloud/kms/usagethat the right service triggered the right operation on the right key. - The returned ciphertext is a real envelope decryptable by the
public KMS
DecryptAPI (uses the samefakecloud-kms:envelope as the existing service-side encrypt path).
Encryption context, key policy enforcement, and KMS-managed key rotation come in follow-up PRs.
Structs§
- KmsService
Hook - Hook used by service crates that need to call KMS for encryption / decryption without going through the AWS-shaped HTTP layer.
- KmsUsage
Record - One recorded KMS hook call. Returned by the introspection endpoint
so test code can assert
kms:GenerateDataKey/kms:Decryptran on the expected key + service principal. - KmsUsage
State
Enums§
Constants§
- DEFAULT_
AWS_ MANAGED_ ALIASES - Canonical AWS-managed service aliases (
alias/aws/<service>). Real AWS pre-creates these in every account/region, soaws kms list-aliasesreturns them on a brand-new account anddata.aws_kms_aliasresolves them. The Terraform acceptance tests for several services (e.g.aws_dynamodb_tableencryption) readalias/aws/<service>via that data source, so they must be listable even before any KMS use.
Functions§
- ensure_
default_ managed_ aliases - Idempotently provision every
DEFAULT_AWS_MANAGED_ALIASESentry that isn’t already present, soListAliasesmirrors real AWS. Provisioning a missing alias also mints its backing AWS-managed key, matching the auto-provision-on-first-use path in [resolve_or_provision].