# Production workflow with CloudFormation

**URL:** <https://forum.serverless.com/t/production-workflow-with-cloudformation/204>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [August 29, 2016, 10:34am UTC](https://forum.serverless.com/t/production-workflow-with-cloudformation/204 "2016-08-29T10:34:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkistner](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rkistner/32/98_2.png) [@rkistner](https://forum.serverless.com/u/rkistner)\
**Post date:** [August 29, 2016, 10:34am UTC](https://forum.serverless.com/t/production-workflow-with-cloudformation/204/1 "2016-08-29T10:34:39Z")

</div>

Is there a way to preview CloudFormation templates before deploying, or to upload it manually?

This is specifically for production workflows. Essentially, I’d like to:

1. Review the CloudFormation configuration changes before deploying, potentially via CloudFormation Change Sets.
2. Restrict access to production deploys, for example to only a specific web user with 2FA enforced.

I see currently (1.0.0-beta2) there is an option `serverless deploy --noDeploy`. This creates a template file in `.serverless/cf-template-update-*.json`. However, this only seems to contain the custom resources from `serverless.yml` file, and not the functions. The S3 zip upload would also likely have to happen via the CLI before being able to deploy the CloudFormation changes.

Is something like this possible with serverless, or is there another recommend workflow for production?

---

<div class="post-metadata">

**Author:** ![rowanu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rowanu/32/75_2.png) [@rowanu](https://forum.serverless.com/u/rowanu)\
**Post date:** [August 29, 2016, 10:36pm UTC](https://forum.serverless.com/t/production-workflow-with-cloudformation/204/2 "2016-08-29T22:36:41Z")

</div>

I like your request to work with CFN Change Sets (and I don’t think it’s possible yet). I’ll have a look to see how much work that will be, as it sounds useful.

Restricting deployment access to a specific user is not going to be something (I think) that the Serverless framework will be able to do for you - it’s more of an AWS setting. As mentioned in the setup docs, the framework currently works best with Administrator-level policy access to your AWS account, so restricting it is not really possible until all the IAM requirements are nailed-down.

In the future (when all requirements are sorted) it will be possible to set up a restricted role to run deployments with, and require that users using that role have 2FA enabled, but not yet.

---

<div class="post-metadata">

**Author:** ![rkistner](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rkistner/32/98_2.png) [@rkistner](https://forum.serverless.com/u/rkistner)\
**Post date:** [August 30, 2016, 7:02am UTC](https://forum.serverless.com/t/production-workflow-with-cloudformation/204/3 "2016-08-30T07:02:50Z")

</div>

I’m happy to configure all of that manually in AWS. My main question is: Can I generate the CloudFormation JSON with serverless to upload manually, instead of deploying directly with serverless?

---

<div class="post-metadata">

**Author:** ![flomotlik](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/flomotlik/32/3_2.png) [@flomotlik](https://forum.serverless.com/u/flomotlik)\
**Post date:** [August 30, 2016, 7:08am UTC](https://forum.serverless.com/t/production-workflow-with-cloudformation/204/4 "2016-08-30T07:08:05Z")

</div>

Yup, `serverless deploy --noDeploy`. Although at the moment the stack needs to be created, but if you just want to update things, running the command will put the compiled cf templates into a .serverless folder in your current directory

---

<div class="post-metadata">

**Author:** ![rkistner](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rkistner/32/98_2.png) [@rkistner](https://forum.serverless.com/u/rkistner)\
**Post date:** [August 30, 2016, 7:30am UTC](https://forum.serverless.com/t/production-workflow-with-cloudformation/204/5 "2016-08-30T07:30:54Z")

</div>

At the moment the generate json file doesn’t seem to include anything defined under functions/events - only custom resources defined in the `resources:` section of `serverless.yml`. Is that correct?

---

<div class="post-metadata">

**Author:** ![flomotlik](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/flomotlik/32/3_2.png) [@flomotlik](https://forum.serverless.com/u/flomotlik)\
**Post date:** [August 30, 2016, 1:34pm UTC](https://forum.serverless.com/t/production-workflow-with-cloudformation/204/6 "2016-08-30T13:34:05Z")

</div>

`serverless deploy --noDeploy` should include everything. 2 files should be created, one stack file that shows the stack that will be used for creation of the whole CF stack and one to update. The update one has all resources in it. If it was never deployed before it might fail, otherwise it should work fine.

---

<div class="post-metadata">

**Author:** ![rkistner](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rkistner/32/98_2.png) [@rkistner](https://forum.serverless.com/u/rkistner)\
**Post date:** [August 30, 2016, 1:49pm UTC](https://forum.serverless.com/t/production-workflow-with-cloudformation/204/7 "2016-08-30T13:49:11Z")

</div>

Ok, seems like that’s a bug in 1.0.0-beta2 that has been fixed since: [https://github.com/serverless/serverless/pull/1881](https://github.com/serverless/serverless/pull/1881)

---

<div class="post-metadata">

**Author:** ![dtabolich](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/dtabolich/32/1171_2.png) [@dtabolich](https://forum.serverless.com/u/dtabolich)\
**Post date:** [September 9, 2016, 1:04pm UTC](https://forum.serverless.com/t/production-workflow-with-cloudformation/204/8 "2016-09-09T13:04:29Z")

</div>

Hi All,  
Regarding the CloudFront template, I don’t have enough permissions to create CF in AWS due to the Company policy restrictions. But, I have existing CF template (created by Admin). Is it possible to associate this existing one with serverless service via configuration?

Thanks.

---

<div class="post-metadata">

**Author:** ![flomotlik](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/flomotlik/32/3_2.png) [@flomotlik](https://forum.serverless.com/u/flomotlik)\
**Post date:** [September 17, 2016, 1:50pm UTC](https://forum.serverless.com/t/production-workflow-with-cloudformation/204/9 "2016-09-17T13:50:08Z")

</div>

@dtabolich its currently not possible to set a fully custom CF stack name, so you will have to get permission to create the CF stack or have an Admin create the CF stack for you.

---

<div class="post-metadata">

**Author:** ![dtabolich](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/dtabolich/32/1171_2.png) [@dtabolich](https://forum.serverless.com/u/dtabolich)\
**Post date:** [September 20, 2016, 1:53pm UTC](https://forum.serverless.com/t/production-workflow-with-cloudformation/204/10 "2016-09-20T13:53:15Z")

</div>

@flomotlik, thanks for comments.  
Actually, I’ve managed this by creating stack in advanced based on the naming convention you use and seems that it is working now!  
There are some incompatible changes from AWS resources perspective like API Gateway stages, but hopefully I’ll be able to solve them behind CF.

Thank you!
