Created
May 4, 2020 15:19
-
-
Save naturalett/bb9aa10bde4857b89077926285407795 to your computer and use it in GitHub Desktop.
SecretManager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '''Example code of the SecretManager class''' | |
| class SecretManager(object): | |
| def __init__(self, serviceName, environment, awsRegion="us-east-1", filepath=""): | |
| try: | |
| self.SERVICE_NAME = serviceName.lower() | |
| self.ENVIRONMENT = environment.lower() | |
| self.FILEPATH = filepath | |
| self.ssm = self.initSSM(awsRegion) | |
| self.CREDENTIAL_KEY_PREFIX = "cred" | |
| self.credentialValues = {} | |
| except Exception as err: | |
| raise err | |
| def initSSM(self, awsRegion): | |
| ''' | |
| Initialise AWS connection with given credentials | |
| :param awsRegion: | |
| :return: boto3.client() | |
| ''' | |
| try: | |
| return boto3.client("ssm", region_name=awsRegion) | |
| except: | |
| print("An exception occurred\nFailed to establish aws connection") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment