Overview
KMS (Key Management Service) provides encryption keys to protect data at rest. While Fjall and AWS use default encryption automatically, you can create custom KMS keys when you need:- Customer-managed key rotation
- Cross-account data access
- Compliance requirements for key ownership
- Granular access control
Default Encryption
Most AWS services use encryption by default:When to Create Custom Keys
Create explicit KMS keys for:- Compliance - Need customer-managed keys (CMK)
- Key rotation control - Manage rotation schedule
- Cross-account sharing - Share encrypted data
- Audit requirements - Detailed CloudTrail logging
- Cost allocation - Track encryption costs per key
Custom KMS Keys
Create a Key
Use with S3
Use with Secrets Manager
Use with RDS
Granting Access
Lambda Access
ECS Access
Key Aliases
Aliases make keys easier to reference:Common Patterns
Shared Encryption Key
One key for multiple resources:Environment-Specific Keys
Cross-Account Access
Key Rotation
Automatic Rotation
- Creates new cryptographic material
- Keeps old versions for decryption
- Transparent to applications
- Recommended for production
Cost Optimization
KMS Pricing
- Customer-managed keys: $1/month per key
- API requests: $0.03 per 10,000 requests
Reduce Costs
1. Use S3 Bucket Keys - Reduces API calls by 99%:Accessing Encrypted Data
From Lambda
From ECS
Monitoring
Key usage is logged to CloudTrail:Encrypt- data encryption operationsDecrypt- data decryption operationsGenerateDataKey- envelope encryptionScheduleKeyDeletion- key deletion
Best Practices
- Use default encryption for most use cases (AWS managed keys)
- Enable key rotation for customer-managed keys
- Create one key per environment (dev, staging, prod)
- Share keys across resources to reduce costs
- Use S3 Bucket Keys to minimize API calls
- Grant minimal permissions (decrypt-only when possible)
- Use aliases for easier key management
- Monitor CloudTrail for unexpected usage
- Set RemovalPolicy.RETAIN for production keys
Troubleshooting
Access Denied on Encrypted Resources
- Check IAM role has
kms:Decryptpermission - Verify key policy allows the role
- Confirm resource uses the expected key
- Review CloudTrail for detailed error
High KMS Costs
- Enable S3 Bucket Keys (
bucketKeyEnabled: true) - Share keys across resources
- Cache decrypted values in application
- Consider AWS managed keys for non-sensitive data
Key Not Found
- Verify key exists in the same region
- Check key alias is correct
- Ensure key hasn’t been scheduled for deletion
See Also
- Secrets Manager - Encrypted secrets storage
- S3 Bucket - Encrypted object storage
- DatabaseFactory - Encrypted database storage
- IAM Role - Grant KMS permissions