Using Boto to determine if an AWS AMI is available












4















I am using Boto to create an AMI of one of my EC2 boxes, and then I would like to spin up more boxes with that AMI, but the run_instances command is barking that my AMI is not available yet.



How can I use boto to query aws to find out when my ami is ready?



The EC2 connection supports a method to get_image



But the Image does not have any sort of status attribute










share|improve this question



























    4















    I am using Boto to create an AMI of one of my EC2 boxes, and then I would like to spin up more boxes with that AMI, but the run_instances command is barking that my AMI is not available yet.



    How can I use boto to query aws to find out when my ami is ready?



    The EC2 connection supports a method to get_image



    But the Image does not have any sort of status attribute










    share|improve this question

























      4












      4








      4








      I am using Boto to create an AMI of one of my EC2 boxes, and then I would like to spin up more boxes with that AMI, but the run_instances command is barking that my AMI is not available yet.



      How can I use boto to query aws to find out when my ami is ready?



      The EC2 connection supports a method to get_image



      But the Image does not have any sort of status attribute










      share|improve this question














      I am using Boto to create an AMI of one of my EC2 boxes, and then I would like to spin up more boxes with that AMI, but the run_instances command is barking that my AMI is not available yet.



      How can I use boto to query aws to find out when my ami is ready?



      The EC2 connection supports a method to get_image



      But the Image does not have any sort of status attribute







      python amazon-web-services boto






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 3 '12 at 18:10









      MattoToddMattoTodd

      5,197104771




      5,197104771
























          4 Answers
          4






          active

          oldest

          votes


















          5














          a quick dir of Image led me to Image.state with values like "pending" and "available"






          share|improve this answer































            2














            In addition to "pending" and "available" there is also the "failed" state. This is the full set of AMI states available.






            share|improve this answer































              0














              I used the above method but it took a little while for me to figure it out. Not a python person but here is what I did. Hope it helps someone.



              #EC2 Connection
              conn = boto.ec2.connect()

              image_status = conn.get_all_images(image_ids='ami-XXX')[0]
              image_state = image_status.state
              print image_state





              share|improve this answer































                0














                I can write a simple function using boto3



                def check_ami_exists(ami_id, region): 
                client = boto3.client('ec2', region_name = region)
                response = client.describe_images()
                for image in response['Images']:
                if ami_id == image['ImageId']:
                return True
                return False





                share|improve this answer























                  Your Answer






                  StackExchange.ifUsing("editor", function () {
                  StackExchange.using("externalEditor", function () {
                  StackExchange.using("snippets", function () {
                  StackExchange.snippets.init();
                  });
                  });
                  }, "code-snippets");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "1"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10437026%2fusing-boto-to-determine-if-an-aws-ami-is-available%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  4 Answers
                  4






                  active

                  oldest

                  votes








                  4 Answers
                  4






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  5














                  a quick dir of Image led me to Image.state with values like "pending" and "available"






                  share|improve this answer




























                    5














                    a quick dir of Image led me to Image.state with values like "pending" and "available"






                    share|improve this answer


























                      5












                      5








                      5







                      a quick dir of Image led me to Image.state with values like "pending" and "available"






                      share|improve this answer













                      a quick dir of Image led me to Image.state with values like "pending" and "available"







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered May 3 '12 at 18:21









                      MattoToddMattoTodd

                      5,197104771




                      5,197104771

























                          2














                          In addition to "pending" and "available" there is also the "failed" state. This is the full set of AMI states available.






                          share|improve this answer




























                            2














                            In addition to "pending" and "available" there is also the "failed" state. This is the full set of AMI states available.






                            share|improve this answer


























                              2












                              2








                              2







                              In addition to "pending" and "available" there is also the "failed" state. This is the full set of AMI states available.






                              share|improve this answer













                              In addition to "pending" and "available" there is also the "failed" state. This is the full set of AMI states available.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jul 26 '12 at 18:49









                              OkezieEOkezieE

                              3,43711923




                              3,43711923























                                  0














                                  I used the above method but it took a little while for me to figure it out. Not a python person but here is what I did. Hope it helps someone.



                                  #EC2 Connection
                                  conn = boto.ec2.connect()

                                  image_status = conn.get_all_images(image_ids='ami-XXX')[0]
                                  image_state = image_status.state
                                  print image_state





                                  share|improve this answer




























                                    0














                                    I used the above method but it took a little while for me to figure it out. Not a python person but here is what I did. Hope it helps someone.



                                    #EC2 Connection
                                    conn = boto.ec2.connect()

                                    image_status = conn.get_all_images(image_ids='ami-XXX')[0]
                                    image_state = image_status.state
                                    print image_state





                                    share|improve this answer


























                                      0












                                      0








                                      0







                                      I used the above method but it took a little while for me to figure it out. Not a python person but here is what I did. Hope it helps someone.



                                      #EC2 Connection
                                      conn = boto.ec2.connect()

                                      image_status = conn.get_all_images(image_ids='ami-XXX')[0]
                                      image_state = image_status.state
                                      print image_state





                                      share|improve this answer













                                      I used the above method but it took a little while for me to figure it out. Not a python person but here is what I did. Hope it helps someone.



                                      #EC2 Connection
                                      conn = boto.ec2.connect()

                                      image_status = conn.get_all_images(image_ids='ami-XXX')[0]
                                      image_state = image_status.state
                                      print image_state






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Nov 26 '14 at 23:40









                                      EzosEzos

                                      11017




                                      11017























                                          0














                                          I can write a simple function using boto3



                                          def check_ami_exists(ami_id, region): 
                                          client = boto3.client('ec2', region_name = region)
                                          response = client.describe_images()
                                          for image in response['Images']:
                                          if ami_id == image['ImageId']:
                                          return True
                                          return False





                                          share|improve this answer




























                                            0














                                            I can write a simple function using boto3



                                            def check_ami_exists(ami_id, region): 
                                            client = boto3.client('ec2', region_name = region)
                                            response = client.describe_images()
                                            for image in response['Images']:
                                            if ami_id == image['ImageId']:
                                            return True
                                            return False





                                            share|improve this answer


























                                              0












                                              0








                                              0







                                              I can write a simple function using boto3



                                              def check_ami_exists(ami_id, region): 
                                              client = boto3.client('ec2', region_name = region)
                                              response = client.describe_images()
                                              for image in response['Images']:
                                              if ami_id == image['ImageId']:
                                              return True
                                              return False





                                              share|improve this answer













                                              I can write a simple function using boto3



                                              def check_ami_exists(ami_id, region): 
                                              client = boto3.client('ec2', region_name = region)
                                              response = client.describe_images()
                                              for image in response['Images']:
                                              if ami_id == image['ImageId']:
                                              return True
                                              return False






                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Nov 24 '18 at 6:09









                                              rakeshzrakeshz

                                              264




                                              264






























                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Stack Overflow!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10437026%2fusing-boto-to-determine-if-an-aws-ami-is-available%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  Wiesbaden

                                                  Marschland

                                                  Dieringhausen