Skip to content

Commit

Permalink
Merge pull request #1910 from stakwork/feat/aws_empty_keys
Browse files Browse the repository at this point in the history
PR: Add Conditions For Empty AWS keys in Production
  • Loading branch information
elraphty authored Oct 30, 2024
2 parents c7050d6 + 949da02 commit b92bde7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/s3"
Expand Down Expand Up @@ -64,10 +65,19 @@ func InitConfig() {
// Add to super admins
SuperAdmins = StripSuperAdmins(AdminStrings)

awsConfig, err := config.LoadDefaultConfig(context.TODO(),
config.WithRegion(AwsRegion),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(AwsAccess, AwsSecret, "")),
)
var awsConfig aws.Config
var err error

if AwsAccess == "" && AwsSecret == "" {
awsConfig, err = config.LoadDefaultConfig(context.TODO(),
config.WithRegion(AwsRegion),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(AwsAccess, AwsSecret, "")),
)
} else {
awsConfig, err = config.LoadDefaultConfig(context.TODO(),
config.WithRegion(AwsRegion),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider("", "", "")))
}

if err != nil {
fmt.Println("Could not setup AWS session", err)
Expand Down

0 comments on commit b92bde7

Please sign in to comment.