Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/createAliasStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ module.exports = {
return this._provider.request(
'CloudFormation',
'createStack',
params,
this._options.stage,
this._options.region
params
).then(cfData => this.monitorStack('create', cfData));

},
Expand Down Expand Up @@ -73,9 +71,7 @@ module.exports = {

return this._provider.request('CloudFormation',
'describeStackResources',
{ StackName: this._aliasStackName },
this._options.stage,
this._options.region)
{ StackName: this._aliasStackName })
.then(() => BbPromise.resolve('alreadyCreated'))
.catch(e => {
if (_.includes(e.message, 'does not exist')) {
Expand Down
12 changes: 3 additions & 9 deletions lib/listAliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@ module.exports = {
{
restApiId: apiId,
stageName: stageName
},
this._options.stage,
this._options.region)
})
.then(stage => {
return this._provider.request('APIGateway',
'getDeployment',
{
restApiId: apiId,
deploymentId: stage.deploymentId
},
this._options.stage,
this._options.region);
});
})
.catch(err => {
if (/^Invalid stage/.test(err.message)) {
Expand All @@ -50,9 +46,7 @@ module.exports = {
{
LogicalResourceId: 'ApiGatewayRestApi',
StackName: stackName
},
this._options.stage,
this._options.region)
})
.then(cfData => cfData.StackResourceDetail.PhysicalResourceId)
.catch(() => BbPromise.resolve(null));
},
Expand Down
12 changes: 3 additions & 9 deletions lib/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ module.exports = {
return this.provider
.request('CloudWatchLogs',
'describeLogStreams',
params,
this.options.stage,
this.options.region)
params)
.then(reply => {
if (!reply || _.isEmpty(reply.logStreams)) {
throw new this.serverless.classes
Expand Down Expand Up @@ -104,9 +102,7 @@ module.exports = {
return this.provider.request(
'CloudWatchLogs',
'describeLogStreams',
params,
this.options.stage,
this.options.region
params
)
.then(reply => {
if (!reply || _.isEmpty(reply.logStreams)) {
Expand Down Expand Up @@ -196,9 +192,7 @@ module.exports = {
return this.provider
.request('CloudWatchLogs',
'filterLogEvents',
params,
this.options.stage,
this.options.region)
params)
.then(results => {
if (results.events) {
_.forEach(results.events, e => {
Expand Down
8 changes: 2 additions & 6 deletions lib/removeAlias.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ module.exports = {

return this._provider.request('CloudFormation',
'updateStack',
params,
this.options.stage,
this.options.region)
params)
.then(cfData => this.monitorStack('update', cfData))
.then(() => BbPromise.resolve([ currentTemplate, aliasStackTemplates, currentAliasStackTemplate ]))
.catch(err => {
Expand All @@ -193,9 +191,7 @@ module.exports = {

return this._provider.request('CloudFormation',
'deleteStack',
{ StackName: stackName },
this._options.stage,
this._options.region)
{ StackName: stackName })
.then(cfData => {
// monitorStack wants a StackId member
cfData.StackId = stackName;
Expand Down
36 changes: 9 additions & 27 deletions lib/stackInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ module.exports = {

return this._provider.request('CloudFormation',
'getTemplate',
params,
this._options.stage,
this._options.region)
params)
.then(cfData => {
try {
return BbPromise.resolve(JSON.parse(cfData.TemplateBody));
Expand All @@ -45,9 +43,7 @@ module.exports = {

return this._provider.request('CloudFormation',
'listImports',
params,
this._options.stage,
this._options.region)
params)
.then(cfData => BbPromise.resolve(cfData.Imports));

},
Expand All @@ -61,9 +57,7 @@ module.exports = {

return this._provider.request('CloudFormation',
'getTemplate',
params,
this._options.stage,
this._options.region)
params)
.then(cfData => {
return BbPromise.resolve(JSON.parse(cfData.TemplateBody));
})
Expand Down Expand Up @@ -98,9 +92,7 @@ module.exports = {

return this._provider.request('CloudFormation',
'describeStackResources',
{ StackName: stackName },
this._options.stage,
this._options.region);
{ StackName: stackName });
},

aliasStacksDescribeResource(resourceId) {
Expand All @@ -112,9 +104,7 @@ module.exports = {
{
StackName: stackName,
LogicalResourceId: resourceId
},
this._options.stage,
this._options.region);
});
},

aliasStacksDescribeAliases() {
Expand All @@ -124,9 +114,7 @@ module.exports = {

return this._provider.request('CloudFormation',
'listImports',
params,
this._options.stage,
this._options.region)
params)
.then(cfData => BbPromise.resolve(cfData.Imports))
.mapSeries(stack => {
const describeParams = {
Expand All @@ -135,9 +123,7 @@ module.exports = {

return this._provider.request('CloudFormation',
'describeStackResources',
describeParams,
this._options.stage,
this._options.region);
describeParams);
});
},

Expand Down Expand Up @@ -188,9 +174,7 @@ module.exports = {
const stackName = `${this._provider.naming.getStackName()}-${aliasName}`;
return this._provider.request('CloudFormation',
'describeStackResources',
{ StackName: stackName },
this._options.stage,
this._options.region);
{ StackName: stackName });
},

aliasGetAliasFunctionVersions(aliasName) {
Expand All @@ -207,9 +191,7 @@ module.exports = {
aliasGetAliasLatestFunctionVersionByFunctionName(aliasName, functionName) {
return this._provider.request('Lambda',
'getAlias',
{ FunctionName: functionName, Name: aliasName },
this._options.stage,
this._options.region)
{ FunctionName: functionName, Name: aliasName })
.then(result => _.get(result, 'FunctionVersion', null));
},

Expand Down
8 changes: 2 additions & 6 deletions lib/updateAliasStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ module.exports = {

return this._provider.request('CloudFormation',
'createStack',
params,
this._options.stage,
this._options.region)
params)
.then((cfData) => this.monitorStack('create', cfData));
},

Expand Down Expand Up @@ -81,9 +79,7 @@ module.exports = {

return this._provider.request('CloudFormation',
'updateStack',
params,
this._options.stage,
this._options.region)
params)
.then((cfData) => this.monitorStack('update', cfData))
.catch((e) => {
if (e.message === NO_UPDATE_MESSAGE) {
Expand Down
9 changes: 3 additions & 6 deletions lib/updateFunctionAlias.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ module.exports = {
return this.provider.request(
'Lambda',
'getFunction',
params,
this.options.stage, this.options.region
params
);
})
.then(result => {
Expand All @@ -37,8 +36,7 @@ module.exports = {
return this.provider.request(
'Lambda',
'publishVersion',
params,
this.options.stage, this.options.region
params
);
})
.then(result => {
Expand All @@ -53,8 +51,7 @@ module.exports = {
return this.provider.request(
'Lambda',
'updateAlias',
params,
this.options.stage, this.options.region
params
);
})
.then(result => {
Expand Down
4 changes: 1 addition & 3 deletions lib/uploadAliasArtifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ module.exports = {

return this.provider.request('S3',
'putObject',
params,
this._options.stage,
this._options.region);
params);
},

uploadAliasArtifacts() {
Expand Down
6 changes: 3 additions & 3 deletions test/createAliasStack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('createAliasStack', () => {
expect(providerRequestStub).to.have.been.calledOnce,
expect(monitorStackStub).to.have.been.calledOnce,
expect(providerRequestStub).to.have.been
.calledWithExactly('CloudFormation', 'createStack', expectedCFData, 'myStage', 'us-east-1'),
.calledWithExactly('CloudFormation', 'createStack', expectedCFData),
expect(monitorStackStub).to.have.been
.calledWithExactly('create', requestResult)
]));
Expand Down Expand Up @@ -117,7 +117,7 @@ describe('createAliasStack', () => {
.then(() => BbPromise.all([
expect(providerRequestStub).to.have.been.calledOnce,
expect(providerRequestStub).to.have.been
.calledWithExactly('CloudFormation', 'createStack', expectedCFData, 'myStage', 'us-east-1'),
.calledWithExactly('CloudFormation', 'createStack', expectedCFData),
]));
});

Expand Down Expand Up @@ -208,7 +208,7 @@ describe('createAliasStack', () => {
expect(providerRequestStub).to.have.been.calledOnce,
expect(createAliasStub).to.not.have.been.called,
expect(providerRequestStub).to.have.been
.calledWithExactly('CloudFormation', 'describeStackResources', expectedCFData, 'myStage', 'us-east-1'),
.calledWithExactly('CloudFormation', 'describeStackResources', expectedCFData),
]));
});

Expand Down
18 changes: 5 additions & 13 deletions test/logs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ describe('logs', () => {
descending: true,
limit: 50,
orderBy: 'LastEventTime',
},
awsAlias.options.stage,
awsAlias.options.region
}
),
expect(logStreamNames).to.have.lengthOf(2),
expect(logStreamNames[0])
Expand Down Expand Up @@ -284,9 +282,7 @@ describe('logs', () => {
descending: true,
limit: 50,
orderBy: 'LastEventTime',
},
awsAlias.options.stage,
awsAlias.options.region
}
),
expect(logStreamNames).to.have.lengthOf(4),
]));
Expand Down Expand Up @@ -355,9 +351,7 @@ describe('logs', () => {
logStreamNames: logStreamNamesMock,
filterPattern: 'error',
startTime: 1475269200000,
},
awsAlias.options.stage,
awsAlias.options.region
}
),
]));
});
Expand Down Expand Up @@ -405,9 +399,7 @@ describe('logs', () => {
logStreamNames: logStreamNamesMock,
startTime: 1287532800000,
filterPattern: 'error',
},
awsAlias.options.stage,
awsAlias.options.region
}
),
]));
});
Expand Down Expand Up @@ -470,7 +462,7 @@ describe('logs', () => {
expect(formatter(testEvent)).to.be.a('string')
.that.contains('This is a test message');
expect(formatter(testEvent)).to.be.a('string')
.that.contains('2017-07-09 00:00:00.000 (+');
.that.contains('2017-07-09 00:00:00.000 (');
});
});
});
Expand Down
Loading