I’m new to serverless and would like to understand the following,.
Is there a way to extract all the cloudformation code into a stand-alone template file that I can then put into S3 and use CloudFormation to manage my deployments myself?
In order words, right now we’re building apps with serverless (i.e. lambda, web api, S3 static angular web UI, dynamoDb, etc) and we deploy them via serverless deploy cli through a custom CodeBuild job we have. However, we want more control and really want to:
Have serverless CLI create a CloudFormation.template file.
We will then update this file to S3.
From there, we will then create the required CodePipeline that watches the S3 butcket for CloudFormation.template updates and
this will then trigger a deployment of the CloudFormation template.
serverless package cli looks interesting but that (as far as I can tell) doesn’t create a stand alone valid cloudformation template. Thanks for your patience.
The entire sls deploy process is based off CloudFormation and creates a new CloudFormation stack for each service you build by uploading a CF template and your Lambda function artifacts to an S3 bucket and then running threm through the CloudFormation service. This is deliberate because the aim of Serverless is to help you build serverless microservices very easily without having to worry about the deployment process. The resources section of the serverless.yml is also all just vanilla CloudFormation and you can use whatever CF you want to extend the capabilities of your service.
As far as deploying on a tool like CodeBuild, if you can run a shell command you can deploy with Serverless and I would encourage you to try and make use of the benefits the serverless deployment provides you as it can take away a lot of the hassles of deploying serverless architectures; its really its core strength. Serverless can also keep your CF stacks in sync; if you make a change it will only alter the part that has changed.
In and of itself what you are saying makes perfect sense.
But allow me to share a recent experience: I have been developing lambdas with serverless for awhile now, and some of these are being deployed identically across multiple accounts and regions. The organization I’m working for has now decided that these will be managed via CF StackSets.
So, there’s no way to use any serverless command. The best I can do is somehow prebuild everything with serverless including the CF template and hand that off. I’m going to hack together a solution, but some variant of serverless package that solves my problem would be sweet!