blog

Execute AWS Lambda locally in Pycharm and Deploy to AWS

Posted on June 2, 2025 by Govind Kumar


Well, as a software developer we generally prefer to use the tool of our own choice while coding. The priority varies from developer to developer. Some directly starts with the terminal while others do with the IDEs. The Development is required everywhere and the earnestness of Serverless technology can’t be ignored where also development plays a crucial role. One among them is AWS Lambda, It’s fun automating the stuff using Lambda but it becomes challenging when we need to do it online via the AWS console. In order to get rid of that muddle, let’s frame-up the environment where we get the same feel without compromising our interest, i.e. Coding from our favourite IDEs on the local computer.

This recipe will provide a modus operandi to set up and manage the configurations of PyCharm in a local development environment, and how you can go ahead and deploy your first Python serverless function directly to AWS Lambda. Believe me, it's fun!!

I am using macOS Catalina. The setup is going to remain indistinguishable in almost all the macOS. However, the instructions to do the same in all other OS is also mentioned.

Here are the steps to setup PyCharm locally:

1. In order to achieve our target, there are certain application pre-requisites.

  1. Ensure that Python is installed in your system. If not, click here to download the Python version of your choice. (Preferably Python 3.X)
  2. Check if everything is in order using the below command from the terminal.
python --version# Python 3.7.3.

2. Install the AWS Serverless Application Model (SAM) command-line interface using brew. (Windows Users can try this).

Before Installing Brew there are few prerequisites. To complete that click here

After the successful installation of Brew checks the version.

Note: Brew (It is not required in Windows or Linux OS)

brew --version

The output should look like this:

Homebrew 2.1.6Homebrew/homebrew-core (git revision ef21; last commit 2019-06-19)

Let’s install SAM CLI now.

brew tap aws/tapbrew install aws-sam-cli

To upgrade the AWS SAM CLI, you still use Homebrew, but replace install with upgrade as follows:

brew upgrade aws-sam-cli

3. In order to run the Lambda function locally, we will be needing a docker container. Let us install docker .

brew cask install dockeropen /Applications/Docker.app

Windows and Linux based user can follow this link to get docker installed in their system.

As soon as docker has been launched, check if it is running:

docker ps

4. Once done with the above steps, let’s install the IDE of our choice. Here in this case Pycharm. (You can make use of another tool like Visual Studios as well).

Follow this link to install Pycharm. You may install the package as per the requirement. Here we are installing the community edition.

5. Let us start the installation of a toolkit and set up the project structure.

Steps: Navigate to Pycharm preferences > Plugins > Marketplace > Search Plugin in marketplace > Search for AWS Toolkit and Install it.

Note: The way to install a plugin in windows and Linux may be different. You may click here to get it done in your system.

  • Once done, restart Pycharm to get the plugin into action.

6. Setup the Project in Pycharm.

Let’s set up your project in PyCharm. Create a new project from File > Create new project and choose AWS Serverless Application as project type. Be sure to select the correct setting (you can choose a “Hello World” template from SAM Template).

The project setup will be done automatically, and a function called lambda_handler, which returns a basic ,Hello World“ example, will be created in app.py.

7. The directory structure will be like this:

Note that, there are two files of major concern in our case right now. i). app.py ii). template.yaml

Click on app.py file and write some sample lambda function. You may simply copy paste this as well or take the default created.

import jsondef lambda_handler(event, context):return {"statusCode": 200,"body": json.dumps({"message": "hello world",}),}

8. Now ensure that you have your Correct AWS credentials configured in your system.

To install AWS CLI in Mac — Click here Windows — Click here Linux — Click here

Once, installed, configure using the credentials, generated using IAM Service. To configure AWS CLI click here.

9. Configure Pycharm to connect to your AWS account. Click on AWS Connection and Select the credentials along with the region.

Selecting AWS credentials

10. Once done, Select the JSON Input to trigger the lambda function. You may select Hello World Template or can write your own input file.

Selecting the Input Json for Lambda Function

11. Test the function locally now!! Simply go to your function and click on Run.

