skip to Main Content

With a human error if an AMI associated to an EC2 got deleted and unrecovered. Is it possible to add new AMI to existing EC2 which is running? Does this destroy the existing EC2 and do we have to create new EC2?

2

Answers


  1. Once an EC2 instance is created it doesn’t matter at all if you delete the AMI. The AMI is not "in use" when an EC2 instance is running. The EBS volume(s) that were created when you launched the instance were copied from the AMI, at which point the AMI is no longer involved in the process at all.

    You do not need to "add new AMI to existing EC2" which is impossible anyway.

    Login or Signup to reply.
  2. You can create new AMI for that EC2, make sure you enable no reboot option before create AMI, other wise server will be rebooted.

    You can use AWS CLI like below

    INSTANCE_ID=`/opt/aws/bin/ec2-metadata -i | /usr/bin/awk '{print $2}'`
    /usr/bin/aws ec2 create-image --no-reboot --instance-id $INSTANCEID --name "AMINAME" --description "description"
    

    You can also use AWS console.

    Creating an AMI will not destroy ANY EC2. it is backup for EC2 for DR, if EC2 fails you can launch new EC2 from updated AMI.

    You can also use AWS AMI scheduledr –

    https://aws.amazon.com/premiumsupport/knowledge-center/ec2-systems-manager-ami-automation/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search