In this article , I want to share a specific use case where you may need to revert a change that broke your application when using AWS SAM. 


  • I am deploying my serverless backend with AWS Sam 
  • I have a front end contact form app that sends request to the backend
  • Someone ( me in this case) changed the lambda function code using the console because of a mistake. I changed a wrong function and therefore the contact form app is broken. 
  • I need to troubleshoot and revert the changes

Now we’ve established the scenario, here are the steps that can be taken to revert to backend to the the state when things last worked. 

How can I find when things were working properly ? Cloudwatch Logs to the rescue. Lambda sends all the function execution logs to cloudwatch.

So I head over to my Lambda function for the contact app backend.

Now the steps to take to debug and revert to a working change:

  1. Find the cloudwatch log that shows successful lambda function execution and note the timestamp.
  2. Go to the S3 bucket where you’re uploading the sam deployment package. ( Sam packages and stores the files in a S3 bucket before deploying the stack)
  3. Use the timestamp you noted to find a file that was uploaded before the working log was written. 
  4. Download that file and extract. 
  5. The files extracted contains the lambda function file. Im my case it’s ( I’m using python runtime for my lambda function)
  6. View the code and compare with the current code. 
  7. Change the current code and package and deploy the sam package.
  8. Things should work now 

This is a very special case which could be specefic to my workflow. And there might be other ways to make sure I don’t ever have to go through this process. But in this instance, I was able to use the listed steps to debug and revert back the changes that broke my contact form application. 

Let me know if you have any questions in the comments below. 


Leave a Reply

Please Login to comment
newest oldest most voted
Notify of

Hi. I have checked your and i see you’ve got some
duplicate content so probably it is the reason that you don’t rank high in google.
But you can fix this issue fast. There is a tool that generates
articles like human, just search in google: miftolo’s tools

Hey there! I know this is kind of off topic but I was wondering
if you knew where I could get a captcha plugin for my comment form?
I’m using the same blog platform as yours and I’m
having problems finding one? Thanks a lot!

Hello, Neat post. There is a problem along with your site in web explorer, could check this… IE still is the market chief and a big component to other people will miss your magnificent writing due to this problem.

It is really a great and helpful piece of information. I am glad that you shared this useful information with us. Please keep us informed like this. Thank you for sharing.