Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

DynamoDB Basics Python Boto3

Configurando variável de ambiente

Utilizando a porta padrão exposta pelo Localstack.

#Configure Environment Variables
export LOCALSTACK_ENDPOINT_URL="http://localhost:4566"

Configurando AWS CLI

#Configure AWS CLI
aws configure --profile localstack

AWS Access Key ID [None]: test
AWS Secret Access Key [None]: test
Default region name [None]: us-east-1
Default output format [None]:

Criação de um AWS CLI profile chamado localstack com os padrões utilizados para uso local.

Para verificar se a configuração ficou correta podemos executar o seguinte comando abaixo para listar os buckets

#Verify LocalStack configuration
aws --profile localstack --endpoint-url=$LOCALSTACK_ENDPOINT_URL s3 ls

Ambiente virtual e instalação de dependências Python

python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install boto3
python3 -m pip install python-dotenv

Os arquivos utilizam variáveis contidas no arquivo .env

Criação da tabela

python3 utils_dynamodb.py createtable
  • Retorna dados da tabela poc-python-dynamodb (CLI)
awslocal dynamodb describe-table --table-name poc-python-dynamodb

Referencias:

https://hands-on.cloud/testing-python-aws-applications-using-localstack/