| Published | 26/07/2026 |
| Platform | AWS Study Group |
| Link | https://www.facebook.com/groups/awsstudygroupfcj/posts/2225146494916977/ |
| Evidence | ![]() |
Hello everyone!
When building backend systems, we frequently work with databases, storage containers, and APIs. Protecting data is always a top priority, especially as an application grows.
A common question is:
How can we securely encrypt data without designing and operating an entire cryptographic key management system ourselves?
In this article, I will introduce AWS Key Management Service (AWS KMS), a powerful AWS service designed to manage the lifecycle of cryptographic keys.
AWS Key Management Service is a fully managed service that allows you to create, control, and rotate cryptographic keys used to encrypt data or generate digital signatures.
AWS KMS supports several types of keys for different use cases:
One of the most important characteristics of AWS KMS is how it protects these keys at the physical hardware level.
AWS KMS keys are not stored on ordinary EC2 instances or in standard databases. Instead, they are created and managed inside dedicated Hardware Security Modules, commonly known as HSMs.
These devices are designed to protect cryptographic material and are validated under FIPS 140 Level 3 security requirements.
The plaintext form of a KMS key never leaves the AWS KMS hardware boundary. AWS employees cannot export or directly access the plaintext key material.
This significantly reduces the risks associated with manually storing and managing encryption keys.
One reason AWS KMS is widely used is its seamless integration with many services across the AWS ecosystem.
Amazon S3 can automatically encrypt objects before storing them by using server-side encryption with AWS KMS keys, also known as SSE-KMS.
Amazon RDS can use AWS KMS to encrypt database instances, automated backups, snapshots, and read replicas.
Amazon EBS can encrypt virtual storage volumes attached to Amazon EC2 instances.
AWS Lambda uses encryption to protect environment variables at rest. AWS KMS can also be used when applications require additional control over how sensitive configuration values are encrypted and decrypted.
Because AWS KMS is integrated directly with these services, applications can use centralized key management without building a separate encryption infrastructure.
Encrypting data is not enough. A secure system must also control who or what can use each encryption key.
AWS KMS integrates closely with AWS Identity and Access Management. You can use IAM policies and KMS key policies to define permissions such as:
Every AWS KMS API request can also be recorded through AWS CloudTrail. This includes operations such as:
These audit logs help with monitoring, security investigations, and compliance requirements.
Suppose you are building a backend API with FastAPI or Spring Boot that processes hundreds of gigabytes of video data.
The AWS KMS Encrypt API only supports a limited amount of plaintext in each
direct request. For large files or datasets, applications commonly use a method
called envelope encryption.
Envelope encryption uses two levels of keys:
The process works as follows.
The backend application sends a request to AWS KMS to generate a data key.
AWS KMS returns two versions of that key:
The ciphertext data key is protected by the KMS key.
The application uses the plaintext data key to encrypt the actual file or data inside the application environment.
This operation can be performed using tools such as:
The large data object does not need to be sent to AWS KMS.
After encryption is complete, the application should immediately remove the plaintext data key from memory.
The plaintext version should never be stored permanently.
The application stores two items together:
For example, both items can be stored in Amazon S3 or in a database.
When the application needs to decrypt the data, it sends the ciphertext data key to AWS KMS. After KMS decrypts the data key, the application temporarily uses the plaintext version to decrypt the file locally.
Key insight: Envelope encryption improves performance and reduces network latency because large datasets do not need to pass through AWS KMS. The application encrypts and decrypts the data locally, while the original KMS key continues to protect the data keys.
AWS KMS and AWS Secrets Manager solve related but different security problems.
AWS KMS manages cryptographic keys used for encryption, decryption, digital signatures, and message authentication.
AWS Secrets Manager stores and manages secret values such as:
Secrets Manager can use AWS KMS to encrypt stored secrets, but AWS KMS itself is not a replacement for a secret-management service.
AWS KMS makes it easier to protect sensitive data without building and operating a complex key management infrastructure.
Whether you are developing microservices, containerized applications, backend APIs, or CI/CD pipelines, AWS KMS provides a centralized and secure foundation for managing cryptographic keys.
Its main strengths include:
By understanding how AWS KMS works and how it differs from AWS Secrets Manager, developers can design cloud systems that protect sensitive information more effectively.