LocalStack lets you run AWS local stack to develop and test cloud apps offline. The community edition of this service is free with some core AWS Cloud APIs included. In the other plans, there are some advanced services included but you will like the community edition. With AWS Local Stack, you can host S3, EC2, Elastic Search, and many more AWS components. Here you can run these services locally and connect to them from AWS CLI and do what you like. For instance, if you want t use S3 then you can create new buckets, upload files, download files, and do much more.
If you often work with AWS services then you know the process of setting them up. You need AWS account and most importantly, internet. But with LocalStack, you won’t have to do that. You just fire up the local AWS cloud on your PC and create cloud apps and test them all offline. Right now, it works perfectly on MAC and Linux. On Windows, it breaks but I think that will be fixed in next updates. The community edition of LocalStack is very good and then you can easily run in it on your terminal or do whatever you like.
How to Create AWS Local Stack to Develop and Test Cloud Apps Offline?
AWS Local Stack can be deployed on any machine running Linux or MAC. This is open source and you can install it via Docker for simplicity or you can go with the manual approach if you like that. There is a single command to open install it and launch it, In my case, I have installed it on Linux based in Ubuntu and I used Docker for the installation. Before starting with it, see the services included in the free community edition.
- API Gateway at port 4567
- Kinesis at port 4568
- DynamoDB at port 4569
- DynamoDB Streams at port 4570
- Elasticsearch at port 4571
- S3 at port 4572
- Firehose at port 4573
- Lambda at port 4574
- SNS at port 4575
- SQS at port 4576
- Redshift at port 4577
- ES (Elasticsearch Service) at port 4578
- SES at port 4579
- Route53 at port 4580
- CloudFormation at port 4581
- CloudWatch at port 4582
- SSM at port 4583
- SecretsManager at port 4584
- StepFunctions at port 4585
- CloudWatch Logs at port 4586
- EventBridge (CloudWatch Events) at port 4587
- STS at port 4592
- IAM at port 4593
- EC2 at port 4597
The best way to run it on your terminal is through Docker. Make sure that you have Docker-Compose installed and then you just clone this GitHub repository. Just cd in to the LocalStack directory and run the following command and wait for it to launch the service at the specified ports. Here if you are advanced user then you can tweak the YAML file a bit if you want to.
docker-compose up
To see if the LocalStack is working fine, you can test it by going to the specific local URL. The URL I have shown in the screenshot for the S3 storage service. After pointing to the URL, you will get response in XML format. With the help of AWS CLI, you can create new buckets here and then upload files.
To create a bucket and upload a file, you can use the following syntax of AWS CLI. If you know AWS then you may be aware of these commands. If you don’t know other AWS commands then you can simply turn the AWS docs and see how it works.
To create a new bucket: aws --endpoint-url=http://localhost:4572 s3 mb s3://BucketName
To upload a file: aws s3 cp FiletoUpload s3://BucketName/TargetFileName --endpoint-url=http://localhost:4572
In the screenshots above, you can see the S3 endpoint is working perfectly. But this was just to demonstrate the functionality of the local instance of S3. Other AWS services are also running there and you can access them in the similar way. There are some really useful commands of AWS CLI that you can learn and use them. Also, you can learn some advanced aspects of LocalStack on its GitHub page.
Closign thoughts
LocalStack is really a very amazing tool that AWS lovers can try. I really liked the free community version of LocalStack which comes with a lot of core AWS Cloud APIs. The installation and usage of this is very nice as well and in just a few minutes, you can get up and running the AWS Offline cloud on your computer or terminal. This is a great tool for testers as well so if you are one of those people looking for ways to use AWS Cloud offline then this is a very helpful post.