From 38f3e06960239607883d5d15a57287bb946b262a Mon Sep 17 00:00:00 2001 From: Camal Cakar <79836315+thundering-herd@users.noreply.github.com> Date: Fri, 28 May 2021 17:31:55 +0200 Subject: [PATCH] feat: add AWS SSO support (#883) * feat: add AWS SSO support To support AWS SSO we need to Bump the AWS SDK which is providing support recently. Also we need to adjust our creation of sessins to include the `SharedConfigState` field. See https://aws.amazon.com/blogs/developer/aws-sso-support-in-the-aws-sdk-for-go/ for more information. * fix: gofmt * Limit parallelism due to aws-sdk-go failing Co-authored-by: Yoriyasu Yano <430092+yorinasub17@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 7 +++++++ modules/aws/auth.go | 9 ++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6bbdd82fd..eb5c30b11 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/Azure/go-autorest/autorest/azure/auth v0.5.1 github.com/Azure/go-autorest/autorest/validation v0.3.0 // indirect github.com/aws/aws-lambda-go v1.13.3 - github.com/aws/aws-sdk-go v1.27.1 + github.com/aws/aws-sdk-go v1.38.28 github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect github.com/docker/cli v0.0.0-20200109221225-a4f60165b7a3 // indirect github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect @@ -38,7 +38,7 @@ require ( github.com/urfave/cli v1.22.2 github.com/zclconf/go-cty v1.2.1 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 - golang.org/x/net v0.0.0-20201021035429-f5854403a974 + golang.org/x/net v0.0.0-20201110031124-69a78807bb2b golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d golang.org/x/tools v0.0.0-20201110201400-7099162a900a // indirect google.golang.org/api v0.15.0 diff --git a/go.sum b/go.sum index 06c34b174..c7288882a 100644 --- a/go.sum +++ b/go.sum @@ -87,6 +87,8 @@ github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQ github.com/aws/aws-sdk-go v1.16.26/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.1 h1:MXnqY6SlWySaZAqNnXThOvjRFdiiOuKtC6i7baFdNdU= github.com/aws/aws-sdk-go v1.27.1/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.38.28 h1:2ZzgEupSluR18ClxUnHwXKyuADheZpMblXRAsHqF0tI= +github.com/aws/aws-sdk-go v1.38.28/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= @@ -275,6 +277,9 @@ github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a h1:zPPuIq2jAWWPTrGt7 github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -501,6 +506,8 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/modules/aws/auth.go b/modules/aws/auth.go index 2a0a0f6c9..f2aa6f78c 100644 --- a/modules/aws/auth.go +++ b/modules/aws/auth.go @@ -30,7 +30,14 @@ func NewAuthenticatedSession(region string) (*session.Session, error) { // NewAuthenticatedSessionFromDefaultCredentials gets an AWS Session, checking that the user has credentials properly configured in their environment. func NewAuthenticatedSessionFromDefaultCredentials(region string) (*session.Session, error) { - sess, err := session.NewSession(aws.NewConfig().WithRegion(region)) + awsConfig := aws.NewConfig().WithRegion(region) + + sessionOptions := session.Options{ + Config: *awsConfig, + SharedConfigState: session.SharedConfigEnable, + } + + sess, err := session.NewSessionWithOptions(sessionOptions) if err != nil { return nil, err }