1
1

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 1 year has passed since last update.

Localstackを構築してみる

Posted at

目的

クラウドを触るのは学生にとっては少し抵抗があるものである。

昔、AWSを触った時は無料枠の中で遊ぼうと思っていたが、調子に乗って1日で2000円ほど取られてしまった。焦って止めようとしたのだが、どこで課金されているのかよく分からず、格闘した経験がある。

今回は、localstackを構築して無料でAWS互換環境で遊び倒そう。

環境

  • docker
  • docker-compose
  • python (pip)

awscliのインストール

awscli

$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

version確認

$ aws --version
aws-cli/2.11.27 Python/3.11.3 Linux/5.15.0-25-generic exe/x86_64.ubuntu.22 prompt/off

awscli-local

awscliを用いてlocalstackを操作する事も出来るが、エンドポイントの指定をやってくれるawscli-localをインストールしよう。

$ pip3 install awscli-local

version指定

root@shoma:/home/shoma/aws/dist# awslocal --version
aws-cli/2.11.27 Python/3.11.3 Linux/5.15.0-25-generic exe/x86_64.ubuntu.22 prompt/off

localstackの構築

git clone https://github.com/localstack/localstack.git
docker-compose -f ./localstack/docker-compose.yml up

動作検証

aws-cliの設定

$ mkdir ~/.aws/
$ nano ~/.aws/config

configの内容

[default]
region = ap-northeast-1
output = json

クレデンシャルを設定

[default]
aws_access_key_id = dummy
aws_secret_access_key = dummy

aws-cliコマンド実行

# aws s3 ls s3:// --endpoint-url=http://localhost:4566
2023-06-12 03:18:18 test-bucket

awscli-local

いちいちエンドポイントを指定するのも大変なので、今後はawslocalで

# awslocal s3 ls s3://
2023-06-12 03:18:18 test-bucket

localstack管理ツールのインストール

$ pip3 install localstack

確認

# localstack status services
lqqqqqqqqqqqqqqqqqqqqqqqqqqwqqqqqqqqqqqqqk
x Service                  x Status      x
tqqqqqqqqqqqqqqqqqqqqqqqqqqnqqqqqqqqqqqqqu
x acm                      x ? available x
x apigateway               x ? available x
x cloudformation           x ? available x
x cloudwatch               x ? available x
x config                   x ? available x
x dynamodb                 x ? available x
x dynamodbstreams          x ? available x
x ec2                      x ? available x
x es                       x ? available x
x events                   x ? available x
x firehose                 x ? available x
x iam                      x ? available x
x kinesis                  x ? available x
x kms                      x ? available x
x lambda                   x ? available x
x logs                     x ? available x
x opensearch               x ? available x
x redshift                 x ? available x
x resource-groups          x ? available x
x resourcegroupstaggingapi x ? available x
x route53                  x ? available x
x route53resolver          x ? available x
x s3                       x ? running   x
x s3control                x ? available x
x secretsmanager           x ? available x
x ses                      x ? available x
x sns                      x ? available x
x sqs                      x ? available x
x ssm                      x ? available x
x stepfunctions            x ? available x
x sts                      x ? available x
x support                  x ? available x
x swf                      x ? available x
x transcribe               x ? available x
mqqqqqqqqqqqqqqqqqqqqqqqqqqvqqqqqqqqqqqqqj
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?