Recently I setup Visual Studio Code for local development of AWS Lambda functions. As I mentioned this experience in detail here, all went well and I was able to develop these functions locally and deploy them to AWS.

But a couple days ago, I discovered an annoyance; the CodeLens disappeared whenever I started VS Code and reopened an existing workspace that contained AWS Lambda functions written in Python(or it could be any runtime such as Node.js, .Net Core or Ruby). I couldn’t find anything suspicious in the AWS Toolkit logs either.

By the way by CodeLens, I am referring to a set of clickable actions that show up at the top of, say in our case, a Lambda function:

To test what is going on, I even created a new serverless application by opening the Command Palette (Shift+Command+P on Mac, Ctrl+Shift+P on Windows/Linux) and typing AWS: Create new serverless application, and CodeLens started appearing again even in the existing serverless application in the same workspace in which it was not working, but as soon as I closed VS Code and started it again, CodeLens would disappear again in the same workspace in which I didn’t make a single change.

What it looks like when it doesn’t work

No CodeLens


In order to make it work again, all you have to do is:

  • Open the Command Palette (Shift+Command+P on Mac, Ctrl+Shift+P on Windows/Linux)
  • Type AWS: Create new Serverless Application
  • Press Enter

Don’t go any further and don’t actually create a new serverless app. You will see that the CodeLens starts to appear on your existing Lambda functions. Just go back on your Command Palette now and close it.

I don’t have an explanation for this that why this behaviour happens, but it just does and I figured this workaround after spending hours. May be, AWS Toolkit doesn’t get activated upon Visual Studio Code’s launch but when we invoke some functionality of it, it’s features such as CodeLens fire up. It’s just a theory without any proof.

It’s also possible that I might be the only one facing this issue, but if someone else is too, I hope this helps them.