April 2018
Intermediate to advanced
280 pages
8h 37m
English
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 = ...