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

Method create_ami

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

Create an AMI from an EC2 instance. Args: instance_id: The ID of the instance to create the AMI from. name: Name for the AMI. description: Description for the AMI. no_reboot: If True, do not reboot the instance before creating

(
        self,
        instance_id: str,
        name: str,
        description: Optional[str] = None,
        no_reboot: bool = False,
        tags: Optional[Dict[str, str]] = None,
        wait: bool = True
    )

Source from the content-addressed store, hash-verified

595
596 @aws_operation("create_ami")
597 def create_ami(
598 self,
599 instance_id: str,
600 name: str,
601 description: Optional[str] = None,
602 no_reboot: bool = False,
603 tags: Optional[Dict[str, str]] = None,
604 wait: bool = True
605 ) -> Dict[str, Any]:
606 """
607 Create an AMI from an EC2 instance.
608
609 Args:
610 instance_id: The ID of the instance to create the AMI from.
611 name: Name for the AMI.
612 description: Description for the AMI.
613 no_reboot: If True, do not reboot the instance before creating the AMI.
614 tags: Dictionary of tags to apply.
615 wait: Whether to wait for the AMI to be available.
616
617 Returns:
618 Details of the created AMI.
619 """
620 create_args = {
621 'InstanceId': instance_id,
622 'Name': name,
623 'NoReboot': no_reboot
624 }
625
626 if description:
627 create_args['Description'] = description
628
629 # Prepare tags
630 all_tags = self.DEFAULT_TAGS.copy()
631 all_tags['Name'] = name
632 if tags:
633 all_tags.update(tags)
634
635 tag_specs = [{
636 'ResourceType': 'image',
637 'Tags': [{'Key': k, 'Value': v} for k, v in all_tags.items()]
638 }]
639
640 create_args['TagSpecifications'] = tag_specs
641
642 # Create the AMI
643 response = self.client.create_image(**create_args)
644 image_id = response['ImageId']
645
646 # Wait for the AMI to be available if requested
647 if wait:
648 self.wait_for('image_available', {'ImageIds': [image_id]})
649
650 return self.get_ami(image_id)
651
652 @aws_operation("deregister_ami")
653 def deregister_ami(self, image_id: str, delete_snapshots: bool = False) -> None:

Callers

nothing calls this directly

Calls 2

get_amiMethod · 0.95
wait_forMethod · 0.80

Tested by

no test coverage detected