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.

- 523
- 9
- 10
-
1you can mock S3 by using moto (on your host machine) then set the S3 endpoint URL to your host IP:5000 and it will mock S3 calls... – Neil McGuigan Mar 07 '21 at 21:23
-
@NeilMcGuigan, but that is language-specific, i.e., it works only for Python. – S. Nabil Apr 13 '22 at 18:09
-
1@Inquirer not true. it has a CLI based HTTP server that you can use with any language – Neil McGuigan Apr 13 '22 at 19:45
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)

- 46,580
- 12
- 123
- 152
I believe the only the difference is now being coming from AWS itself, will be it its offerings for latest and greatest in terms of new features/services as launched by AWS's, even though being into BETA it will take some time for SAM local to catch up.
Also Localstack comes in 2 flavors - Base and Pro which is priced. So if given a choice I would start to explore SAM local now.

- 77
- 4