List my custom images Azure CLI - azure-virtual-machine

I'm using Azure CLI to managed my VMs.
My VMs are created from a custom image. I forgot the name I was given to the image.
I created the image using az image create
Is there any way to list all my custom images name?
I tried using this command: az vm image list -o table -g myGroup but i got an exception that resource group parameter is not valid

This command will list all the images/name “azure vm image list”
Azure CLI
For images, use az image list --resource-group
Additional information: This article details some of the most common commands to create and manage virtual machines (VMs).

If you are interested in getting a more simplified and readable response with the name of all your Custom Images, I would recommend this command:
az image list --output table
You can also use this command as mentioned in other answer:
az image list --resource-group
But, this command will give you a more detailed JSON response with information about storageProfile, sourceVirtualmachine, etc..

Related

Create AMI using existing EC2 with Image builder pipeline

I have an EC2 instance with a lot of configurations, and those configurations update day by day. I need to create an Image Builder pipeline to get AMI from those EC2.How can I do that?
Is this possible in the AWS Image Builder pipeline? If yes, can anyone provide relevant documents for that requirement?
I refer to several documents and videos. But that all involves using base images.

Get the gcloud create cmd for a cluster created through the GCP UI

Is there an easy way to get the gcloud container clusters create ... command details for an existing cluster? (... Command that can be used to create the exact same cluster)
Someone from my team created a cluster on GKE through the UI with specific region and machine type details, and a few other customizations I can't remember. I'll be deleting the cluster, as it was for a test. We may need to recreate it and for this, instead of running through the UI, I was hoping to document the gcloud command that can be used to create the same cluster.
I couldn't find anything on the GCP UI to help with this. We can through the docs (https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster) construct the cmd that might build the same cluster, but wanted to check if there was a better way.
You can create your cluster on the GUI and use the button on the bottom to generate the HTTP Rest command or the Gcloud command line. You can find this on several pages in the GUI.
I recently was trying to get the gcloud command that can be used to recreate an existing cluster
I found a way to get the gcloud command with the parameters by going to your GKE-->create Cluster-->Clone an existing Cluster-->choose your Cluster and at the bottom you will have the Rest/command-line option.

Self describe regions with ECS/EC2 Instance

I want to securely fetch configuration files from S3 using a secure VPC from my Docker container. But I want to determine inside the application which configuration file to fetch and use based on the region I am on. Is there a good/best practice to go on about describing the current container's region?
I understand that you can use the AWS SDK/CLI to describe the ECS instances, but that doesn't tell me which one the container is specifically deployed on.
Use the metadata server to query the availability-zone from which you can get the region.
$ curl 169.254.169.254/latest/meta-data/placement/availability-zone/
us-east-1a
One example if you are using python SDK is:
import os
az = os.popen("curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone/").read()
print az[:-1]
>>> us-east-1
Within EC2, you can retrieve the instance metadata using a simple curl command to a local (internal) web API. Region and AZ are some of the data points you can get:
http://169.254.169.254/latest/meta-data/services/domain
http://169.254.169.254/latest/meta-data/placement/availability-zone
See this page for full details about instance metadata.
Within ECS, I'd be interested to see if these might still work -- my hunch is they would, as the container should query the host machine's API for the answer, and the ECS host is most certainly an EC2 instance.
Let us know if that works?

using spark with aws cluster

I setup a cluster successfully following the instruction here. Just wondering could I invoke Spark via the API with this type of cluster? Where can I find the Spark endpoint(s) detail(s) please? If the aforementioned tutorial is a dead-end, could anyone point me in the right direction please?
My ultimate POC aim is to add 2 columns in a flat file (e.g. csv) in some S3 bucket and compare the resulting values with a third column via spark (this is not a homework (-:) - ideally using Mobius as I am [former] .net dev).
This reference should provide you the information you need. Here is a snippet:
"Go into the ec2 directory in the release of Apache Spark you downloaded.
Run ./spark-ec2 -k <keypair> -i <key-file> -s <num-slaves> launch <cluster-name>, where <keypair> is the name of your EC2 key pair (that you gave it when you created it), <key-file> is the private key file for your key pair, <num-slaves> is the number of slave nodes to launch (try 1 at first), and <cluster-name> is the name to give to your cluster.
For example:
export AWS_SECRET_ACCESS_KEY=AaBbCcDdEeFGgHhIiJjKkLlMmNnOoPpQqRrSsTtU
export AWS_ACCESS_KEY_ID=ABCDEFG1234567890123
./spark-ec2 --key-pair=awskey --identity-file=awskey.pem --region=us-west-1 --zone=us-west-1a launch my-spark-cluster
After everything launches, check that the cluster scheduler is up and sees all the slaves by going to its web UI, which will be printed at the end of the script (typically http://master-hostname:8080)."

How do I save a customized AWS EC2 image (AMI)?

So, I am using an ubuntu AMI (amazon machine image). I have installed a couple of compiler, softwares, packages etc on this image. Now I want to save this image; so that I can use it to spawn multiple identical instances of this same AMI. How can I save my create and image of my current AMI instance in order to replicate it to create multiple identical instances?
Create a new AMI Image
Go to the AWS console
go to your EC2 dashboard : in the instances list
select your instance, right click on your instance
select image / create image
This will create an AMI image that you can reuse later