44 lines
1.5 KiB
Plaintext
44 lines
1.5 KiB
Plaintext
import re, sys
|
|
import datetime
|
|
import base64
|
|
import json
|
|
import com.amazonaws.services.s3.AmazonS3ClientBuilder as AmazonS3ClientBuilder
|
|
import com.amazonaws.auth.profile.ProfileCredentialsProvider as ProfileCredentialsProvider
|
|
import com.amazonaws.auth.AWSStaticCredentialsProvider as AWSStaticCredentialsProvider
|
|
import com.amazonaws.services.secretsmanager.AWSSecretsManagerClientBuilder as AWSSecretsManagerClientBuilder
|
|
import com.amazonaws.services.secretsmanager.model.GetSecretValueRequest as GetSecretValueRequest
|
|
import com.amazonaws.services.secretsmanager.model.AWSSecretsManagerException as AWSSecretsManagerException
|
|
import com.amazonaws.services.securitytoken.AWSSecurityTokenService as AWSSecurityTokenService ;
|
|
import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClientBuilder as AWSSecurityTokenServiceClientBuilder;
|
|
|
|
|
|
|
|
|
|
# Constants
|
|
|
|
class GetCredentials():
|
|
'''
|
|
Gets aws credentials for the provided path and region.
|
|
|
|
'''
|
|
|
|
def __init__(self, path, profile, region):
|
|
self.path = path
|
|
self.profile = profile
|
|
self.region = region
|
|
self.credentials = self._get_credentials()
|
|
# self.client = self._get_s3_client()
|
|
|
|
def _get_credentials(self):
|
|
'''Gets the credentials for the AWS account which the s3 bucket is in.
|
|
|
|
Args:
|
|
|
|
Returns:
|
|
credentials : The aws credentials for a given profile stored on the server.
|
|
'''
|
|
credentials = ProfileCredentialsProvider(self.path, self.profile).getCredentials()
|
|
return credentials
|
|
|
|
|