I have an aws_session_token in my ~/.aws/credentials file
. I read it like this using the aws-sdk for Go version 2:
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-west-2"), config.WithSharedConfigProfile("devadm"))
...
retrieve, err := cfg.Credentials.Retrieve(context.TODO())
...
token := retrieve.SessionToken
How do I set this token in a client for dynamodb, s3, or kms? There is nothing in the docs about this for version 2 of the aws-sdk for Go.
You don't ever need to touch the session token (which by the way may change with time in some circumstances).
All you have to do is create your dynamo, etc client with the config you created.
// Using the Config value, create the DynamoDB client
svc := dynamodb.NewFromConfig(cfg)