How to find the same spec AMI in different regions? - amazon-web-services

as title, while I create CFN template, I always check EC2 console for AMI id in different regions.
these ids belong to the same spec image,
ex: all of them are "ubuntu 12.04 64 bit", but in various regions
is there any quick method to check this messages?
thanks a lot!

No, there is no method for identifying matching AMIs across different regions.
Some background...
An Amazon Machine Image (AMI) contains a disk image that is used to boot an Amazon EC2 instance. It is created by using the Create Image command on an existing Amazon EC2 instance, and can also be created from an EBS Snapshot (Linux only).
Each AMI receives a unique ID in the form ami-1234abcd.
AMIs exist in only one AWS region. When an AMI is copied between regions, it receives a new AMI ID. This means that the "same" image will appear with a different AMI ID in each region.
When an AMI is copied between regions, it will retain its name and description, but this is not necessarily unique, so it cannot be used to definitively match AMIs between regions.
AMI creators will often supply a list of matching AMI IDs across regions, for example: Amazon Linux AMI IDs

Related

How can I get list of instances along with attached volumes and their respective type and size?

I am working on the AWS CLI for the first time and need help.
I want the query to get list of ec2 instances along with attached volumes and their respective type and size using AWS CLI.
Can you please help?
You would use describe-instances to obtain a list of all Amazon EC2 instances in your account in a particular Region.
You can use describe-volumes to obtain a list of Amazon EBS Volumes. There is an Attachments field that lists which EC2 instances are connected to each volume, and also fields for Size and VolumeType.
Given that you would need to join the Instance and Volume information together, it might be easier to do this from a programming language like Python rather than using the AWS CLI.

where will be stored our AWS Custom AMI?

we can take the back up of server which is running in AWS. that is called AMI.
How AWS handles our custom AMI ? where it will be stored ? can we access the Custom AMI Location ? I searched lot but could not get the answer. please let me know if there is any documentation about Custom AMI location. if it stored in S3 buckets can we see it ? or otherwise how can we know about out custom AMI.
An Amazon Machine Image (AMI) is stored in Amazon S3, but it is not directly accessible. Instead, you must use API calls or the Management Console to use an AMI.
The reality is that an AMI might actually contain content from other AMIs -- for example, if you launch an instance from a standard AWS-provided AMI, then add one file and create a new AMI, only the blocks that your instance changed would be stored -- the remaining (unchanged) blocks simply point to the original AMI content. This means that AMIs can often be quite small and you will not pay the cost of storing the complete disk. All of this is invisible to users.
You can see your 'custom' AMI in the AMIs section of the management console, or via the describe_images API call.

Different AMI based on AWS Region?

Is there any reasons that AWS AMI are different based on the region?
For example, if I try to launch an EC2 instance in Frankfurt I Got this AMI:
Amazon Linux AMI 2015.03 (HVM), SSD Volume Type - *ami-a8221fb5*
While in Oregon:
Amazon Linux AMI 2015.03 (HVM), SSD Volume Type - *ami-e7527ed7*
Note the different ami-version: ami-a8221fb5 and ami-e7527ed7.
Is there any reasons?
And how can I build a cloudformation template that I can launch on both Frankfurt or Oregon without having to change the ami ?
The reason for different AMIs in different region is related to the fact that you have to have thet actual image available in the region to be able to launch instances. (if you didn't you would basically have to transfer it from where it would be mastered - a transfer between distant regions would take a long time - so it would take a long time to launch new ec2 instances).
in theory, I guess you could have the same image id across multiple regions but that would just make it confusing in case the image bound to the id is not the same. not to mention that you probably don't want to push it to all regions (inter-region traffic is not free).
the choice that ec2 made here to have different ids per region gives you the maximum amount of control and flexibility without a high price.
for launching machines via cloudformation, you can definitely parametrize it the way E.J. Brennan describes it.
You would use parameterized values, such as in this pretty good example:
You can use an input parameter to refer to a specific value in a map
by using the Fn::FindInMap function. For example, suppose you have a
list of regions that map to a specific AMI. You can select the AMI
that your stack uses by specifying a region parameter when you create
the stack.
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-input-conditional-parameters.html
I just pushed a tool to help create mappings for multiple regions (by looking up the corresponding AMI image ID for an image given a source AMI image ID and region). It's written in boto3. You may find it useful. https://github.com/codesolid/ami-lookup.

What's AMI ImageType?

There is a image-type in describe-images filter, and an ImageType in response, however no information about what it stands for, and cannot find any information by googling.
There are three types: machine, kernel, ramdisk, what do they mean?
If you are just using AMI images provided by someone else, you can just ignore them -- you'll only need to use the AMI identifier when booting new instances.
A bit more detailed answer: The ramdisk image (ARI) and kernel image (AKI) are used as part of the boot sequence of a Linux instance.
More accurately:
Hardware virtualized (HVM) instances do not use ARI or AKIs at all. All of the boot sequence is part of the AMI itself. This includes both EBS and instance-store backed instance types.
Paravirtualized (PV e.g. running on Xen) EBS-backed instances need an AKI, and paravirtualized instance-backed instances need both AKI and ARI.
While AMIs are always unique, AKI/ARIs can be reused. For example, the aki-88aa75e1 kernel image is used by (in us-east-1, public images) by 5413 AMIs and the ramdisk ari-a51cf9cc by 683 AMIs. Both of these images are provided by Amazon and are thus trusted by others when they're building AMIs. Also if you bundle an instance-store/paravirtualized machine as an AMI it'll will inherit ARI and AKI from original AMI so many people publishing AMIs will implicitly re-use those.
Also note that Windows requires HVM, so ARI/AKI are not applicable to Windows instances at all.
Some links for more information:
https://forums.aws.amazon.com/thread.jspa?threadID=84096
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UserProvidedKernels.html

sharing an Amazon AWS AMI to another account via the console

I'm trying to view an AMI shared from one of my amazon accounts with another amazon account and it's not visible. I've followed all of the instructions here:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sharingamis-explicit.html
I've been able to share an EBS Volume successfully, but not the AMI. Are there any undocumented issues or steps anyone has run in to which might keep me from viewing the shared AMI?
Alternatively - is there a way to build an AMI from the snapshot?
It's possible that one of your accounts is set to a different region than your other. At least, that's what I just ran into.
AMIs don't cross regions - an AMI created in region A will never show up in any other region. You'll see this if your two accounts are in different regions, or even if you switch regions in one of your accounts.
There are two things you can do:
Just change regions in your target account. The AMI should magically appear - at least, it did for me. Easy, but unsatisfying, if you really like some other region.
In your source account, copy the AMI into the region that you'd like to use it from. Here are the official docs, but it's pretty straightforward. From the console, right-click the AMI, select Copy AMI, choose your region, and press the Copy AMI button. Wait until copied, then set permissions on the newly-generated AMI.
You'll have to wait, but at least you won't have to go through the song-and-dance that you used to.
You need to be in the correct region as well on the left hand side of the filter below launch there is a drop down menu that defaults the AMI's to "Owned by Me". Since you are in the destination account you need to select "Private Images"
All Amazon AWS AMI's are public and visible to all accounts. Are you talking about an AMI that you (or someone else) explicitly created following these steps:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami.html
If so, the instructions for sharing those are here:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-sharingamis.html
(I'm not sure the difference between your link and this link. They seem... the same)
EBS Snapshots, which are not AMIs, can be shared with other accounts. The instructions for sharing EBS Snapshots with other accounts are here:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-modifying-snapshot-permissions.html
I don't know of any direct way to create an AMI from a snapshot. I don't think there is one.