Skip to main content

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

Project description

wehandle-aws-utils

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

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 ainda não é distribuída em um registry PyPI. Enquanto isso, consuma a versão tagueada diretamente do Git utilizando o uv:

uv add "wehandle-aws-utils @ git+ssh://git@github.com/WeHandle/wehandle-aws-utils.git@v0.1.0"

Substitua v0.1.0 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.0.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.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wehandle_aws_utils-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.0.tar.gz
Algorithm Hash digest
SHA256 67763114490f031c3c0899eced4bb6843101395b5c733a7ec01d249e9588c503
MD5 f16157f72ec6224a56e848183a6ff12f
BLAKE2b-256 5b67ffd5e6d58de9663af6597684a2d445a34ca3f42fade35557f0a196ab94cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wehandle_aws_utils-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 642052145608f029bf728347aceb73cbdaa2ea9b2d7a14dbdac1b5ca912a5536
MD5 8eadd49236339b4fa1e41880133ba0f8
BLAKE2b-256 4f7307817b12c1be65b27a8beda33d9781c93c725e2ee85a5c5b4fc9bb5bb602

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