-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julien Duchesne
committed
Jun 10, 2019
1 parent
21097d9
commit 4c0834a
Showing
5 changed files
with
62 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package credentials | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/secretsmanager" | ||
) | ||
|
||
type AWSSecretsManagerSource struct { | ||
SecretID string `mapstructure:"secret_id"` | ||
} | ||
|
||
func (source *AWSSecretsManagerSource) Credentials() ([]Credentials, error) { | ||
sess := session.Must(session.NewSessionWithOptions(session.Options{ | ||
SharedConfigState: session.SharedConfigEnable, | ||
})) | ||
client := secretsmanager.New(sess) | ||
value, err := client.GetSecretValue(&secretsmanager.GetSecretValueInput{ | ||
SecretId: aws.String(source.SecretID), | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return getCredentialsFromBytes(value.SecretBinary) | ||
} | ||
|
||
func (source *AWSSecretsManagerSource) Type() string { | ||
return "Amazon SecretsManager" | ||
} | ||
|
||
func (source *AWSSecretsManagerSource) ValidateConfiguration() bool { | ||
return len(source.SecretID) > 0 | ||
} |
This file contains 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
This file contains 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