Site icon Machine Learning Projects

How to create an API in AWS API Gateway using AWS Lambda – 2023

Machine Learning Projects

Hey guys, in today’s blog we will see how to create an API in AWS API Gateway using AWS Lambda. In the last blog, we saw a detailed step-by-step guide on how we can deploy an AWS Lambda using AWS ECR Docker Image.

So without any further due, let’s do it.

Step 1 – You should have a Lambda deployed on AWS Lambda.

Step 2 – Let’s create an API in AWS API Gateway using AWS Lambda.

Step 3 – Deploy the API.

NOTE – Add the following headers in your return request to avoid CORRS error on the front end. Also, you need to click on Enable Corrs in Action dropdown and then click Deploy API again to enable its effect.

return {
        "statusCode": 200, 
        "result": res, 
        'headers': {
            'Content-Type': 'application/json',
            'Access-Control-Allow-Headers': 'Content-Type',
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Methods': 'OPTIONS,POST,GET'
            }
    }

So this is how you create an API in AWS API Gateway using AWS Lambda, thanks for reading it and I hope you are taking something with you after reading this and till the next time…

Check out my other machine learning projectsdeep learning projectscomputer vision projectsNLP projectsFlask projects at machinelearningprojects.net

Exit mobile version