@@ -15,6 +15,7 @@ package config
1515
1616import  (
1717	"errors" 
18+ 	"net/url" 
1819
1920	flag "github.com/spf13/pflag" 
2021	"go.uber.org/zap/zapcore" 
@@ -29,6 +30,7 @@ const (
2930	flagEnableDevLogging      =  "enable-development-logging" 
3031	flagAWSAccountID          =  "aws-account-id" 
3132	flagAWSRegion             =  "aws-region" 
33+ 	flagAWSEndpointURL        =  "aws-endpoint-url" 
3234	flagLogLevel              =  "log-level" 
3335	flagResourceTags          =  "resource-tags" 
3436)
@@ -41,6 +43,7 @@ type Config struct {
4143	EnableDevelopmentLogging  bool 
4244	AccountID                 string 
4345	Region                    string 
46+ 	EndpointURL               string 
4447	LogLevel                  string 
4548	ResourceTags              []string 
4649}
@@ -79,6 +82,13 @@ func (cfg *Config) BindFlags() {
7982		"" ,
8083		"The AWS Region in which the service controller will create its resources" ,
8184	)
85+ 	flag .StringVar (
86+ 		& cfg .EndpointURL , flagAWSEndpointURL ,
87+ 		"" ,
88+ 		"The AWS endpoint URL the service controller will use to create its resources. This is an optional"  + 
89+ 			" flag that can be used to override the default behaviour of aws-sdk-go that constructs endpoint URLs"  + 
90+ 			" automatically based on service and region" ,
91+ 	)
8292	flag .StringVar (
8393		& cfg .LogLevel , flagLogLevel ,
8494		"info" ,
@@ -117,5 +127,13 @@ func (cfg *Config) Validate() error {
117127	if  cfg .Region  ==  ""  {
118128		return  errors .New ("unable to start service controller as AWS region is nil. Please pass --aws-region flag" )
119129	}
130+ 
131+ 	if  cfg .EndpointURL  !=  ""  {
132+ 		endpoint , err  :=  url .Parse (cfg .EndpointURL )
133+ 		if  err  !=  nil  ||  endpoint .Scheme  !=  "https"  &&  endpoint .Host  !=  ""  {
134+ 			return  errors .New ("invalid service endpoint. Please refer to "  + 
135+ 				"https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html for more details" )
136+ 		}
137+ 	}
120138	return  nil 
121139}
0 commit comments