Run Lambda Locally

Now it will take a while, as it will download the Docker Container for the first time. Once done, something like this will appear!

Output after execution

12. You’ll need to create an AWS CloudFormation stack and Amazon S3 Bucket (if needed) in order to proceed with the deployment.

In order to deploy your function to AWS Lambda, you can right-click on your project folder in the sidebar, and choose Deploy Serverless Application:

The deployment will go live in a short while!

Give some name for the Cloudformation Stack and Select the S3 Bucket.
Now, you’ve successfully set up PyCharm with AWS toolkit to test your functions locally, subsequently deploy it live to AWS Lambda (via AWS CloudFormation).

Note: Feel free to reach us via a comment in case of any issue, we will solve it together.

Conclusion

PyCharm is a Python IDE that works great with AWS Lambda. You can run, build and deploy your lambda code locally in PyCharm. You can rely on it for intelligent code checks, easy project navigation, and much more.

Share post on

Subscribe to Our Blogs

Subscribe to our blogs and be the first to know about innovations in the field of cloud storage

Related Posts

Running NBFC Workload on AWS   
Digital Transformation ChallengesDigital transformation in Financial Services is impossible without modernizing your core system. Amazon Web Services (AWS) is built to handle the complexity, rigor, and regulatory requirements unique to the Financial Services industry. By running your core system on AWS, you can access the agility and speed you need at any time, break down the siloes that hold your data hostage, and drive innovation at the enterprise level – all while reducing IT costs. Integrate your most valuable data with the cloud to automate manual processes, improve customer experiences, and launch new market-facing applications more quickly. AXESS.IO, an AWS Advanced partner has deep industry expertise, solutions that align to AWS best practices, and AWS-certified staff.AWS as the Trusted Choice for FSI IndustryWhat is AWS?Amazon Web Services (AWS) is a cloud platform that provides a secure and resilient cloud infrastructure that financial services can use to innovate, build and safely handle, process and analyze sensitive financial information.AWS is Highly AvailableGlobally, AWS has 76 availability zones with three availability zones in India.Also, AWS delivers the highest network availability with 7 times fewer downtime hours than the next largest cloud provider.AWS is Easily ScalableWith AWS, companies don’t have to provision resources to handle peak levels of activity. They, in turn, can just scale up or down based on their business needs and also pay only for what they use.AWS is Highly SecureThe AWS infrastructure is built to satisfy the security requirements for global banks and other high-sensitivity organizations and is monitored 24/7 to ensure confidentiality, integrity and availability of your data.AWS Security Hub comprises of solutions like Amazon Macie, Amazon Inspector and Amazon GaurdDuty that not only protect your infrastructure and data but also perform compliance monitoring.Effective and Efficient InfrastructureThe AWS cloud infrastructure is equipped to cater to the increasing mark of customer satisfaction, contain, process and analyze massive amounts of financial data without technical glitches while being highly secure and easily adaptable.Managing Compliance on AWSHaving said that, though operating on the cloud has immense opportunities in terms of business growth while being able to process and analyze hundreds of terabytes of financial data in very little time, it has its own list of setbacks. Migrating into a cloud infrastructure that doesn’t address these setbacks could turn the whole finance sector into a disaster.In addition, NBFCs are highly regulated. RBI has published guidelines in regards to the outsourcing of IT Infrastructure. These requirements are very stringent and have been designed to ensure business continuity in the event of a disaster or geopolitical problem.But the good news is that AWS with its local legal entity named Amazon Internet Services Private Limited (AISPL), meets all the compliance requirement from the RBI. We have published a couple of whitepapers in this regard:Whitepaper - Running NBFC Workload on AWSPlease do not hesitate to reach us at ciso@axcess.io to discuss how we can help you with your cloud journey.

Ready to discuss your cloud project?
Have questions?

Get In Touch

Only a competent AWS Consulting Partner will understand your unique needs and goals. The smart, enterprise-ready cloud solutions from Axcess.io can make life easier for your organization.



© 2025 All rights reserved

Terms of Service|Privacy Policies