Data Protection Operations: KMS, ACM, Secrets Manager and Parameter Store for Keys, Certificates and Secrets
AWS KMS
| Concept | Meaning |
|---|---|
| KMS key (CMK) | Logical key in KMS. Material never leaves KMS unencrypted. Used to encrypt up to 4 KB directly or to protect data keys |
| AWS owned keys | Managed by AWS services internally, invisible, free |
| AWS managed keys | aws/s3, aws/ebs... created for you. Automatic rotation yearly, you cannot edit the key policy |
| Customer managed keys | You control policy, rotation, enable/disable, deletion, tags, aliases. Small monthly fee plus API cost |
| Symmetric vs asymmetric | Symmetric (AES-256-GCM) default. Asymmetric RSA/ECC for sign/verify or encrypt outside AWS |
| HMAC keys | Generate and verify MACs |
| Data key | Generated with GenerateDataKey. You encrypt data locally with the plaintext data key and store the encrypted data key beside the data (envelope encryption) |
| Alias | Friendly name alias/app-prod that can be repointed |
| Multi-Region keys | Same key id and material replicated to other Regions (for DR, global tables, cross-Region decrypt) |
| Key store options | KMS standard, CloudHSM-backed custom key store, external key store (XKS) |
bash
aws kms create-key --description "app data" --key-usage ENCRYPT_DECRYPT
aws kms create-alias --alias-name alias/app-prod --target-key-id <key-id>
aws kms enable-key-rotation --key-id <key-id>
aws kms get-key-rotation-status --key-id <key-id>
aws kms encrypt --key-id alias/app-prod --plaintext fileb://secret.txt --query CiphertextBlob --output text | base64 -d > secret.enc
aws kms schedule-key-deletion --key-id <key-id> --pending-window-in-days 30 # 7 to 30 days, can be cancelled
aws kms disable-key --key-id <key-id>
Key Policies, IAM and Grants
- A KMS key must have a key policy. If the policy does not allow IAM to manage access (
kms:*to the account root principal), IAM policies alone have no effect. The default policy delegates to IAM - To use a key a principal needs permission in the key policy or IAM (or a grant). Cross-account use needs both the key policy in the key's account and an IAM allow in the caller's account
- Grants give temporary, programmatic delegation (used by EBS, RDS, and similar services). Retire when done
- Encryption context: extra authenticated key/value pairs that must match on decrypt, also shown in CloudTrail and usable in conditions
- Use **
kms:ViaServiceandkms:CallerAccount** conditions to restrict a key to specific services and accounts - Every API call is logged to CloudTrail
| Rotation | Behavior |
|---|---|
| Automatic | Customer managed symmetric keys: new key material yearly (configurable period), same key ID and ARN, old material kept to decrypt old data. No app change |
| Manual | Create a new key, update the alias, re-encrypt as needed. Needed for asymmetric and imported keys |
| Imported key material | You supply the material, can expire, no automatic rotation |
| KMS problem | Fix |
|---|---|
AccessDeniedException using a key | Key policy and IAM policy, grants, condition keys, cross-account both sides, key not disabled |
DisabledException / KMSInvalidStateException | Key disabled or pending deletion. Enable or cancel deletion |
| EBS/RDS/S3 stops working after key change | Services lost permission or key deleted. Deleting a key makes data unrecoverable |
ThrottlingException | Request quota per Region (shared). Use data key caching, S3 Bucket Keys, request increase |
| Cross-Region copy of encrypted snapshot fails | Destination KMS key must be in the destination Region and permitted |
AWS Certificate Manager (ACM)
| Topic | Notes |
|---|---|
| Public certificates | Free. Use with ELB, CloudFront, API Gateway. Not exportable, so they do not install directly on EC2 (use exportable certificates feature or a private CA, or put the ELB in front) |
| Validation | DNS validation (add a CNAME in Route 53, enables automatic renewal) preferred over email |
| Renewal | Managed certificates renew automatically when validation CNAME stays in place and the cert is in use |
| Region | Regional. CloudFront needs the certificate in us-east-1 |
| Private CA | AWS Private CA issues private certificates for internal services and devices (paid) |
| Imported certificates | You manage renewal. ACM sends expiry events (45, 30 days...). Use EventBridge and the Config rule acm-certificate-expiration-check |
bash
aws acm request-certificate --domain-name app.example.com --subject-alternative-names "*.example.com" --validation-method DNS
aws acm describe-certificate --certificate-arn <arn> --query 'Certificate.[Status,DomainValidationOptions[].ResourceRecord]'
aws acm list-certificates --certificate-statuses ISSUED PENDING_VALIDATION
| ACM problem | Fix |
|---|---|
Stuck PENDING_VALIDATION | DNS CNAME missing or in wrong zone, or email not approved |
| Certificate not visible in CloudFront | Request it in us-east-1 |
| Renewal failed | Validation record deleted, certificate not in use, domain no longer resolves |
Browser NET::ERR_CERT_COMMON_NAME_INVALID | Domain name not covered by SANs |
AWS Secrets Manager
- Stores secrets (database credentials, API keys) encrypted with KMS, with versions and staging labels (
AWSCURRENT,AWSPREVIOUS,AWSPENDING) - Automatic rotation using a Lambda function (ready-made for RDS, Aurora, Redshift, DocumentDB). Rotation steps:
createSecret→setSecret→testSecret→finishSecret. The Lambda must reach both Secrets Manager and the database (VPC/endpoint) and the secret must be in the same Region - Managed master passwords for RDS/Aurora handle rotation without your own Lambda
- Resource policy for cross-account access, replication to other Regions, tags, and CloudTrail audit
- Retrieve in code with the SDK (cache the value) or via ECS/EKS/Lambda integrations and CloudFormation dynamic references
- Cost: per secret per month plus API calls
bash
aws secretsmanager create-secret --name prod/db/app --secret-string '{"username":"app","password":"change-me"}'
aws secretsmanager get-secret-value --secret-id prod/db/app --query SecretString --output text
aws secretsmanager rotate-secret --secret-id prod/db/app --rotation-lambda-arn $LAMBDA --rotation-rules AutomaticallyAfterDays=30
aws secretsmanager replicate-secret-to-regions --secret-id prod/db/app --add-replica-regions Region=ap-southeast-1
Systems Manager Parameter Store
| Parameter Store | Secrets Manager | |
|---|---|---|
| Types | String, StringList, SecureString (KMS) | Secret string/binary |
| Rotation | No built-in rotation | Built-in rotation |
| Cost | Standard tier free, advanced tier paid | Per secret per month |
| Size | 4 KB (8 KB advanced) | 64 KB |
| Cross-account sharing | Advanced tier with RAM | Resource policy |
| Hierarchy and history | Yes (/prod/app/db), versions | Versions with labels |
| Best for | Configuration and simple secrets | Credentials needing rotation, cross-Region replication |
CloudHSM
- Dedicated FIPS 140-2 Level 3 hardware security modules in your VPC that you control (AWS cannot see keys). Use for strict compliance, custom key stores, or crypto APIs (PKCS#11, JCE, CNG)
- Create a cluster across AZs for availability. You manage users and backups
Practice Tasks
- Create a customer managed key with rotation and a restrictive key policy
- Encrypt an S3 bucket and an EBS volume with the key and watch the
Decryptevents in CloudTrail - Request an ACM certificate with DNS validation and attach it to an ALB
- Create a secret with 30-day rotation for an RDS database
- Move an application's configuration into Parameter Store and read it with a role
Conclusion
Use KMS keys with careful key policies (and rotation) for encryption, ACM for free, auto-renewed TLS certificates on ELB, CloudFront (us-east-1) and API Gateway, Secrets Manager for rotated credentials, Parameter Store for configuration, and CloudHSM only when you need dedicated hardware control.
Quick Summary: KMS; policies and grants; rotation; ACM; Secrets Manager; Parameter Store; CloudHSM.

