ysde / grafana-backup-tool

A Python-based application to backup Grafana settings by using the Grafana API
MIT License
808 stars 269 forks source link

feat: consolidate s3 logic, use default providers chain #245

Closed DerekTBrown closed 8 months ago

DerekTBrown commented 8 months ago

What does this PR do?

  1. Some of the logic in s3_upload.py was duplicative of the logic in s3_download.py. This PR consolidates this into a shared file, s3_common.py.
  2. Boto3 has the capability to pull credentials from context (i.e. shared credentials files, assume role). This PR changes the behavior of the s3_upload and s3_download utilities to pull credentials from context if a token is not provided. a. The preferred method for authenticating to AWS within EKS is to use role assumption, as this avoids using long-lived credentials (like AWS tokens). This change is needed to facilitate using this approach.

How did I test this?

I am not sure how to test this. Let me know if I need to add tests somewhere.

DerekTBrown commented 8 months ago

@ysde Let me know if this looks okay, or if I need to make any changes!

I also have a few other PRs in mind (adding an auto-formatter, adding some testing using Tilt + Minio). Let me know if you have plans for the repo I can contribute to!

acjohnson commented 8 months ago

Does this preserve the original behavior of the s3 download/upload mechanism?

DerekTBrown commented 8 months ago

@acjohnson The behavior for existing callers should be identical.

acjohnson commented 8 months ago

Thank you @DerekTBrown