How to set a region with LoadDefaultConfig and shared profile

0

Hello,

I am starting with Go SDK AWS v2 and I cannot figure out how to select a pre-configured profile and select region programically. I want to do this:

cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithSharedConfigProfile("saml"))

But also this at the same time and I struggle to understand how to combine these two together:

cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-east-1"))

Thanks!

lzap
gefragt vor 2 Jahren1320 Aufrufe
1 Antwort
1
Akzeptierte Antwort

LoadDefaultConfig will accept any number of the LoadOptions (With...) functions as arguments. You should be able to do:

cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithSharedConfigProfile("saml"), config.WithRegion("us-east-1"))

There's an example here: https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/config#example-package-Custom_config.

Ed
beantwortet vor 2 Jahren
  • Ooooh right how could I miss this! Thanks.

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen