// Enable SDK's Shared Config support.
sess := session.Must(session.NewSessionWithOptions(session.Options{
Profile: "hoge-profile",
AssumeRoleTokenProvider: stscreds.StdinTokenProvider,
SharedConfigState: session.SharedConfigEnable,
}))
// Use the session to create service clients and make API operation calls.
svc := s3.New(sess)
svc.PutObject(...)
こんなに簡単に実装できる!!。。。
参考リンク
https://aws.amazon.com/jp/blogs/developer/assume-aws-iam-roles-with-mfa-using-the-aws-sdk-for-go/