Note: Please go to to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Guides > RightScale API 1.5 > Examples > End-to-End Examples > 3 Tier E2E API Example > Destroy Deployment

Destroy Deployment

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 Servers

Terminate any servers in the deployment if they are currently running.  You can do this from the Dashboard or using the API. 

Verify Configuration

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 Script

Create the following script, name it Destroy3tier.

#!/bin/sh -e
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$DEPLOYMENT
echo "Done."

Reminder:  Make sure the script is executable before running it.

$ chmod 755 Destroy3tier

Run Script

$ ./Destroy3tier
Reading configuration files. . .
Done (config)
Deleting deployment number 306795001 and all servers. . .

Post Tutorial Steps

  • Note you could also remove other resources, such as the security group (whose ID was also read in from the generic.cfg file)
  • More intelligence could be added to this basic script to make it more practical.  For example, rather than assuming the servers are shutdown, you could look for operational servers in the deployment and terminate and delete them.  That leaves the option of not deleting the deployment itself, just the servers in it, and other cloud resources you do want remove.
You must to post a comment.
Last modified
14:52, 4 Jun 2013



This page has no classifications.



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