Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How-to/Can-we use serverless for modifying existing cloudformation stack? #6694

Open
shubsaini09 opened this issue Sep 16, 2019 · 3 comments

Comments

@shubsaini09
Copy link

shubsaini09 commented Sep 16, 2019

Let's say, I have deployed my lambda and API gateway using cloud formation. Now I want to start using the serverless framework, so how do I point my new serverless template to point to existing cloud formation stack to make changes? Is it possible? If yes then how? Can someone please give a small example or reference docs? I know I can drop the existing resources and recreate them but that is not a good option for me.

If this happens successfully then I am going to use to this in my production so let me know of any worst-case failure scenarios also. Will my template delete everything and recreate or it will just override on my existing stack?

Thanks for helping : )

@shubsaini09
Copy link
Author

shubsaini09 commented Sep 16, 2019

After hours of R&D and work,

Internally, Serverless converts to Cloud-Formation template. That means, if we are able to design a similar template, with all the resources, then we can use Serverless to modify our existing resources and they will be only updated and no recreated again.

I tried simulating in a lower environment and below is what I observed.

There is a way how Serverless creates the template internally and if you have not used a similar approach then you won't be able to use Serverless to modify your resources. Instead, you will end up creating new replicas of each which in turn will throw an error. Because the same name resources are not allowed in most of the places in AWS.

Little deeper - Cloudformation does something like 'difference between old and new script' based on which it decides what to delete and what to add. This is why Serverless will create new because it won't match with existing template names.

However, we can pick-pocket the names from our existing template and a little bit of reverse engineering can be used to do all of this. But this is all expensive in terms of time and efforts. The best way is to delete and recreate if possible. I know it's not very supportive in production environments.

In short, the answer is no. We can't use it easily.

I am keeping it opened for the main people(like @pmuens ) to decide on this.

Thanks

@gligorkot
Copy link

I really need this, and have been able to produce a serverless stack to exactly replicate my CF resources, but I am stuck at a problem as my current stack doesn't have a ServerlessDeploymentBucket which obviously Serverless needs for its deployment.

I'll try and work around it if I can, but haven't found anything at the moment.

@gligorkot
Copy link

Right, working through this got me to these two pages:

This one - which would be ideal - #4840 - but has been closed as something unlikely to happen... But an interesting discussion was there about being able to specify an existing deployment bucket. So I created a new bucket where serverless can upload the newly created CF Template json and this solved that issue.

I then followed the documentation here: https://serverless.com/framework/docs/providers/aws/guide/deploying/, added the custom deploymentBucket config under provider and serverless successfully updated my previously manually uploaded CF Stack.

Success!

Hope this helps you or anyone else who stumbles upon this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants