AWS costs skyrocketed massively after enabling KMS encryption

For context, I am working on a distributed data processing pipeline. I have a step function that has parallel states which invoke lambda functions and glue jobs based on different inputs to the states. Per execution of the step function, I run 13 glue jobs in parallel.

Glue config is as follows -
Workers - 10
Worker type - G4.X
enabled continuous logging

It was fine for the last two months where the average monthly costs was around $1200. Until last week, due to organisation policy, it became mandatory to enable encryption for the glue job as well as the cloudwatch logs.

We created a Security configuration and attached it to the glue job. It has S3 and cloudwatch encryption enabled with type SSE-KMS.

Following that, In just 4 days of July, the costs are already over $3000 per month.

We are running the step function multiple times per day, sometimes having 2 executions concurrently. That would be 2x13 glue jobs running concurrently.
The glue costs are as expected but the KMS costs are significantly higher.
After checking cloudtrail for kms.amazonaws.com service, it shows multiple calls to kms by glue job runner session.

I am assuming this is because of continuous logging enabled? It is writing driver and executor logs constantly and each entry into logs is calling multiple kms actions like decrypt, generateDataKey and so on.

Please help me with this as the forecasted month end costs show $8000+ based on the current run trends.

Tl:dr - Account costs significantly increased after enabling kms encryption for glue jobs and cloudwatch logs with continuous logging enabled.

Hi there,

Sorry for any confusion I hear you’re experiencing! You do have some options provided by AWS that may hep you get this resolved. Firstly, I’d suggest reaching out to our Support team via: http://go.aws/support-center.

Once you create a case, you will be assigned a case ID, and a person will reach out to assist you.

Please be patient, as these issues are handled in an ordered manner.

- Dino C.

You need no investigate further why are the kms costs, but if your job is creating many small files in s3, each file creation or read will call kms to generate data key or decrypt it. If s3 encryption is the culprit you could use bucket keys. Take a look at https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-key.html

Are you using envelope encryption? I think that can reduce your KMS costs by reducing how much data you have to send back and forth. https://support.huaweicloud.com/intl/en-us/dew_faq/dew_01_0054.html

I already have bucket key enabled with SSE-KMS. In cloudtrail, all of the calls are made by glue job runner session. I think it’s because of streaming logs to cloudwatch. Each log entry is calling kms decrypt and a lot of other kms actions

This seems like a promising solution but organisation policy limits me to use CMK only unfortunately

Then your organization’s policy choice comes at a cost of a bit under a thousand dollars a day. Your best move here is to escalate internally and present this information, because you don’t want to be left holding the bag.

Have you looked at the breakdown of costs to see what service is spiking? If it is a spike mostly in KMS it is probably worth looking into your configuration related to S3, such as perhaps your bucket key setup is somehow not entirely correct and the calls are still going between S3 and KMS for some reason.

Yes I looked at the breakdown and checked cloudtrail. The calls are not from S3 but made by Glue Job runner session. Most probably cause of streaming logs to cloudwatch which has a kms key associated with the log group

Just curious, is the cost mostly in Cloudwatch? I know it has been a topic of conversation in the past about putlogs and optimizing costs via things like Kinesis or Elasticsearch/Opensearch. I think the idea is just to straight reduce the logging to Cloudwatch logs and just go straight to S3 more or less.

Have you validated the extra cost is caused by Glue logging into CW? CloudWatch Log Groups are encrypted at rest by default using server side encryption. Is the org policy that you have to have it encrypted or that it must use a CMK? If it’s just that it needs to be encrypted, look into rolling back SSE-KMS and using the default encryption for CW Log Groups. As an aside, you’ll hit higher costs if you’re using a CMK for S3 vs the default bucket SSE-S3 encryption so again if you don’t HAVE to use a CMK, look at the default encryption. But like quinnypig said, if your orgs policy is to use a CMK then they may have to eat that cost or find a creative solution to the situation. If you have ES you can get with your TAM or SA to look into it further.

Glue Encryption

CW Log Protection

Types of CW Log Encryption

S3 KMS

SSE-S3

Thanks a lot! Unfortunately, we have to use CMK for encryption. I did check cloudtrail and most of the calls are made by glue. Since I have Continuous logging enabled, I’m assuming it’s streaming logs into CW. That could be the reason for the large volume of KMS calls. As suggested by others, I will disable continuous logging to check if that makes a difference as it will essentially limit the amount of logs written into CW

Compliance/sec teams even in highly regulatory environments change their policy after CEO /CFO see the bill. Inform everyone about cost of the new policy and ask them review it with CFO /CEO in copy.

This.

You cannot separate policy from the costs of implementing the policy. You escalate up the chain with “this policy will cost us $1k per day. Are you really sure you want us to do this?”

Then you implement the decision that management makes.

Yes I have drafted a cost analysis report which should hopefully make them change this policy. It wasn’t implemented until last week. Hopefully after seeing the new costs, they will not enforce using CMK for encrypting glue logs and jobs

This is the most interesting comment section in the whole sub. I’m mesmerized. What will the answer be?

My money is on the logs, has nothing to do with KMS. That would be marginal increase. I also think you may want to review the glue jobs themselves and confirm that invocations and processing times have not increased. Probably lots of people here would be happy to screenshare while you’re in your billing console and help pinpoint the issue and the change.

Suddenly seeing $1000+ increase due to KMS is usually an implementation bug where it is calling the service way more than necessary, possibly in loop. Do you think the glue job is supposed to be making millions of api calls to the service each month? How many CMKs are you using in your app?

Did you enable S3 Bucket Keys when you enabled SSE-KMS or was it enabled before? Note that any existing objects inside the bucket will not benefit from S3 Bucket Keys (only new objects will). To correct this, you would need to recopy the object into the bucket.

do not initialize the kms object in the handler. initialize it on the global scope.