Skip to content

Commit f038803

Browse files
committed
Pass config information through to AWS lambda instance for deployment.
1 parent 5f55570 commit f038803

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

lib/fastboot-api-lambda-deploy-plugin.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ module.exports = DeployPlugin.extend({
1414

1515
_getConfig(context) {
1616
const config = Object.assign({}, context.config['fastboot-api-lambda']);
17+
return config;
18+
},
19+
20+
_getSafeConfig(context) {
21+
const config = this._getConfig(context);
1722
delete config.accessKeyId;
1823
delete config.secretAccessKey;
1924
return config;
@@ -35,7 +40,7 @@ module.exports = DeployPlugin.extend({
3540
},
3641

3742
didBuild: function(context) {
38-
const config = this._getConfig(context);
43+
const config = this._getSafeConfig(context);
3944
const paths = this._getPaths(context);
4045

4146
const addonRootPath = paths.addonRootPath;
@@ -70,13 +75,24 @@ module.exports = DeployPlugin.extend({
7075
},
7176

7277
activate: function(context) {
73-
const config = this._getConfig(context);
7478
const tempPath = this._getPaths(context).tempPath;
79+
const config = this._getConfig(context);
7580

7681
const lambdaFunction = config.lambdaFunction;
77-
const region = config.region || DEFAULT_REGION;
7882

79-
const Lambda = new AWS.Lambda({ region: region });
83+
const lambdaConfig = {
84+
region: config.region || DEFAULT_REGION
85+
};
86+
87+
if (config.accessKeyId) {
88+
lambdaConfig.accessKeyId = config.accessKeyId;
89+
}
90+
91+
if (config.secretAccessKey) {
92+
lambdaConfig.secretAccessKey = config.secretAccessKey;
93+
}
94+
95+
const Lambda = new AWS.Lambda(lambdaConfig);
8096
const UpdateLambdaFunc = RSVP.denodeify(Lambda.updateFunctionCode.bind(Lambda));
8197

8298
return RSVP.resolve()
@@ -88,13 +104,13 @@ module.exports = DeployPlugin.extend({
88104
.then(() => fs.readFile(`${tempPath}.zip`))
89105

90106
.then(fileBuf => {
91-
this.log(`3/3. Uploading zip to ${lambdaFunction} lambda to ${region} region`);
107+
this.log(`3/3. Uploading zip to ${lambdaFunction} lambda to ${lambdaConfig.region} region`);
92108
return UpdateLambdaFunc({
93109
FunctionName: lambdaFunction,
94110
ZipFile: fileBuf
95111
});
96112
})
97113

98-
.then(() => this.log(`API FastBoot lambda production bundle successfully uploaded to "${lambdaFunction}" lambda in region "${region}" 🚀`));
114+
.then(() => this.log(`API FastBoot lambda production bundle successfully uploaded to "${lambdaFunction}" lambda in region "${lambdaConfig.region}" 🚀`));
99115
}
100116
});

0 commit comments

Comments
 (0)