<p>Yes, it can be done.</p>

<p>You can either create an IAM instance role which allows the instance to use ec2 actions such as "create-image" or you can create an IAM user and create for this user access and secret keys and a policy which allows this user to create images in ec2 and then configure the access and secret keys locally on the server using the "aws configure" command.</p>

<p>Whatever method you choose from the above options, the next step would be from within the instance itself and assuming you have aws-cli installed in the instance, first run:</p>

<p><code>ec2-metadata -i</code> to get the instance id.</p>

<p>and then run:</p>

<pre><code>aws ec2 create-image --instance-id INSTANCEID --name NameOfImage --no-reboot --region REGION
</code></pre>

<p>And it will create an image of this instance in the region you provided without rebooting the instance.</p>

<p>The create-image command will create an image of the instance, also called AMI which then you can use to create new instances from.</p>

CC BY-SA 4.0
2019-12-13T00:15:52.167Z
Would I still need access to the linux academy aws account the lab servers are hosts on?
doug
CC BY-SA 4.0
2019-12-13T00:19:52.337Z
Could I create a public AMI if im given the right permitions?
doug
CC BY-SA 4.0
2019-12-12T09:52:31.930Z
2019-12-12T09:52:31.930Z
Itai Ganot
<p>I want to be able to back up my linux accadamy lab servers but they don't provide a way to to this.</p>

<p>I'm wondering if it's posible to clone my EC2 lab server from inside the EC2 to get round this?</p>

CC BY-SA 4.0
2019-12-12T11:35:36.563Z
Please explain why you need this
030
CC BY-SA 4.0
2019-12-13T00:05:08.260Z
In this instance Iv been working through seting up puppet on amozon linux 2 on the lab servers and I want to back up my instance as I previosly messed it up and had to start configering it from scratch.
Im useing the lab servers to save setting up a DNS name on my personal acount for the server and each agent.
doug
<amazon-ec2><linux>
Is there a way to clone an ec2 from inside the ec2 terminal?
doug
# Is there a way to clone an ec2 from inside the ec2 terminal?

(Asked by: username_0 on 2019-12-12)

I want to be able to back up my linux accadamy lab servers but they don't provide a way to to this.

I'm wondering if it's posible to clone my EC2 lab server from inside the EC2 to get round this?

**Tags:** amazon-ec2, linux

> **Comments:**
> **username_1**: Please explain why you need this  
> **username_0**: In this instance Iv been working through seting up puppet on amozon linux 2 on the lab servers and I want to back up my instance as I previosly messed it up and had to start configering it from scratch. Im useing the lab servers to save setting up a DNS name on my personal acount for the server and each agent.  

---

## 1 answers

### Answer by username_2 on 2019-12-12. Score: 2

Yes, it can be done.
You can either create an IAM instance role which allows the instance to use ec2 actions such as "create-image" or you can create an IAM user and create for this user access and secret keys and a policy which allows this user to create images in ec2 and then configure the access and secret keys locally on the server using the "aws configure" command.
Whatever method you choose from the above options, the next step would be from within the instance itself and assuming you have aws-cli installed in the instance, first run:
ec2-metadata -i to get the instance id.
and then run:
aws ec2 create-image --instance-id INSTANCEID --name NameOfImage --no-reboot --region REGION

And it will create an image of this instance in the region you provided without rebooting the instance.
The create-image command will create an image of the instance, also called AMI which then you can use to create new instances from.

> **Comments:**
> **username_0**: Would I still need access to the linux academy aws account the lab servers are hosts on?  
> **username_0**: Could I create a public AMI if im given the right permitions?  

---

