Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GetSecret = func(secretKey, region string) (secret string) { sess, err := session.NewSession() if err != nil { log.Println(err.Error()) return } svc := secretsmanager.New(sess, aws.NewConfig().WithRegion(region)) input := &secretsmanager.GetSecretValueInput{ SecretId: aws.String(secretKey), } result, err := svc.GetSecretValue(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case secretsmanager.ErrCodeDecryptionFailure: log.Println(secretsmanager.ErrCodeDecryptionFailure, aerr.Error()) case secretsmanager.ErrCodeInternalServiceError: log.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error()) case secretsmanager.ErrCodeInvalidParameterException: log.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error()) case secretsmanager.ErrCodeInvalidRequestException: log.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error()) case secretsmanager.ErrCodeResourceNotFoundException: log.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error()) } } else { log.Println(err.Error()) } return } var secretString string if result.SecretString != nil { secretString = *result.SecretString } else { decodedBinarySecretBytes := make([]byte, base64.StdEncoding.DecodedLen(len(result.SecretBinary))) _, err := base64.StdEncoding.Decode(decodedBinarySecretBytes, result.SecretBinary) if err != nil { log.Println("Base64 Decode Error:", err) return } } return secretString }
Functions ¶
This section is empty.
Types ¶
type AwsUtilsImpl ¶
type AwsUtilsImpl struct{}
func NewAwsUtils ¶
func NewAwsUtils() *AwsUtilsImpl
func (*AwsUtilsImpl) GetNewSession ¶
type MockAwsUtils ¶
type MockAwsUtils struct {
GetNewSessionfunc func(config config.AWSConfig) (*session.Session, error)
}
func (*MockAwsUtils) GetNewSession ¶
Click to show internal directories.
Click to hide internal directories.