LoginSignup
1
1

More than 1 year has passed since last update.

LocalStack をさわってみた

Last updated at Posted at 2022-11-15

LocalStack をさわってみた

AWS のサービスをさわり始めるにあたって、利用費用を意識せずに実験がしたいなと思っていたところ、LocalStack の 1.0 が正式リリースされていたので、LocalStack を起動して、AWS-CLI を使って LocalStack に S3 バケットを作成するところまでをやってみました。

2022 年 7 月に LocalStack 1.0 が正式リリースされた

LocalStack とは

クラウドアプリケーションを開発するための、ローカルマシン上でクラウドサービスをエミュレートする機能を提供するツールです。

現時点で、AWS の主要サービスに対応しており無料で使える「Community」版でも基本的な API 群は利用することができるとのこと(※)。

※ 無料で使えるものとそうでないものはAWS Service Feature Coverageから確認することができます

起動

何はともあれ起動してみる。

$ docker run --rm -it -p 4566:4566 -p 4510-4559:4510-4559 localstack/localstack

# しばらくすると起動する
・
・
・
Digest: sha256:57c6252b73b29c1eb811b1cccebeb556a3640709bae5a477fbc0e141e4e795b1
Status: Downloaded newer image for localstack/localstack:latest
Waiting for all LocalStack services to be ready
2022-10-15 03:55:21,400 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2022-10-15 03:55:21,402 INFO supervisord started with pid 16
2022-10-15 03:55:22,406 INFO spawned: 'infra' with pid 21
2022-10-15 03:55:23,408 INFO success: infra entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

LocalStack version: 1.2.1.dev
LocalStack build date: 2022-10-19
LocalStack build git hash: 02e6c027

2022-10-15T03:55:23.819  WARN --- [-functhread3] hypercorn.error            : ASGI Framework Lifespan error, continuing without Lifespan support
2022-10-15T03:55:23.819  WARN --- [-functhread3] hypercorn.error            : ASGI Framework Lifespan error, continuing without Lifespan support
2022-10-15T03:55:23.820  INFO --- [-functhread3] hypercorn.error            : Running on https://0.0.0.0:4566 (CTRL + C to quit)

動作確認

AWS-CLI で利用するダミーの設定を作成する。

$ docker run -it --rm amazon/aws-cli configure --profile dummy
AWS Access Key ID [None]: dummy
AWS Secret Access Key [None]: dummy
Default region name [None]: ap-northeast-1
Default output format [None]: None

試しに、LocalStack 内にバケットを作成する。

# Dockerで立ち上げたLocalStackのCONTAINER IDを確認する
$ docker ps
# IPアドレスを確認する
$ docker inspect {CONTAINER ID} | grep IPAddress

$ docker run -it --rm -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli s3 mb s3://sample-bucket --endpoint-url=http://{IP ADDRESS}:4566 --profile dummy

LocalStack 内にバケットが作成されたことを確認する。

$ docker run -it --rm -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli s3 ls --endpoint-url=http://{IP ADDRESS}:4566 --profile dummy

参考

1
1
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
1
1