Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I get the AMI Id through the AMI name with boto3?

I’m trying to automate the creation of an autoscaling group Cloudformation Template using an EC2 instance already deployed and running so, for making an exact copy I need to have the AMI of the current instance. In order to get the Image I run the following script:

ec2 = boto3.client('ec2')
ec2.create_image(InstanceId="i-f234nr1kdd", Name="abc")

and it works, now what I need is to get the AMI Id using boto3 and the AMI name for pass the AMI Id to the cloudformation template.

I just need to get the AMI id value programmatically with the AMI name as parameter in order to pass the AMI Id to the part of my code that generates the Cloudformation template

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks since now!

>Solution :

response = ec2.create_image(InstanceId="i-f234nr1kdd", Name="abc")
response('ImageId')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading