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.2.tar.gz (5.8 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.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wehandle_aws_utils-0.1.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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.2.tar.gz
Algorithm Hash digest
SHA256 d5d419e9ac1b0544b87b8e7eaf0d37abcd8146699a435fdafb05cc6cd89649e9
MD5 ceb1f1eb30f0649e5dd2e9714468c09d
BLAKE2b-256 cb3b1ed299765b5fc9c792d3e3dcd696d797ac6c0b9b6a52bf5e923ebaf47c63

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wehandle_aws_utils-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c261418818dc229bad39d726473bdd1e5e3fcf27740bbf5ef9effb5a78975d87
MD5 2f30814a141e283081ba836d747e9129
BLAKE2b-256 d577dfb110155914a7e34dcd14413d9479df1084dc4c56476f4735e08262eb9d

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