Pipeline local para ingestão de arquivos usando LocalStack (S3, DynamoDB, Lambda, API Gateway).
- Upload → S3 Bucket (
ingestor-raw) - Trigger → Lambda (
ingest-file) processa metadados - Storage → DynamoDB (
files) + S3 Bucket (ingestor-processed) - API → API Gateway + Lambda (
files-api) para consulta
# Ubuntu/Debian
sudo apt update
sudo apt install docker.io docker-compose-plugin
# Adicionar usuário ao grupo docker
sudo usermod -aG docker $USER
newgrp docker# Ubuntu/Debian
sudo apt install awscli
# Ou via pip
pip install awscli
# Configurar (use credenciais dummy para LocalStack)
aws configure
# AWS Access Key ID: test
# AWS Secret Access Key: test
# Default region name: us-east-1
# Default output format: json# Ubuntu/Debian
sudo apt install jq
# macOS
brew install jq# Instalar Python 3.8+
sudo apt install python3 python3-pip
# Instalar dependências do projeto
pip install boto3 requestsdocker-compose up -d && ./scripts/test-pipeline.shdocker-compose down -v# Limpar terminal
clear
# Mostrar status inicial
echo "=== INICIANDO PIPELINE ==="
docker-compose ps# Subir serviços
echo "=== SUBINDO LOCALSTACK ==="
docker-compose up -d
# Aguardar inicialização
echo "=== AGUARDANDO INICIALIZAÇÃO ==="
sleep 15
# Executar testes
echo "=== EXECUTANDO PIPELINE ==="
./scripts/test-pipeline.sh
# Verificar logs
echo "=== LOGS DO LAMBDA ==="
aws --endpoint-url=http://localhost:4566 logs describe-log-groupsecho "=== UPLOAD PARA S3 ==="
aws --endpoint-url=http://localhost:4566 s3 cp test-file.txt s3://ingestor-raw/
aws --endpoint-url=http://localhost:4566 s3 ls s3://ingestor-raw/echo "=== LOGS DO PROCESSAMENTO ==="
aws --endpoint-url=http://localhost:4566 logs filter-log-events \
--log-group-name /aws/lambda/ingest-file \
--start-time $(date -d '1 minute ago' +%s)000echo "=== DADOS NO DYNAMODB ==="
aws --endpoint-url=http://localhost:4566 dynamodb scan \
--table-name files \
--output tableecho "=== TESTANDO API ==="
API_URL=$(aws --endpoint-url=http://localhost:4566 apigateway get-rest-apis \
--query 'items[0].id' --output text)
curl -s "http://localhost:4566/restapis/$API_URL/local/_user_request_/files" | jq .- Desenvolvimento local: Evita custos da AWS durante desenvolvimento
- Testes isolados: Ambiente controlado e reproduzível
- Rapidez: Deploy instantâneo vs. minutos na AWS real
- S3: Storage natural para arquivos de entrada e saída
- Lambda: Processamento serverless, escalável automaticamente
- DynamoDB: NoSQL rápido para metadados de arquivos
- API Gateway: Interface REST padronizada
- docker-compose.yml: Orquestração simples dos serviços
- scripts/: Automação de deploy e testes
- lambdas/: Código das funções isolado por responsabilidade
=== AGUARDANDO LOCALSTACK ESTAR PRONTO ===
=== CRIANDO BUCKETS S3 ===
make_bucket: ingestor-raw
make_bucket: ingestor-processed
=== CRIANDO TABELA DYNAMODB ===
An error occurred (ResourceInUseException) when calling the CreateTable operation: Table already exists: files
Tabela files já existe.
=== PREPARANDO ARQUIVO DE TESTE ===
=== UPLOAD PARA S3 ===
upload: ./test-file.txt to s3://ingestor-raw/test-file.txt
=== VERIFICANDO UPLOAD ===
2025-10-22 22:36:26 19 test-file.txt
=== AGUARDANDO PROCESSAMENTO ===
=== CONSULTANDO DYNAMODB ===
-----------------------------------------------
| Scan |
+-------------------+--------+----------------+
| ConsumedCapacity | Count | ScannedCount |
+-------------------+--------+----------------+
| None | 0 | 0 |
+-------------------+--------+----------------+
=== VERIFICANDO BUCKET PROCESSADO ===
=== PIPELINE TESTADO COM SUCESSO ===
Nota: O upload para o S3 foi realizado com sucesso, mas não há itens no DynamoDB nem arquivos processados. Isso indica que a trigger do Lambda ou o processamento do arquivo ainda precisa ser ajustado para completar o fluxo end-to-end.