MCPcopy Create free account
hub / github.com/agenticsorg/edge-agents / resize_instance

Method resize_instance

scripts/agents/devops/src/aws/ec2.py:276–311  ·  view source on GitHub ↗

Change the instance type (resize) of an EC2 instance. Args: instance_id: The ID of the instance to resize. instance_type: The new instance type. wait: Whether to wait for the modification to complete. Returns:

(
        self, 
        instance_id: str, 
        instance_type: str, 
        wait: bool = True
    )

Source from the content-addressed store, hash-verified

274
275 @aws_operation("resize_instance")
276 def resize_instance(
277 self,
278 instance_id: str,
279 instance_type: str,
280 wait: bool = True
281 ) -> Dict[str, Any]:
282 """
283 Change the instance type (resize) of an EC2 instance.
284
285 Args:
286 instance_id: The ID of the instance to resize.
287 instance_type: The new instance type.
288 wait: Whether to wait for the modification to complete.
289
290 Returns:
291 Updated instance details.
292 """
293 # Check if the instance is running
294 instance = self.get_instance(instance_id)
295 was_running = instance['State']['Name'] == 'running'
296
297 # Stop the instance if it's running
298 if was_running:
299 self.stop_instance(instance_id, wait=True)
300
301 # Change the instance type
302 self.client.modify_instance_attribute(
303 InstanceId=instance_id,
304 InstanceType={'Value': instance_type}
305 )
306
307 # Restart the instance if it was previously running
308 if was_running:
309 self.start_instance(instance_id, wait=wait)
310
311 return self.get_instance(instance_id)
312
313 #
314 # Security Group Management

Callers

nothing calls this directly

Calls 3

get_instanceMethod · 0.95
stop_instanceMethod · 0.95
start_instanceMethod · 0.95

Tested by

no test coverage detected