ruby/example_code/ec2/ec2-ruby-example-elastic-ips.rb
# Releases an Elastic IP address from an
# Amazon Elastic Compute Cloud (Amazon EC2) instance.
#
# Prerequisites:
#
# - An Amazon EC2 instance with an associated Elastic IP address.
#
# @param ec2_client [Aws::EC2::Client] An initialized EC2 client.
# @param allocation_id [String] The ID of the allocation corresponding to
#   the Elastic IP address.
# @return [Boolean] true if the Elastic IP address was released;
#   otherwise, false.
# @example
#   exit 1 unless elastic_ip_address_released?(
#     Aws::EC2::Client.new(region: 'us-west-2'),
#     'eipalloc-04452e528a66279EX'
#   )

Releases an Elastic IP address from an
Amazon Elastic Compute Cloud (Amazon EC2) instance.



An Amazon EC2 instance with an associated Elastic IP address.
Releases an Elastic IP address from an Amazon Elastic Compute Cloud ( Amazon EC2 ) instance . An Amazon EC2 instance with an associated Elastic IP address .
def elastic_ip_address_released?(ec2_client, allocation_id)
  ec2_client.release_address(allocation_id: allocation_id)
  return true
rescue StandardError => e
  return "Error releasing Elastic IP address: #{e.message}"
  return false
end
def elastic_ip_address_released? ( ec2_client , allocation_id ) ec2_client . release_address ( allocation_id : allocation_id ) return true rescue StandardError => e return "Error releasing Elastic IP address: #{e.message}" return false end
Releases an Elastic IP address from an
Amazon Elastic Compute Cloud (Amazon EC2) instance.
Releases an Elastic IP address from an Amazon Elastic Compute Cloud ( Amazon EC2 ) instance .
true if the Elastic IP address was released; otherwise, false.
true if the Elastic IP address was released ; otherwise false .
Boolean
ec2_client
An initialized EC2 client.
An initialized EC2 client .
allocation_id
The ID of the allocation corresponding to the Elastic IP address.
The ID of the allocation corresponding to the Elastic IP address .
example
exit 1 unless elastic_ip_address_released?( Aws::EC2::Client.new(region: 'us-west-2'), 'eipalloc-04452e528a66279EX' )
exit 1 unless elastic_ip_address_released? ( Aws :: EC2 :: Client . new ( region : ' us - west - 2 ' ) ' eipalloc - 04452e528a66279EX ' )