linzhengen / tech-notes

My tech notes write in github issues🧲
1 stars 0 forks source link

[20201104] golang cliでaws MFA二段階認証の実装方法 #24

Open linzhengen opened 4 years ago

linzhengen commented 4 years ago

こんなに簡単に実装できる!!。。。

// 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/