Select Language:
If you’re managing a large number of AWS Lambda functions and need to update your runtime environment, it can seem overwhelming, but with a clear plan, it becomes manageable. Here’s a step-by-step approach based on recent experience in migrating from Python 3.8/3.9 to Python 3.12, especially when you’re working with many libraries and functions.
First, assess the scope. In our case, we had over 170 internal Python libraries that we package and publish to AWS CodeArtifact. We also had more than 800 Lambda functions relying on those libraries. Our team uses Poetry for managing dependencies, packaging, and publishing, which helps streamline the process.
We explored options for automation and considered AWS Transform but ultimately ruled it out due to internal security policies. Instead, we turned to an AI coding assistant, which was approved internally, and developed a set of custom prompts—our Agent Skills Library. This library contains templates and instructions to keep the migration process consistent and reduce errors.
Our approach is divided into two phases:
Phase 1: Library Migration
In this step, we update each library’s configuration to target Python 3.12. Then, we resolve dependencies, test for compatibility, and publish a new version to CodeArtifact. This ensures the libraries are ready for the new runtime and minimizes issues when updating Lambda functions.
Phase 2: Lambda Function Migration
Once the libraries are updated and available, we proceed to update each Lambda function. We change the runtime version and reference the new library versions. Afterward, we run smoke tests to ensure critical functionality works as expected before redeploying the functions.
Using the Agent Skills Library helps enforce a consistent process across all libraries and functions, making the migration more reliable and reducing manual work.
Now, you might wonder about the best way to execute such a large migration. Should you update all libraries first and then migrate functions? Or should you do it gradually, updating individual libraries and their corresponding functions step by step? Based on our experience, a progressive approach—updating and testing library-by-library alongside functions—provides better control and reduces the risk of widespread issues.
You also might ask if there are AWS-native tools to help here. Tools like CodeGuru can assist with code reviews and performance, while Lambda Powertools can simplify logging and debugging. Upstream proxies in CodeArtifact can help manage dependency resolution more smoothly. Incorporating these tools alongside your AI-based automation can enhance reliability.
When publishing Python 3.12 packages with Poetry, keep in mind some differences from earlier versions. Compatibility with wheel files and metadata formatting may change, so verify that your packaging process aligns with the latest Python standards.
Before you start, seek guidance on the process. Ensure your overall migration strategy aligns with best practices for large-scale updates on AWS, and consider any security policies that might impact automation. Planning a phased, tested rollout—library then function—helps manage risk and ensures a smoother transition.
By following this approach and leveraging both automation and AWS tools, you can make a complex migration more manageable and less prone to errors.





