Skip to content

Commit

Permalink
AWS Secrets Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Cosentino committed Jan 3, 2024
1 parent 108e25d commit fae228c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions aws_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@

from core import SingletonMeta
from enums import Env
from tracker.config import ConfigHandler


class AWSUtils(metaclass=SingletonMeta):
"""AWSUtils class"""

def __init__(self):
self.config = ConfigHandler()
def __init__(self, config=None):
self.config = config

@staticmethod
def get_secret(secret_name: str, region_name: str = "eu-central-1") -> str:
Expand All @@ -42,8 +41,12 @@ def get_secret_value(secret_string: str) -> str:
"""Get a secret value from AWS Secrets Manager given the payload's SecretString"""
if not secret_string:
raise ValueError("Empty AWS Secret.")

return secret_string.split('"')[3]
try:
return secret_string.split('"')[3]
except IndexError:
# Attempt to return the secret string as is
# it might be a plain text secret, or from env vars
return secret_string

async def ensure_credentials_file(self, home_dir: str = "/root"):
"""Ensure the AWS credentials are loaded."""
Expand Down
2 changes: 1 addition & 1 deletion release.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

__metaclass__ = type # pylint: disable=invalid-name

__version__ = "v0.1.7"
__version__ = "v0.1.8"
__author__ = "F."

0 comments on commit fae228c

Please sign in to comment.