Below is a simple shell script that assists in creating a custom AMI from an existing EC2 instance using the AWS CLI [1][2]: ```shellscipt #!/bin/bash # AWS Region region="us-east-1" # Replace with your desired region # EC2 Instance ID instance_id="your-instance-id" # Replace with the ID of your EC2 instance # AMI Name and Description ami_name="MyCustomAMI" ami_description="Custom Amazon Machine Image created using a script" # Create the AMI echo "Creating a custom Amazon Machine Image (AMI)..." aws ec2 create-image \ --instance-id $instance_id \ --name "$ami_name" \ --description "$ami_description" \ --block-device-mappings "[{\"DeviceName\":\"/dev/sda1\",\"Ebs\":{\"VolumeType\":\"gp2\"}}]" \ --region $region # Wait for the AMI creation to complete echo "Waiting for the AMI creation to complete..." aws ec2 wait image-available --image-ids $ami_id --region $region echo "Custom AMI created with ID: $ami_id" ``` Before running the script, make sure you have the AWS CLI configured with your AWS access and secret keys using aws configure. Also, replace "your-instance-id" with the actual instance ID and set the ami_name and ami_description as desired. This script creates an AMI from an existing EC2 instance and waits for the AMI creation to complete before displaying the AMI ID. It's a simple example that can be expanded upon based on your specific requirements.