To delete the deployment and all servers within it, based on information from a configuration file used to originally create the servers in the deployment.
Warning! The example script provided deletes all servers and the deployment itself. Please be sure that is the desired outcome before running the script. This script assumes the deployment you wish to delete is specified in the generic.cfg file.
Table of Contents
This tutorial is designed to clean up the example deployment and servers initially created in the Create 3 Tier Servers End to End tutorial. Note that the curl call is identical to the individual Delete Deployment API example. The only difference is the deployment ID is read in from a configuration file.
Prerequisite: Example assumes you have previously authenticated, and your valid session cookie is in 'mycookie'.
Terminate any servers in the deployment if they are currently running. You can do this from the Dashboard or using the API.
Verify the generic.cfg file contains the correct configuration informaiton. In our example, specify the Cloud ID (2112), Deployment number (306795001) and Security Group seperated by a space.
2112 306795001 DEU7O32167MJ4
Create the following script, name it Destroy3tier.
#!/bin/sh -e # CONFIGURATION echo "Reading configuration files. . . " read CLOUD DEPLOYMENT SG < generic.cfg echo "Done (config)" echo "Deleting deployment number ${DEPLOYMENT} and all servers. . ." curl -i -H X_API_VERSION:1.5 -b mycookie -X DELETE https://my.rightscale.com/api/deployments/$DEPLOYMENT echo "Done."
Reminder: Make sure the script is executable before running it.
$ chmod 755 Destroy3tier
$ ./Destroy3tier Reading configuration files. . . Done (config) Deleting deployment number 306795001 and all servers. . .
© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.