From f6c1835fc59c31236d22ab31785a061f00bb3cb5 Mon Sep 17 00:00:00 2001 From: Jerad C Date: Thu, 13 Jul 2023 11:16:52 -0500 Subject: [PATCH] fix profile and region arguments (#234) --- cmd/main.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 31a56f6..e2490d0 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -16,7 +16,6 @@ package main import ( "context" "fmt" - "github.com/aws/aws-sdk-go-v2/config" "log" "os" "os/signal" @@ -31,6 +30,8 @@ import ( "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector" "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs" "github.com/aws/amazon-ec2-instance-selector/v2/pkg/sorter" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/config" ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" tea "github.com/charmbracelet/bubbletea" "github.com/spf13/cobra" @@ -247,7 +248,18 @@ Full docs can be found at github.com/aws/amazon-` + binName } ctx := context.Background() - cfg, err := config.LoadDefaultConfig(ctx) + cfg, err := config.LoadDefaultConfig(ctx, + config.WithSharedConfigProfile( + aws.ToString( + cli.StringMe(flags[profile]), + ), + ), + config.WithRegion( + aws.ToString( + cli.StringMe(flags[region]), + ), + ), + ) if err != nil { fmt.Printf("Failed to load default AWS configuration: %s\n", err.Error()) os.Exit(1)