Skip to content

Instantly share code, notes, and snippets.

@thiagoadsix
Last active July 4, 2023 21:50
Show Gist options
  • Save thiagoadsix/8e4adbba005a75dc8fe8d3fa606c1782 to your computer and use it in GitHub Desktop.
Save thiagoadsix/8e4adbba005a75dc8fe8d3fa606c1782 to your computer and use it in GitHub Desktop.
Porque você deveria utilizar LocalStack
@thiagoadsix
Copy link
Author

thiagoadsix commented Jul 4, 2023

LocalStack: Desenvolvimento e Teste de Aplicações Baseadas em Nuvem Localmente

📚 Documentações Importantes

Para acompanhar melhor o vídeo, aqui estão algumas documentações úteis:

LocalStack
AWS CLI
NoSQL Workbench

💻 Comandos e Configurações de Arquivos

Vamos mergulhar em alguns comandos e configurações de arquivos que serão úteis para você.

Docker Compose

Aqui está o Docker Compose do LocalStack. Lembre-se, você pode encontrar mais detalhes sobre como instalá-lo e utilizá-lo na sua máquina na documentação oficial.

version: "3.8"

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
    image: localstack/localstack
    ports:
      - "127.0.0.1:4566:4566"            # LocalStack Gateway
      - "127.0.0.1:4510-4559:4510-4559"  # external services port range
    environment:
      - DEBUG=${DEBUG-}
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

AWS CLI

Este comando é somente o exemplo que utilizamos no video para criar uma tabela com DynamoDB. Para mais informações de como interagir/criar os seus recursos via AWS CLI, você pode consumir essa documentação.

Com index:

aws --endpoint-url=http://localhost:4566 dynamodb create-table \
  --table-name Users \
  --attribute-definitions \
    AttributeName=id,AttributeType=S \
    AttributeName=email,AttributeType=S \
  --key-schema \
    AttributeName=id,KeyType=HASH \
  --provisioned-throughput \
    ReadCapacityUnits=5,WriteCapacityUnits=5 \
  --global-secondary-indexes \
    'IndexName=emailIndex,KeySchema=[{AttributeName=email,KeyType=HASH}],Projection={ProjectionType=ALL},ProvisionedThroughput={ReadCapacityUnits=5,WriteCapacityUnits=5}'

Sem index:

aws --endpoint-url=http://localhost:4566 dynamodb create-table \
  --table-name Users \
  --attribute-definitions \
    AttributeName=id,AttributeType=S \
    AttributeName=email,AttributeType=S \
  --key-schema \
    AttributeName=id,KeyType=HASH \
  --provisioned-throughput \
    ReadCapacityUnits=5,WriteCapacityUnits=5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment