2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

1. LocalStackによるインフラ構築に向けて

Last updated at Posted at 2020-03-31

Quick introduction to localstack using localstack-demo

What is LocalStack ?

LocalStack provides an easy-to-use test/mocking framework for developing Cloud applications. It spins up a testing environment on your local machine that provides the same functionality and APIs as the real AWS cloud environment.

Setting up components

conda create -n localstack python=3.5
conda activate localstack
mkdir external-master
cd external-master && git clone https://github.com/good-idea/localstack-demo.git
git clone https://github.com/localstack/localstack.git
pip install awscli

Configuring

$aws configure --profile localstack
AWS Access Key ID [None]: dummy
AWS Secret Access Key [None]: dummy
Default region name [None]: us-east-1
Default output format [None]: json
$ tree .aws
.aws
├── config
└── credentials

0 directories, 2 files
$ cd .aws
$ ls
config		credentials
$ vim credentials
$ vim config

Launching localstack container

$ cd external-master/localstack-demo 
$ TMPDIR=/private$TMPDIR \
> DATA_DIR=/tmp/localstack/data \
> SERVICES=apigateway,kinesis,dynamodb,dynamodbstreams,elasticsearch,s3,\
> lambda,sns,sqs,redshift,es,ses,route53,cloudformation,cloudwatch,\
> ssm,secretsmanager,stepfunctions,logs,sts,iam,ec2 \
> docker-compose up -d
Creating network "localstack-demo_default" with the default driver
Creating localstack_demo ... done

Creating S3-bucket

Execute bellow commands after launching localstack.

aws --endpoint-url=http://localhost:4572 s3 mb s3://demo-bucket
aws --endpoint-url=http://localhost:4572 s3api put-bucket-acl --bucket demo-bucket --acl public-read

Finally, access to http://localhost:8055 and assumed result is bellow.

スクリーンショット 2020-03-31 午前11.49.09.png

How to reproduce(Fastest)

Using pre-setup docker container, we can reproduce environment easily.

docker pull yoshinobusekiyu4docker/nova-dev-env:localstack
TMPDIR=/private$TMPDIR DATA_DIR=/tmp/localstack/data SERVICES=apigateway,kinesis,dynamodb,dynamodbstreams,elasticsearch,s3,lambda,sns,sqs,redshift,es,ses,route53,cloudformation,cloudwatch,ssm,secretsmanager,stepfunctions,logs,sts,iam,ec2 
docker run -it -p '4563-4599:4563-4599' -p 8055:8080 yoshinobusekiyu4docker/nova-dev-env:localstack /bin/bash -c "localstack start"
aws --endpoint-url=http://localhost:4572 s3 mb s3://demo-bucket
aws --endpoint-url=http://localhost:4572 s3api put-bucket-acl --bucket demo-bucket --acl public-read

References

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?