components icon indicating copy to clipboard operation
components copied to clipboard

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

Open SimonKaluza opened this issue 4 years ago • 5 comments

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?

SimonKaluza avatar Sep 09 '19 21:09 SimonKaluza

$ serverless remove

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

austencollins avatar Sep 09 '19 21:09 austencollins

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.

SimonKaluza avatar Sep 10 '19 15:09 SimonKaluza

@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!

eahefnawy avatar Sep 11 '19 10:09 eahefnawy

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?

morgler avatar Apr 09 '20 23:04 morgler

@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.

eahefnawy avatar Apr 13 '20 12:04 eahefnawy