Skip to content

Commit 632660c

Browse files
committed
revert some changes
1 parent b1b0280 commit 632660c

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

book/src/lib/client/aws_secrets_manager.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ Creating a new instance is straight-forward. You should either use environment v
1010
> [!NOTE]
1111
> Environment variables take precedence over shared credentials.
1212
13-
Once you have an instance of AWS Secrets Manager you gain access to following functions:
14-
* `CreateSecret(key string, val string, override bool) error`
15-
* `GetSecret(key string) (AWSSecret, error)`
16-
* `RemoveSecret(key string, noRecovery bool) error`
13+
## Using environment variables
14+
You can pass required configuration as following environment variables:
15+
* `AWS_ACCESS_KEY_ID`
16+
* `AWS_SECRET_ACCESS_KEY`
17+
* `AWS_REGION`
1718

1819
## Using shared credentials
1920
If you have shared credentials stored in `.aws/credentials` file, then the easiest way to configure the client is by setting
@@ -22,11 +23,11 @@ If you have shared credentials stored in `.aws/credentials` file, then the easie
2223
> [!WARNING]
2324
> Remember, that most probably you will need to manually create a new session for that profile before running your application.
2425
26+
2527
> [!NOTE]
2628
> You can read more about configuring the AWS SDK [here](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html).
2729
28-
## Using environment variables
29-
You can pass required configuration as following environment variables:
30-
* `AWS_ACCESS_KEY_ID`
31-
* `AWS_SECRET_ACCESS_KEY`
32-
* `AWS_REGION`
30+
Once you have an instance of AWS Secrets Manager you gain access to following functions:
31+
* `CreateSecret(key string, val string, override bool) error`
32+
* `GetSecret(key string) (AWSSecret, error)`
33+
* `RemoveSecret(key string, noRecovery bool) error`

framework/secretsmanager.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,14 @@ type AWSSecretsManager struct {
6666
// NewAWSSecretsManager create a new connection to AWS Secrets Manager
6767
func NewAWSSecretsManager(requestTimeout time.Duration) (*AWSSecretsManager, error) {
6868
cfg, err := config.LoadDefaultConfig(context.TODO())
69+
region := os.Getenv("AWS_REGION")
70+
if region == "" {
71+
return nil, fmt.Errorf("region is required for AWSSecretsManager, use env variable: export AWS_REGION=...: %w", err)
72+
}
73+
cfg.Region = region
6974
if err != nil {
7075
return nil, fmt.Errorf("unable to load AWS SDK config, %v", err)
7176
}
72-
if cfg.Region == "" {
73-
region := os.Getenv("AWS_REGION")
74-
if region == "" {
75-
return nil, fmt.Errorf("region is required for AWSSecretsManager, use env variable: export AWS_REGION")
76-
}
77-
cfg.Region = region
78-
}
7977
l := log.Logger.With().Str("Component", "AWSSecretsManager").Logger()
8078
l.Info().Msg("Connecting to AWS Secrets Manager")
8179
return &AWSSecretsManager{

0 commit comments

Comments
 (0)