AWS Lambda Extension for Efficient AWS Config Caching

AWS Lambda Extension for Efficient AWS Config Caching

ยท

2 min read

We were reading AWS AppConfig in our lambda functions, which made it a little slow. In this blog post, we'll explore how to overcome this challenge by leveraging AWS Lambda extensions for efficient AWS AppConfig caching.

AWS Lambda extensions offer a solution to this problem. They allow you to deploy executable code within the same Lambda context environment, enabling you to cache data and optimize your function's performance. In the case of AWS AppConfig, Lambda extensions can be a game-changer. They are capable of caching data and, more importantly, automatically checking for updates in the configuration.

We were using the docker container to deploy our lambda function, so to deploy this we just needed to download the executable for app config from AgentS3 and move it to our lambda function code. This is the Dockerfile for invoking the lambda extension.

COPY extensions /opt/extensions
//extensions fs
// extensions
   -  AppConfigAgent

Simply copy the 'extensions' folder to '/opt/extensions', and upon deploying your Lambda function, it will automatically execute the code within the 'extensions' folder and start an instance on your local port 2772.

The config can called by making a GET request on the 2772 port

const config = await axios.get(`http://localhost:2772/applications/${application}/environments/${env}/configurations/${configuration}`);

This made our code significantly faster and reduced cost for us. You can also code your own extension and share it across the team.

Happy Coding

Did you find this article valuable?

Support Dhairya's Blog by becoming a sponsor. Any amount is appreciated!