deleteInstance method
Deletes a specified instance, which terminates the associated Amazon EC2 instance. You must stop an instance before you can delete it.
For more information, see Deleting Instances.
Required Permissions: To use this action, an IAM user must have a Manage permissions level for the stack, or an attached policy that explicitly grants permissions. For more information on user permissions, see Managing User Permissions.
May throw ValidationException. May throw ResourceNotFoundException.
Parameter instanceId
:
The instance ID.
Parameter deleteElasticIp
:
Whether to delete the instance Elastic IP address.
Parameter deleteVolumes
:
Whether to delete the instance's Amazon EBS volumes.
Implementation
Future<void> deleteInstance({
required String instanceId,
bool? deleteElasticIp,
bool? deleteVolumes,
}) async {
ArgumentError.checkNotNull(instanceId, 'instanceId');
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'OpsWorks_20130218.DeleteInstance'
};
await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'InstanceId': instanceId,
if (deleteElasticIp != null) 'DeleteElasticIp': deleteElasticIp,
if (deleteVolumes != null) 'DeleteVolumes': deleteVolumes,
},
);
}