From 6ad8f9da7a2bf09c261dcca390bee4c16b138317 Mon Sep 17 00:00:00 2001 From: Fawad Khaliq Date: Wed, 12 Aug 2020 13:43:17 -0700 Subject: [PATCH] Revert "Add STS endpoint resolver to override the default (#339)" (#340) This reverts commit 0d41ad4344a4781369a705bd2f3593d1a13779a5. --- go.sum | 2 ++ pkg/aws/cloud.go | 27 +-------------------------- pkg/aws/cloud_config.go | 4 ---- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/go.sum b/go.sum index 0b4a900e..735b0237 100644 --- a/go.sum +++ b/go.sum @@ -58,6 +58,8 @@ github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:l github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 h1:zV3ejI06GQ59hwDQAvmK1qxOQGB3WuVTRoY0okPTAv0= github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= +github.com/aws/aws-sdk-go v1.32.4 h1:J2OMvipVB5dPIn+VH7L5rOqM4WoTsBxOqv+I06sjYOM= +github.com/aws/aws-sdk-go v1.32.4/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.33.5 h1:p2fr1ryvNTU6avUWLI+/H7FGv0TBIjzVM5WDgXBBv4U= github.com/aws/aws-sdk-go v1.33.5/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= diff --git a/pkg/aws/cloud.go b/pkg/aws/cloud.go index 0087b07a..6399c9ca 100644 --- a/pkg/aws/cloud.go +++ b/pkg/aws/cloud.go @@ -23,9 +23,6 @@ type Cloud interface { // Region for the kubernetes cluster Region() string - - // AWS STS Endpoint override for the controller - STSEndpoint() string } // NewCloud constructs new Cloud implementation. @@ -53,25 +50,7 @@ func NewCloud(cfg CloudConfig, metricsRegisterer prometheus.Registerer) (Cloud, cfg.Region = region } - var awsCfg *aws.Config - if len(cfg.STSEndpoint) == 0 { - awsCfg = aws.NewConfig().WithRegion(cfg.Region).WithSTSRegionalEndpoint(endpoints.RegionalSTSEndpoint) - } else { - - stsEndpointOverride := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) { - if service == endpoints.StsServiceID { - return endpoints.ResolvedEndpoint{ - URL: cfg.STSEndpoint, - SigningRegion: cfg.Region, - }, nil - } - - return endpoints.DefaultResolver().EndpointFor(service, region, optFns...) - } - - awsCfg = aws.NewConfig().WithEndpointResolver(endpoints.ResolverFunc(stsEndpointOverride)).WithRegion(cfg.Region) - } - + awsCfg := aws.NewConfig().WithRegion(cfg.Region).WithSTSRegionalEndpoint(endpoints.RegionalSTSEndpoint) sess = sess.Copy(awsCfg) if len(cfg.AccountID) == 0 { sts := services.NewSTS(sess) @@ -112,7 +91,3 @@ func (c *defaultCloud) AccountID() string { func (c *defaultCloud) Region() string { return c.cfg.Region } - -func (c *defaultCloud) STSEndpoint() string { - return c.cfg.STSEndpoint -} diff --git a/pkg/aws/cloud_config.go b/pkg/aws/cloud_config.go index ee3a8a85..55e47aed 100644 --- a/pkg/aws/cloud_config.go +++ b/pkg/aws/cloud_config.go @@ -9,7 +9,6 @@ const ( flagAWSRegion = "aws-region" flagAWSAccountID = "aws-account-id" flagAWSAPIThrottle = "aws-api-throttle" - flagAWSSTSEndpoint = "aws-sts-endpoint" ) type CloudConfig struct { @@ -17,8 +16,6 @@ type CloudConfig struct { Region string // AccountID for the kubernetes cluster AccountID string - // AWS STS Endpoint override for the controller - STSEndpoint string // Throttle settings for aws APIs ThrottleConfig *throttle.ServiceOperationsThrottleConfig } @@ -26,6 +23,5 @@ type CloudConfig struct { func (cfg *CloudConfig) BindFlags(fs *pflag.FlagSet) { fs.StringVar(&cfg.Region, flagAWSRegion, "", "AWS Region for the kubernetes cluster") fs.StringVar(&cfg.AccountID, flagAWSAccountID, "", "AWS AccountID for the kubernetes cluster") - fs.StringVar(&cfg.STSEndpoint, flagAWSSTSEndpoint, "", "AWS STS endpoint override for the controller") fs.Var(cfg.ThrottleConfig, flagAWSAPIThrottle, "throttle settings for AWS APIs, format: serviceID1:operationRegex1=rate:burst,serviceID2:operationRegex2=rate:burst") }