I am currently working on some IAM policies on AWS and being asked to specify Instance and Image ID. I am not sure what is the difference between the two. From what I understand and instanceID is the one that starts with ami-XXXXXX. Correct me if I am wrong, if that is the case where can I find imageID.
You can achieve this in following ways :-
First make sure you are using the new EC2 Experience ( these are applicable on updated UI)
Now log in to your console.
Go to EC2 instances.
You will see resources, under resources click on instances (all states).
Note :- You have chosen the right region.
Click onleft check box for the instance you want to find details ; in the bottom of the screen under Details you can find instance id starting with i-*** and further scroll it you will get ami id starting with ami-*** also.
The ID of an Amazon EC2 instance looks like: i-xxxx
The ID of an Amazon Machine Image (AMI) looks like: ami-xxxx
When an Amazon EC2 instance is launched, the contents of the AMI is copied to the disks of the new instance.
imageId often starts with "ami-" and you can find it in EC2/Images/AMIs
instanceId is the id of instance, you can find it in list of your instances EC2/Instances/Instances->Instance ID field
Related
I have been doing some research and have not really found an answer to this. What I would like to do is in CloudFormation, have a parameter that a user can specify a number that would correlate to the number of volumes they would like attached to an EC2 instance when it is brought up. Obviously there will always be the root volume but then any number (up to the max allowed) of volumes could be created and mounted to the specified EC2 instance by the user. Is there a way to accomplish this in CloudFormation? Thanks for any help!
I created an EC2 instance on AWS to use as an ECS instance. I followed these steps here to do that.
I also created a new Cluster under ECS but for some reasons, I cannot see the instance under the cluster:
Any ideas on what might be the issue here?
I found the missing piece. It was stated here as part of 10th item on the list that:
By default, your container instance launches into your default cluster. If you want to launch into your own cluster instead of the default, choose the Advanced Details list and paste the following script into the User data field, replacing your_cluster_name with the name of your cluster.
I would strongly suggest letting ECS Cluster create its own EC2 Instance(s), especially if you are new to this. You can define the type of instance that you want when you create the cluster and everything will magically work.
Doing it the other way around (EC2 Instance first, then feeding/attaching it into the Cluster) might sound quite natural to you, but it means that you have to handle a lot of things by yourself. You have to manually spend time on
Making sure you pick the right AMI (ecs-optimized),
Making sure the VPC-Subnets are right,
Making sure the architecture is right (e.g. t4g medium instances don't take x86 containers),
Making sure the Cluster Name is in /etc/ecs/ecs.config and then after that restart docker & ecs-agent.
Making sure ecs-agent is properly set up and connecting,
... and blah blah blah.
Maybe, and hopefully, in future they will add an "attaching this EC2 Instance to that Cluster" button that does all these chores. But until then, save yourself this list of headaches and try to get the instance created by the cluster.
I already had a cluster configured, so the easiest way to do this for me was to go to EC2 Console > Auto scaling groups and select the autoscaling group for the cluster. Make sure to increase the desired capacity and maximum capacity. This should start a new EC2 instance.
I wanted to take a pre-existing t2.medium EC2 instance and essentially clone it. Knowing no exact feature exists within AWS I scoured their documentation, asked people I know and came up with:
Create snapshot of said EC2 instance
Create AMI of snapshot
Build EC2 instance from AMI
When I went to build the new EC2 I was only given the option for a t1.micro OR m3.medium and above. I tried both (in and out of same region as original) and kept getting "insufficient data" under Status Checks.
Any ideas on what is going on here?
It sounds like you selected "paravirtual" as the virtualization type when you created the AMI, when you should have selected "hvm".
If you are doing this from the console you can create an AMI directly from the pre-existing EC2 instance, skipping the manual snapshot step, which should automatically use the correct settings for the AMI.
I have an existing EC2 instance myEC2 up and running.
How do I use the CLI to generate the configuration for this so that I can run a command in my CLI window that will create a new identical EC2 with the name myEC2_B?
Amazon documentation is a disaster as far as I can see. Seems to assume a certain level of knowledge for every topic
I'm not sure about how to do this from the command line interface, but it's certainly possible (and quite easy, I might add):
Jump over to your Instances page.
Find and select the instance that you want to duplicate:
Under the actions menu, click create image
Give the image a name, etc. in the dialog. If you are in a dev environment and can shutdown the server, you should probably tick the no reboot box. Otherwise, leave it unticked. Wait while it's created.
Head over to the AMIs option in the sidebar:
Find your newly-created image and tick it:
Click the big blue launch button at the top of the screen. You'll get to choose an instance size, etc.
Enjoy your duplicated server ;)
You would need to do at least a two step process, but lets look at how we would do it all from the console.
list our instances along with their name and instance id:
aws ec2 describe-instances --filters Name=vpc-id,Values=* --query 'Reservations[].Instances[].[PrivateIpAddress,InstanceId,Tags[?Key==`Name`].Value[]]' --output text | sed '$!N;s/\n/ /'
I get a nice spit out of my instances, IP and instance ID along with the name, take note of the instance we want and its instance-id
Now we are going to write that Instance to a new ami using the create-image ec2 sub command:
aws ec2 create-image --instance-id="MYINSTANCEID"
Now we have the AMI (image-id) we simply launch new ec2 instance with the ami id like so:
aws ec2 run-instances --image-id="ami-d13513b2" --key-name="jjs-skyramp" --security-group-ids="sg-daa5c5bf" --instance-type="t2.small"
Of course if you did this all too quickly you will get the following:
Which is telling us the AMI we created before is still pending, so might want to wait till thats finished, and I assure you the command will copy your Imaged machine :)
You can see the commands I used, what I used represents the bare minimum to launch an image as a new ec2 instance, you can see all the other options at: https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html
Its easy to get your id's for each appropriate paramater by simply running:
"aws ec2 describe-THING-I-WANT-TO-SEE
then play some with filters for the json data.
Hope this helps.
Is there a way to find out Amazon EC2 AMI creation date/time from AWS Console or command line?
Note: I am not looking for instance creation, rather when was a particular AMI created?
Querying the creation date of an AMI has been a requested feature since 2006.
Back when I was creating community AMIs in 2007-2009 I started a trend of including the creation date in the AMI name/description (e.g., 20121210). This practice has been picked up by a number of popular AMI series, so you may want to check out the name and description of the AMI for a date looking string.
From AWS's 'What's New' :
AMI Creation Date is now available on the AWS Management Console. You can find this attribute by going to the EC2 console and choosing AMIs on the left navigation menu. You should see a new column on the AMIs page called "Creation Date"
You can also see this 'CreationDate' attribute with AWS EC2 CLI using:
ec2 describe-images --image-ids ami-a3e0thy0
Two alternatives:
1) You can view info about the associated snapshot from the EC2 snapshot panel, specifically the "Started" field which will tell you the time the snapshot started. I think this is very close, and worked well for AMIs my coworkers and I created - not so well for private AMIs. Simply find the snapshot ID (snapshot-1234abcd) in the AMI view in the "Block devices" field, then look up that snapshot in the Snapshots view.
2) If you are in a region which offers AWS CloudTrail, you can probably find that info in the CloudTrail logs.
This is not currently possible. The ability to better track versions of AMIs is a often requested feature though. Expect AWS to be releasing some enhancements in this area relatively soon.
If you want to use the CLI, but only want the image ID and the creation date, you can run this:
aws ec2 describe-images --image-ids ami-XXXXXXXX --query 'Images[*].[ImageId,CreationDate]'