From 0f5cd91ac2a59ee75bc2883a1be38511e7388403 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 21 Sep 2023 12:16:15 -0400 Subject: [PATCH] force setting env creds --- packaging/uniformBuild/uniformBuilder.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packaging/uniformBuild/uniformBuilder.go b/packaging/uniformBuild/uniformBuilder.go index 1114b5ee7f..ffe7ba7e10 100644 --- a/packaging/uniformBuild/uniformBuilder.go +++ b/packaging/uniformBuild/uniformBuilder.go @@ -7,6 +7,8 @@ import ( "flag" "fmt" "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/credentials" + "os" "strings" "time" @@ -34,15 +36,15 @@ var DEFAULT_INSTANCE_GUIDE = map[string]OS{ This function will create EC2 instances as a side effect */ func CreateRemoteBuildManager(instanceGuide map[string]OS, accountID string) *RemoteBuildManager { - cfg, err := config.LoadDefaultConfig(context.TODO()) + // Set up the static credentials provider + creds := credentials.NewStaticCredentialsProvider(os.Getenv("AWS_ACCESS_KEY_ID"), + os.Getenv("AWS_SECRET_ACCESS_KEY"), + os.Getenv("AWS_SESSION_TOKEN")) + + cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithCredentialsProvider(creds)) if err != nil { return nil } - cred, err := cfg.Credentials.Retrieve(context.TODO()) - if cred.SessionToken == "" { - panic("incorrect creds") - return nil - } //instance := *GetInstanceFromID(client, "i-09fc6fdc80cd713a4") rbm := RemoteBuildManager{}