What's the best practice for having different environments for lambda functions, i.e. dev/prod
Should I just have two lambda functions one called myFunction-prod and myFunction-dev or is there a better way to create environments.
I saw that Amazon API Gateway has a notion of "Stages" which accommodates separation of dev, staging and production versions of code.
Is there a similar notion with Amazon Lambda?
You can use AWS Gateway API. Once you created the lamdba functions, create a gateway which points to your lambda function. This can be done easily selecting using a dropdown.
As you mentioned, you can create 2 stages(live and staging) and map the appropriate gateway URLs to the stages. Then by selecting the appropriate method in stages, you can get the REST URL to access the stage.
For example, someurl/live
and someurl/staging
.
Also, while deploying the lamda function changes, choose the appropriate stage to deploy and test it out using the staging URL. Once its done, deploy the function to your live stage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With