@@ -14,6 +14,7 @@ import (
14
14
15
15
"github.com/aws/aws-sdk-go/aws"
16
16
"github.com/aws/aws-sdk-go/aws/awserr"
17
+ "github.com/aws/aws-sdk-go/aws/client"
17
18
"github.com/aws/aws-sdk-go/aws/credentials"
18
19
"github.com/aws/aws-sdk-go/aws/request"
19
20
"github.com/aws/aws-sdk-go/aws/session"
@@ -103,15 +104,17 @@ func init() {
103
104
104
105
// DynamoDBConfig specifies config for a DynamoDB database.
105
106
type DynamoDBConfig struct {
106
- DynamoDB util.URLValue
107
- APILimit float64
107
+ DynamoDB util.URLValue
108
+ APILimit float64
109
+ ApplicationAutoScaling util.URLValue
108
110
}
109
111
110
112
// RegisterFlags adds the flags required to config this to the given FlagSet
111
113
func (cfg * DynamoDBConfig ) RegisterFlags (f * flag.FlagSet ) {
112
114
f .Var (& cfg .DynamoDB , "dynamodb.url" , "DynamoDB endpoint URL with escaped Key and Secret encoded. " +
113
115
"If only region is specified as a host, proper endpoint will be deduced. Use inmemory:///<table-name> to use a mock in-memory implementation." )
114
116
f .Float64Var (& cfg .APILimit , "dynamodb.api-limit" , 2.0 , "DynamoDB table management requests per second limit." )
117
+ f .Var (& cfg .ApplicationAutoScaling , "applicationautoscaling.url" , "ApplicationAutoscaling endpoint URL with escaped Key and Secret encoded." )
115
118
}
116
119
117
120
// AWSStorageConfig specifies config for storing data on AWS.
@@ -806,6 +809,15 @@ func recordDynamoError(tableName string, err error, operation string) {
806
809
807
810
// dynamoClientFromURL creates a new DynamoDB client from a URL.
808
811
func dynamoClientFromURL (awsURL * url.URL ) (dynamodbiface.DynamoDBAPI , error ) {
812
+ dynamoDBSession , err := awsSessionFromURL (awsURL )
813
+ if err != nil {
814
+ return nil , err
815
+ }
816
+ return dynamodb .New (dynamoDBSession ), nil
817
+ }
818
+
819
+ // awsSessionFromURL creates a new aws session from a URL.
820
+ func awsSessionFromURL (awsURL * url.URL ) (client.ConfigProvider , error ) {
809
821
if awsURL == nil {
810
822
return nil , fmt .Errorf ("no URL specified for DynamoDB" )
811
823
}
@@ -817,7 +829,7 @@ func dynamoClientFromURL(awsURL *url.URL) (dynamodbiface.DynamoDBAPI, error) {
817
829
if err != nil {
818
830
return nil , err
819
831
}
820
- return dynamodb . New ( session .New (config ) ), nil
832
+ return session .New (config ), nil
821
833
}
822
834
823
835
// awsConfigFromURL returns AWS config from given URL. It expects escaped AWS Access key ID & Secret Access Key to be
0 commit comments