Interview Prep/AWS/CloudFormation, CloudWatch, KMS, Secrets and Cost

Under load, S3 and SSM calls start failing with `ThrottlingException: You have exceeded the rate at which you may call KMS. Reduce the frequency of your calls.`

AdvancedTroubleshootingCloudFormation, CloudWatch, KMS, Secrets and Cost
Answer

Likely causes → Every SSE-KMS object read or write, every SecureString parameter read and every envelope encryption call hits KMS, and they share a per-account, per-Region request quota for cryptographic operations (thousands of requests per second, depending on the Region).

Diagnose →

aws service-quotas list-service-quotas --service-code kms \
  --query "Quotas[?contains(QuotaName,'Cryptographic operations')].[QuotaName,Value]"
# CloudWatch AWS/Usage: Service=KMS, Type=API, Resource=Decrypt/GenerateDataKey
aws s3api get-bucket-encryption --bucket data --query 'ServerSideEncryptionConfiguration.Rules[].BucketKeyEnabled'

Fix →

  1. Turn on S3 Bucket Keys, which cut KMS calls from S3 by up to 99%: aws s3api put-bucket-encryption --bucket data --server-side-encryption-configuration '{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"aws:kms","KMSMasterKeyID":"<key>"},"BucketKeyEnabled":true}]}'
  2. Cache decrypted secrets and parameters in the app (Secrets Manager caching client, Parameters and Secrets Lambda extension)
  3. Use data key caching (AWS Encryption SDK)
  4. Request a quota increase

Prevent → Alarm on KMS usage at 70% of the quota, and design for caching from the start.

aws All AWS questions Roadmap: Cloud cost & architecture

More on CloudFormation, CloudWatch, KMS, Secrets and Cost