It's important to encrypt our data at rest, and the most common way to do this in AWS is to use the AWS Key Management Service (KMS). When we request data that is encrypted with a KMS Key, we need to perform an API request to KMS to decrypt the data using our KMS Key. Here's a screenshot of the costs of these requests within the eu-west-1 region:

Image showing the key usage pricing for AWS KMS in the eu-west-1 region

As you can see, if we encrypt all our data across multiple services where the data is frequently accessed, we could potentially end up with a substantial KMS bill. This is where caching comes to the rescue, and various AWS services handle caching of KMS Keys in different ways. I'll highlight a few of my favourite AWS services below and try to help you understand what to expect when working with them in combination with AWS KMS.

Amazon S3

In 2020 AWS introduced S3 Bucket Keys, which is a way to reduced the requests to the KMS API for objects encrypted by Server Side Encryption with KMS (SSE-KMS). When Bucket Keys are enabled S3 will generate a short lived key for each requestor which is stored locally within S3.

It's worth noting that requests for objects in S3 which existed before enabling the use of Bucket Keys will not use the bucket keys, and may incur additional costs.

You can learn more about S3 Bucket Keys here:

https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-key