diff --git a/src/aws.js b/src/aws.js index 640ef2d97..a0d900b14 100644 --- a/src/aws.js +++ b/src/aws.js @@ -29,21 +29,29 @@ function getAWSCredentials(callback) { if (result.statusCode !== 201) return callback(new Error(result.text)); if (!result.body || !result.body.credentials) return callback(new Error('Unexpected response')); - return callback(null, { + var credentials = { accessKeyId: result.body.credentials.AccessKeyId, secretAccessKey: result.body.credentials.SecretAccessKey, sessionToken: result.body.credentials.SessionToken, region: 'us-east-1' - }); + }; + + if (config.aws().endpoint) credentials.endpoint = new AWS.Endpoint(config.aws().endpoint); + + callback(null, credentials); }); } else { if (!config.aws().accessKeyId || !config.aws().secretAccessKey) return callback(new SubdomainError(SubdomainError.MISSING_CREDENTIALS)); - callback(null, { + var credentials = { accessKeyId: config.aws().accessKeyId, secretAccessKey: config.aws().secretAccessKey, region: 'us-east-1' - }); + }; + + if (config.aws().endpoint) credentials.endpoint = new AWS.Endpoint(config.aws().endpoint); + + callback(null, credentials); } } diff --git a/src/config.js b/src/config.js index 046816e1e..c0e2a3d7c 100644 --- a/src/config.js +++ b/src/config.js @@ -99,6 +99,7 @@ function initConfig() { data.token = 'APPSTORE_TOKEN'; data.aws.backupBucket = 'testbucket'; data.aws.backupPrefix = 'testprefix'; + data.aws.endpoint = 'http://localhost:5353'; } else { assert(false, 'Unknown environment. This should not happen!'); }