其他分享
首页 > 其他分享> > localstack 试用

localstack 试用

作者:互联网

以前大概介绍过localstack,以下是关于localstack的试用## 环境准备
python3 以及docker,localstack 基于python 开发,使用docker 运行,镜像不小,推荐先下载

 
docker pull localstack/localstack:latest

安装localstack

 
python3 -m venv venv 
source venv/bin/activate
python3 -m pip install localstack
localstack start 

基于docker&docker-compose 执行运行的效果

 docker run --rm -it -p 4566:4566 -p 4510-4559:4510-4559 localstack/localstack
version: "3.8"
 
services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
    image: localstack/localstack
    network_mode: bridge
    ports:
      - "127.0.0.1:53:53"                # only required for Pro (DNS)
      - "127.0.0.1:53:53/udp"            # only required for Pro (DNS)
      - "127.0.0.1:443:443"              # only required for Pro (LocalStack HTTPS Edge Proxy)
      - "127.0.0.1:4510-4559:4510-4559"  # external service port range
      - "127.0.0.1:4566:4566"            # LocalStack Edge Proxy
    environment:
      - DEBUG=${DEBUG-}
      - DATA_DIR=${DATA_DIR-}
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-}
      - LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY-}  # only required for Pro
      - HOST_TMP_FOLDER=${TMPDIR:-/tmp/}localstack
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - "${TMPDIR:-/tmp}/localstack:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

管理ui

localstack 包含了一个可视化管理ui 应用,需要独立下载

https://localstack.cloud/products/cockpit/

 

 

 

部署服务

pip install awscli
pip install awscli-local
 
aws configure --profile default
// 创建bucket
awslocal s3api create-bucket --bucket dalongdemo
// 查询bucket 信息
awslocal s3api  list-buckets
awslocal s3api put-object --bucket sample-bucket --key index.html --body index.html
// 访问,注意默认localstack 包含了一个自带的ipv6的dns 可以直接解析以下信息
http://sample-bucket.localhost.localstack.cloud:4566/

 

 

 

 

说明

localstack 使用还是比较方便的,对于了解aws 的使用会很方便,而且我们通过云端的应用管理直接可以访问我们本地的服务,参考图
后边我们介绍下实现细节

 

 

参考资料

https://docs.localstack.cloud/get-started/
https://hub.docker.com/r/localstack/localstack/tags

标签:试用,--,bucket,0.1,localstack,docker,4566
来源: https://www.cnblogs.com/rongfengliang/p/16244257.html