serverless / components

The Serverless Framework's new infrastructure provisioning technology — Build, compose, & deploy serverless apps in seconds...
https://www.serverless.com
Apache License 2.0
2.31k stars 182 forks source link

How to deprovision/clean up deployed components (Website)? #485

Open SimonKaluza opened 5 years ago

SimonKaluza commented 5 years ago

Is there an easy way to deprovision or destroy all the associated services deployed after calling serverless?

For example, I created a Website via AWS credentials using the "website" serverless component. Usually with the Serverless framework, I was able to destroy all the associated deployments and artifacts by deleting the AWS CloudFormation "Stack". Using Components, I don't think a corresponding template was created in the .serverless directory... Is there another way I can destroy these?

austencollins commented 5 years ago
$ serverless remove

It will remove everything and do so 10x faster than AWS CloudFormation.

SimonKaluza commented 5 years ago

Thanks for the help, that worked very well.

In general the only way to deprovision/clean everything is to ensure the Template.xxx.json artifacts generated by the component are preserved/shared, then ensure we call on the Component's remove function (with the same version) to clean everything it created?

Seems like https://github.com/serverless/components/issues/475 would help with that somewhat, but could be problematic as Serverless Components age/version and add new functionality.

eahefnawy commented 5 years ago

@SimonKaluza yep. We're definitely aware of that. Remote State Storage is a big priority and we'll have a solution for that very soon. Stay tuned!

morgler commented 4 years ago

I don't know if my issue is connected to this issue:

I accidentally deployed the "website" component to the wrong AWS account (wrong credentials in CI stage). I then (unfortunately) first changed the AWS credentials and only AFTER that removed the service. Of course it didn't delete the resources, so I deleted them manually. So far, so good.

The issue is now with the state of the component: it still has the old CloudFront distribution ID stored (verified by sls info --debug) and so tries to update it. But the distribution with this ID does not exist anymore.

I suppose, components cannot prevent the state getting out of sync with actual resources in that case. But how can I delete the state of a component if needed?

eahefnawy commented 4 years ago

@morgler thanks for reporting this. I pushed a fix for it. The real issue here is that cloudfront takes forever to remove, so the component just disables the distro instead of having you wait around for the sake of UX. We could go with the route of waiting until the distro is removed completely, but we're leaving that to CloudFormation.