Skip to main content

Biblioteca para utilitários relacionados a AWS do time de automação

Project description

wehandle-aws-utils

Biblioteca Python para utilitários relacionados a AWS do time wehandle.

Requisitos

  • Python >= 3.11
  • uv (gerenciador de pacotes)

Instalação

Para desenvolvimento:

uv sync --dev

Para uso em produção:

uv pip install .

Uso em outros projetos

A biblioteca é distribuída em um registry PyPI.

uv add "wehandle-aws-utils@v0.1.1"

Substitua v0.1.1 pela tag desejada quando novas versões forem criadas.

Desenvolvimento

Ferramentas

  • pytest: Framework de testes
  • ruff: Linter e formatador de código
  • mypy: Verificação estática de tipos

Executar testes

uv run pytest

Verificar código

uv run ruff check src/
uv run mypy src/

Formatar código

uv run ruff format src/

Funcionalidades Atuais

Utilitários de S3

O módulo wehandle_aws_utils.s3.utils centraliza operações comuns com o Amazon S3 e expõe funções com tolerância a falhas típicas (timeouts, AccessDenied, NoSuchKey):

from wehandle_aws_utils.s3 import utils as s3_utils

local_path = s3_utils.download_file_from_s3("meu-bucket", "dados/arquivo.csv", "/tmp/arquivo.csv")
s3_utils.upload_file_to_s3(local_path, "meu-bucket-processado", "outputs/arquivo.csv")
metadata = s3_utils.get_object_metadata("meu-bucket", "dados/arquivo.csv")

As funções disparam exceções específicas (S3FileNotFoundError, S3AccessDeniedError, S3DownloadError, S3UploadError) para que o chamador possa decidir se deve agendar um retry ou tratar como falha definitiva.

AWS Secrets Manager

O módulo wehandle_aws_utils.secrets_manager.utils encapsula o fluxo recorrente de buscar segredos (como credenciais do Google) e salvá-los no disco com permissões restritas:

from wehandle_aws_utils.secrets_manager import utils as secrets_manager

google_creds = secrets_manager.fetch_secret_json("acesso-google")
secrets_manager.write_secret_to_file("acesso-google", "/tmp/google.json")

Exceções específicas (SecretNotFoundError, SecretAccessDeniedError, SecretDecryptionError, SecretRetrievalError) ajudam o serviço a decidir se deve reprocessar o evento ou falhar definitivamente.

Publicação do Pacote

A action .github/workflows/publish.yml executa lint (ruff), testes (pytest), build e publicação do pacote sempre que um release é publicado ou manualmente.

Fluxo sugerido para lançar uma nova versão interna:

  1. Atualize pyproject.toml / __version__.
  2. Crie um release tagueado (ex.: v0.2.0) pelo GitHub.
  3. A action será executada automaticamente.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wehandle_aws_utils-0.1.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wehandle_aws_utils-0.1.3-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file wehandle_aws_utils-0.1.3.tar.gz.

File metadata

  • Download URL: wehandle_aws_utils-0.1.3.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wehandle_aws_utils-0.1.3.tar.gz
Algorithm Hash digest
SHA256 607e57f677b637b7950c529875d77e77a7f46269c595004bc14c948057104c91
MD5 c2da38068e75cef9d736f7a2a154589d
BLAKE2b-256 11ba811c924ffe0b13e42f7503c0d610fa5c41b89d35951b05c65aced80d345a

See more details on using hashes here.

File details

Details for the file wehandle_aws_utils-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: wehandle_aws_utils-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wehandle_aws_utils-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0a621878e2b48ad606a6dffd49c51f0b8ddd38b2e9910f9fcdce422226856ffd
MD5 51ad87b86c9291955ea12d2baaeb2e6e
BLAKE2b-256 155d99f4812589dc693e73580f7d8a05f341ab1d55b8ef2aabb07324a1157e5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page