Philipp Muens ac6e04068f Fix hitting CloudFormation TemplateBody limit
The CloudFormation template will now be uploaded to S3 and referenced from there
in the updateStack method.
2016-08-18 12:09:44 +02:00

63 lines
1.9 KiB
JavaScript

'use strict';
const BbPromise = require('bluebird');
const validate = require('../lib/validate');
const createStack = require('./lib/createStack');
const mergeCustomProviderResources = require('./lib/mergeCustomProviderResources');
const uploadCloudFormationTemplate = require('./lib/uploadCloudFormationTemplate');
const uploadDeploymentPackage = require('./lib/uploadDeploymentPackage');
const deployFunctions = require('./lib/deployFunctions');
const updateStack = require('./lib/updateStack');
const SDK = require('../');
class AwsDeploy {
constructor(serverless, options) {
this.serverless = serverless;
this.options = options;
this.provider = 'aws';
this.sdk = new SDK(serverless);
Object.assign(
this,
validate,
createStack,
mergeCustomProviderResources,
uploadCloudFormationTemplate,
uploadDeploymentPackage,
deployFunctions,
updateStack
);
this.hooks = {
'before:deploy:initialize': () => BbPromise.bind(this)
.then(this.validate),
'deploy:setupProviderConfiguration': () => BbPromise.bind(this).then(this.createStack),
'before:deploy:deploy': () => BbPromise.bind(this).then(this.mergeCustomProviderResources),
'deploy:deploy': () => BbPromise.bind(this)
.then(() => this.sdk
.getServerlessDeploymentBucketName(this.options.stage, this.options.region)
.then((bucketName) => {
this.bucketName = bucketName;
})
)
.then(this.uploadCloudFormationTemplate)
.then(this.uploadDeploymentPackage)
.then(this.deployFunctions)
.then(this.updateStack)
.then(() => {
const msg = this.options.noDeploy ?
'Did not deploy due to --noDeploy' :
'Deployment successful!';
this.serverless.cli.log(msg);
}),
};
}
}
module.exports = AwsDeploy;