Stop a running EC2 instance. Args: instance_id: The ID of the instance to stop. force: Whether to force stop the instance. wait: Whether to wait for the instance to be stopped. Returns: Updated instance de
(
self,
instance_id: str,
force: bool = False,
wait: bool = True
)
| 212 | |
| 213 | @aws_operation("stop_instance") |
| 214 | def stop_instance( |
| 215 | self, |
| 216 | instance_id: str, |
| 217 | force: bool = False, |
| 218 | wait: bool = True |
| 219 | ) -> Dict[str, Any]: |
| 220 | """ |
| 221 | Stop a running EC2 instance. |
| 222 | |
| 223 | Args: |
| 224 | instance_id: The ID of the instance to stop. |
| 225 | force: Whether to force stop the instance. |
| 226 | wait: Whether to wait for the instance to be stopped. |
| 227 | |
| 228 | Returns: |
| 229 | Updated instance details. |
| 230 | """ |
| 231 | self.client.stop_instances(InstanceIds=[instance_id], Force=force) |
| 232 | |
| 233 | if wait: |
| 234 | self.wait_for('instance_stopped', {'InstanceIds': [instance_id]}) |
| 235 | |
| 236 | return self.get_instance(instance_id) |
| 237 | |
| 238 | @aws_operation("terminate_instance") |
| 239 | def terminate_instance(self, instance_id: str, wait: bool = True) -> Dict[str, Any]: |