Skip to content

Commit 6d6c38a

Browse files
committed
Remove the os.Getenv(AWS_DEFAULT_REGION) and rely on the default EnvConfig behaviour for resolveRegion
1 parent affae46 commit 6d6c38a

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

s3secrets-helper/s3/s3.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,28 @@ func New(log *log.Logger, bucket string) (*Client, error) {
2424
ctx := context.Background()
2525

2626
// Using the current region (or a guess) find where the bucket lives
27+
28+
/*
29+
There are three region resolvers:
30+
- resolveRegion
31+
- resolveEC2IMDSRegion
32+
- resolveDefaultRegion
33+
34+
There are also three config providers:
35+
- LoadOptions (programatic provided below)
36+
- EnvConfig (reads environment variables)
37+
- SharedConfig (reads ~/.aws files)
38+
39+
The resolvers are run sequentially until a region is found, not all
40+
config providers support each resolver. The absolute order is:
41+
42+
- resolveRegion LoadOptions => config.WithRegion() if given
43+
- resolveRegion EnvConfig => first of AWS_REGION, AWS_DEFAULT_REGION
44+
- resolveRegion SharedConfig => default profile on disk
45+
- resolveEC2IMDSRegion LoadOptions => config.WithEC2IMDSRegion() if given
46+
- resolveDefaultRegion LoadOptions => config.WithDefaultRegion() if given
47+
*/
2748
config, err := config.LoadDefaultConfig(ctx,
28-
config.WithRegion(os.Getenv("AWS_DEFAULT_REGION")),
2949
config.WithEC2IMDSRegion(),
3050
config.WithDefaultRegion("us-east-1"),
3151
)

0 commit comments

Comments
 (0)