title: Removing Amazon EC2 instance using python boto
body: <p>I have found some example code which is apparently able to create an Amazon Ec2 instance using python boto. However, for the life of me I can't work out how to make a function to delete the instance.</p>
  
  <p>Can anyone who knows a bit more about python and boto show me what I should be doing in order to remove this instance.</p>
  
  <pre><code># Delete EC2 instance
  def delete_server():
      print(_yellow("Deleting EC2 instance"))
  
  # Create EC2 instance
  def create_server():
      print(_yellow("Creating EC2 instance"))
  
      image = conn.get_all_images(ec2_amis)
  
      reservation = image[0].run(1, 1, key_name=ec2_key_pair, security_groups=ec2_security,
          instance_type=ec2_instancetype)
  
      instance = reservation.instances[0]
      conn.create_tags([instance.id], {"Name":config['INSTANCE_NAME_TAG']})
      while instance.state == u'pending':
          print(_yellow("Instance state: %s" % instance.state))
          time.sleep(10)
          instance.update()
  
      print(_green("Instance state: %s" % instance.state))
      print(_green("Public dns: %s" % instance.public_dns_name))
  
      return instance.public_dns_name
  </code></pre>