diff --git a/docs/providers/aws/guide/deploying.md b/docs/providers/aws/guide/deploying.md index f6afc4ba8..12adb3742 100644 --- a/docs/providers/aws/guide/deploying.md +++ b/docs/providers/aws/guide/deploying.md @@ -44,16 +44,14 @@ The Serverless Framework translates all syntax in `serverless.yml` to a single A ### Deployment method -Since Serverless Framework v3, deployments are done using [CloudFormation change sets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-changesets.html). It is possible to use [CloudFormation direct deployments](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-direct.html) instead. +Since Serverless Framework v4, deployments are by default done using CloudFormation direct deployments](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-direct.html). This is the recommended approach for most users. -Direct deployments **are faster** and have no downsides (unless you specifically use the generated change sets). They will become the default in Serverless Framework 4. - -You are encouraged to enable direct deployments via the `deploymentMethod` option: +If you want to instead use [CloudFormation change sets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-changesets.html), you can enable it via the `deploymentMethod` option: ``` provider: name: aws - deploymentMethod: direct + deploymentMethod: changesets ``` ### Tips diff --git a/docs/providers/aws/guide/serverless.yml.md b/docs/providers/aws/guide/serverless.yml.md index 5cae58385..74cba8a01 100644 --- a/docs/providers/aws/guide/serverless.yml.md +++ b/docs/providers/aws/guide/serverless.yml.md @@ -120,7 +120,7 @@ provider: # CloudFormation tags to apply to the stack. Optional. stackTags: key: value - # Method used for CloudFormation deployments: 'changesets' or 'direct'. Optional. (default: changesets) + # Method used for CloudFormation deployments: 'changesets' or 'direct'. Optional. (default: direct) # See https://www.serverless.com/framework/docs/providers/aws/guide/deploying#deployment-method deploymentMethod: direct # List of existing Amazon SNS topics in the same region where notifications about stack events are sent. Optional. diff --git a/lib/plugins/aws/deploy/lib/create-stack.js b/lib/plugins/aws/deploy/lib/create-stack.js index d724bc6c3..4dfab3069 100644 --- a/lib/plugins/aws/deploy/lib/create-stack.js +++ b/lib/plugins/aws/deploy/lib/create-stack.js @@ -14,7 +14,10 @@ export default { const stackName = this.provider.naming.getStackName() let monitorCfData - if (this.serverless.service.provider.deploymentMethod === 'direct') { + if ( + !this.serverless.service.provider.deploymentMethod || + this.serverless.service.provider.deploymentMethod === 'direct' + ) { const params = this.getCreateStackParams({ templateBody: this.serverless.service.provider.coreCloudFormationTemplate, diff --git a/lib/plugins/aws/deploy/lib/ensure-valid-bucket-exists.js b/lib/plugins/aws/deploy/lib/ensure-valid-bucket-exists.js index 8170f376d..0615a21a5 100644 --- a/lib/plugins/aws/deploy/lib/ensure-valid-bucket-exists.js +++ b/lib/plugins/aws/deploy/lib/ensure-valid-bucket-exists.js @@ -120,7 +120,10 @@ export default { let monitorCfData - if (this.serverless.service.provider.deploymentMethod === 'direct') { + if ( + !this.serverless.service.provider.deploymentMethod || + this.serverless.service.provider.deploymentMethod === 'direct' + ) { const params = this.getUpdateStackParams({ templateBody }) monitorCfData = await this.provider.request( @@ -129,6 +132,7 @@ export default { params, ) } else { + // Change-set based deployment const createChangeSetParams = this.getCreateChangeSetParams({ changeSetType: 'UPDATE', templateBody, diff --git a/lib/plugins/aws/lib/update-stack.js b/lib/plugins/aws/lib/update-stack.js index 35d23de52..c58ead9f6 100644 --- a/lib/plugins/aws/lib/update-stack.js +++ b/lib/plugins/aws/lib/update-stack.js @@ -19,7 +19,10 @@ export default { const templateUrl = `https://${s3Endpoint}/${this.bucketName}/${this.serverless.service.package.artifactDirectoryName}/${compiledTemplateFileName}` let monitorCfData - if (this.serverless.service.provider.deploymentMethod === 'direct') { + if ( + !this.serverless.service.provider.deploymentMethod || + this.serverless.service.provider.deploymentMethod === 'direct' + ) { const params = this.getCreateStackParams({ templateUrl, }) @@ -30,6 +33,7 @@ export default { params, ) } else { + // Change-set based deployment const changeSetName = this.provider.naming.getStackChangeSetName() const createChangeSetParams = this.getCreateChangeSetParams({ @@ -88,7 +92,10 @@ export default { const stackName = this.provider.naming.getStackName() let monitorCfData - if (this.serverless.service.provider.deploymentMethod === 'direct') { + if ( + !this.serverless.service.provider.deploymentMethod || + this.serverless.service.provider.deploymentMethod === 'direct' + ) { const params = this.getUpdateStackParams({ templateUrl }) try { @@ -104,6 +111,7 @@ export default { throw e } } else { + // Change-set based deployment const changeSetName = this.provider.naming.getStackChangeSetName() const createChangeSetParams = this.getCreateChangeSetParams({ @@ -162,8 +170,7 @@ export default { // as it might reference resources newly added in that change set. // Applied only for ChangeSet deployments which is a default method if ( - (!this.serverless.service.provider.deploymentMethod || - this.serverless.service.provider.deploymentMethod === 'changesets') && + this.serverless.service.provider.deploymentMethod === 'changesets' && this.serverless.service.provider.stackPolicy && Object.keys(this.serverless.service.provider.stackPolicy).length ) {