How to setup AWS local server for development purpose?
Recently, I was working on a project where I need to connect to AWS without actually setting up AWS account.
I didn’t had access to AWS server, I didn’t want to spend time on setting up actual account for development purpose, needed something local and started exploring for options
The best one in market as of now I think is https://github.com/localstack/localstack
But it’s not easy as it looks to setup, Here is a complete guide to get started with setting up AWS local server and configuring S3 (just as an example)
- Download the project
- Setup
- Configure
- Download the project:
Head to https://github.com/localstack/localstack and download zip version of the project and extract to a folder.
You don’t compulsorily need to download the zip, you could fork, clone, etc but that’s your choice.
2. Setup
(You may need to add docker path to Path environment variable
C:\Program Files\Docker\Docker\resources\bin
Open CMD as Admin
cd \Downloads\localstack-master\localstack-master\bin
docker-compose up
Now check these URLS:
http://localhost:4566/ should say {“status”: “running”}
http://localhost:4572/
This will setup you server up and running.
3. Configure and Run
Localstack in your local simulates AWS environment so the ways you use to connect to actual AWS are almost same as local.
I would prefer CLI way and for actual AWS we use “aws” package, for localstack we have similar package called “awslocal”
Refer below for all AWS commands
https://dev.to/mdminhazulhaque/aws-cli-cheatsheet-15f2#---s3
Replace aws with awslocal for localstack
Install awslocal cli:
pip install awscli-local
Create bucket named myDocuments:
awslocal s3api create-bucket --bucket myDocuments --region us-east-1
Create prefix/folder named photos:
awslocal s3api put-object --bucket myDocuments --key photos/
Copy all files from current folder to s3 bucket:
awslocal s3 cp ./ s3://myDocuments/photos/ --recursive
List all files in bucket:
awslocal s3api list-objects --bucket myDocuments --region us-east-1
Delete all files from bucket/folder:
awslocal s3 rm s3://myDocuments/photos/ --recursive