Skip to Content
Hybrid Cloud for Developers
book

Hybrid Cloud for Developers

by Manoj Hirway
April 2018
Intermediate to advanced content levelIntermediate to advanced
280 pages
8h 37m
English
Packt Publishing
Content preview from Hybrid Cloud for Developers

Terminating the EC2 instance

Since the EC2 instance is billed by AWS based on the type and usage, it is wise to terminate instances when their purpose is finished. The instances can easily be terminated by creating an object of the TerminateInstancesRequest class and adding the instance ID to it. The termination request object is then passed to the TerminateInstances() function which invokes the termination of the specified instances.

Append the following code snippet to your program to terminate the instance that you just launched:

var terminate_request = new TerminateInstancesRequest();terminate_request.InstanceIds.Add(instances[0].InstanceId);var terminate_response = ec2.TerminateInstances(terminate_request);var terminating_instance = ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hybrid Cloud for Architects

Hybrid Cloud for Architects

Alok Shrivastwa
OpenStack: Building a Cloud Environment

OpenStack: Building a Cloud Environment

Alok Shrivastwa, Sunil Sarat, Kevin Jackson, Cody Bunch, Egle Sigler, Tony Campbell

Publisher Resources

ISBN: 9781788830874Supplemental Content