ruby/example_code/ec2/ec2-ruby-example-elastic-ips.rb
# Creates an Elastic IP address in Amazon Virtual Private Cloud (Amazon VPC).
#
# @param ec2_client [Aws::EC2::Client] An initialized EC2 client.
# @return [String] The allocation ID corresponding to the Elastic IP address.
# @example
#   puts allocate_elastic_ip_address(Aws::EC2::Client.new(region: 'us-west-2'))

Creates an Elastic IP address in Amazon Virtual Private Cloud (Amazon VPC).
Creates an Elastic IP address in Amazon Virtual Private Cloud ( Amazon VPC ) .
def allocate_elastic_ip_address(ec2_client)
  response = ec2_client.allocate_address(domain: 'vpc')
  return response.allocation_id
rescue StandardError => e
  puts "Error allocating Elastic IP address: #{e.message}"
  return 'Error'
end
def allocate_elastic_ip_address ( ec2_client ) response = ec2_client . allocate_address ( domain : 'vpc' ) return response . allocation_id rescue StandardError => e puts "Error allocating Elastic IP address: #{e.message}" return 'Error' end
Creates an Elastic IP address in Amazon Virtual Private Cloud (Amazon VPC).
Creates an Elastic IP address in Amazon Virtual Private Cloud ( Amazon VPC ) .
The allocation ID corresponding to the Elastic IP address.
The allocation ID corresponding to the Elastic IP address .
String
ec2_client
An initialized EC2 client.
An initialized EC2 client .
example
puts allocate_elastic_ip_address(Aws::EC2::Client.new(region: 'us-west-2'))
puts allocate_elastic_ip_address ( Aws :: EC2 :: Client . new ( region : ' us - west - 2 ' ))