Open5
aws localstack
Get Started
-
https://docs.localstack.cloud/get-started/#starting-localstack-with-docker
docker run --rm -it -p 4566:4566 -p 4510-4559:4510-4559 localstack/localstack
-
exec
docker exec -it {container ID} bash
-
change user localstack
su localstack
-
Install need package
# sudo user apt-get install sudo apt-get install gcc python3-dev
pip install localstack
メモ
localstaclk を実行しようとしたら、dokcer がないとおこられる
- Docker コンテナ内からdocker をインストールすることも推奨されてない
Try
local 環境から処理しべきないようなのか ... 。
結論
認識がちがいやり方が違った
ためした手順
- local で
pip install localstack
を実行 - local コマンドは使えない
- done
root@0f203cd9ed3b:/home# localstack start -d
__ _______ __ __
/ / ____ _________ _/ / ___// /_____ ______/ /__
/ / / __ \/ ___/ __ `/ /\__ \/ __/ __ `/ ___/ //_/
/ /___/ /_/ / /__/ /_/ / /___/ / /_/ /_/ / /__/ ,<
/_____/\____/\___/\__,_/_//____/\__/\__,_/\___/_/|_|
💻 LocalStack CLI 1.2.0
[00:03:35] starting LocalStack in Docker mode 🐳 localstack.py:139
preparing environment bootstrap.py:668
Traceback (most recent call last):
File "/usr/local/bin/localstack", line 23, in <module>
・・・
FileNotFoundError: [Errno 2] No such file or directory: 'docker'
localstack でためす
localstack コンテナにアクセス
docker exec -it localstack_main bash
aws configure に設定登録 >> 設定しなくてもよさげ
$ aws configure
# >>>
AWS Access Key ID [None]: test
AWS Secret Access Key [None]: test
Default region name [None]: ap-northeast-1
Default output format [None]: json
create sqs queue
$ awslocal sqs create-queue --queue-name test-queue
{
"QueueUrl": "http://localhost:4566/000000000000/test-queue"
}
send-message
$ awslocal sqs send-message --queue-url http://localhost:4566/00000000000/test-queue --message-body test
{
"MD5OfMessageBody": "098f6bcd4621d373cade4e832627b4f6",
"MessageId": "9000f162-54b9-4b66-af7f-c69c51db959b"
}
recive-message
$ awslocal sqs receive-message --queue-url http://localhost:4566/00000000000/test-queue
{
"Messages": [
{
"MessageId": "9000f162-54b9-4b66-af7f-c69c51db959b",
"ReceiptHandle": "NjZjMjI4NDUtZjg5NC00ZmMxLTlhNTEtZGIzODQzYzE0ZTIyIGFybjphd3M6c3FzOmFwLW5vcnRoZWFzdC0xOjAwMDAwMDAwMDAwMDp0ZXN0LXF1ZXVlIDkwMDBmMTYyLTU0YjktNGI2Ni1hZjdmLWM2OWM1MWRiOTU5YiAxNjY1Mjg0Mjc1LjYyODk2NzU=",
"MD5OfBody": "098f6bcd4621d373cade4e832627b4f6",
"Body": "test"
}
]
}
curl コマンドでためす
curlコマンド >> local PCから
$ curl --location --request POST 'http://localhost:4566/test-queue' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'Action=SendMessage' \
--data-urlencode 'MessageBody={{payload}}'
localstack コンテナ >> receive 確認
$ awslocal sqs receive-message --queue-url http://localhost:4566/test-queue
{
"Messages": [
{
"MessageId": "16c76c09-6b86-4433-b2a5-5a7c9a6d0cc1",
"ReceiptHandle": "NWE0MWRhMGUtN2Q2OS00OTVhLWI0MzctYTJiOWI4NTkxNDU5IGFybjphd3M6c3FzOmFwLW5vcnRoZWFzdC0xOjAwMDAwMDAwMDAwMDp0ZXN0LXF1ZXVlIDE2Yzc2YzA5LTZiODYtNDQzMy1iMmE1LTVhN2M5YTZkMGNjMSAxNjY1Mjg1NjgxLjIzMDI3ODc=",
"MD5OfBody": "9e1ef8980dab237107f28301d972c98f",
"Body": "{{payload}}"
}
]
}
Request Sample Postman AWS SQS
- 毎回 crul を叩くのが面倒なので、Postman で対応できるか調べた結果がコレ