AWS SAM Local vs Localstack

Viewed 6169

I've seen that AWS published recently AWS SAM Local for serverless applications. I find LocalStack to be very similar, I use it for running tests at the moment and can't see lot's of differences as they both support pretty much the same services. Are there any key differences between these two?

3 Answers

SAM Local is basically just for testing your Lambda functions locally.-

No other local services are provided, so for example, if you want to test S3 bucket operations you need to connect to an existing AWS account.

LocalStack lets you mock AWS services, like having a fake S3 bucket

SAM Local lets you run real AWS serverless services locally, like Lambda

So, if you're writing a Lambda and want to test/debug it locally, run it in SAM Local, calling other mocked services on LocalStack

For example, your "real" Lambda calls S3 and Dynamo, then you would mock S3 and Dynamo

If you want to test a Bash script that calls a bunch of different AWS services, then use LocalStack to mock all the services (including say a mock Lambda)

Related