@@ -37,43 +37,47 @@ func (p *DDBPlugin) DatastoreTypeName() string {
3737
3838func (p * DDBPlugin ) DatastoreConfigParser () fsrepo.ConfigFromMap {
3939 return func (m map [string ]interface {}) (fsrepo.DatastoreConfig , error ) {
40- endpoint , ok := m ["endpoint" ].(string )
41- if ! ok || endpoint == "" {
42- return nil , fmt .Errorf ("ddbds: no endpoint specified" )
43- }
44-
4540 table , ok := m ["table" ].(string )
4641 if ! ok || table == "" {
4742 return nil , fmt .Errorf ("ddbds: no table specified" )
4843 }
4944
45+ accessKey , _ := m ["accessKey" ].(string )
46+ secretKey , _ := m ["secretKey" ].(string )
47+ sessionToken , _ := m ["sessionToken" ].(string )
48+
5049 return & DDBConfig {
51- Endpoint : endpoint ,
52- Table : table ,
50+ Table : table ,
51+ AccessKey : accessKey ,
52+ SecretKey : secretKey ,
53+ SessionToken : sessionToken ,
5354 }, nil
5455 }
5556}
5657
5758type DDBConfig struct {
58- Endpoint string
59- Table string
59+ Table string
60+ AccessKey string
61+ SecretKey string
62+ SessionToken string
6063}
6164
6265func (c * DDBConfig ) DiskSpec () fsrepo.DiskSpec {
6366 return fsrepo.DiskSpec {
64- "endpoint" : c .Endpoint ,
65- "table" : c .Table ,
67+ "table" : c .Table ,
68+ "accessKey" : c .AccessKey ,
69+ "secretKey" : c .SecretKey ,
70+ "sessionToken" : c .SessionToken ,
6671 }
6772}
6873
6974func (c * DDBConfig ) Create (path string ) (repo.Datastore , error ) {
7075 awsConfig := & aws.Config {
71- Endpoint : aws .String (c .Endpoint ), // Connecting to local DynamoDB
72- Region : aws .String ("us-east-1" ), // Dummy region
73- Credentials : credentials .NewStaticCredentials (
74- "dummy" , "dummy" , "" , // No real credentials needed for local
75- ),
76- DisableSSL : aws .Bool (true ),
76+ Region : aws .String ("us-east-1" ),
77+ }
78+
79+ if c .AccessKey != "" && c .SecretKey != "" {
80+ awsConfig .Credentials = credentials .NewStaticCredentials (c .AccessKey , c .SecretKey , c .SessionToken )
7781 }
7882
7983 sess , err := session .NewSession (awsConfig )
0 commit comments