Class: Aws::EC2::VpcAddress

Inherits:
Object
  • Object
show all
Extended by:
Deprecations
Defined in:
lib/aws-sdk-ec2/vpc_address.rb

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Actions collapse

Associations collapse

Instance Method Summary collapse

Constructor Details

#initialize(allocation_id, options = {}) ⇒ VpcAddress #initialize(options = {}) ⇒ VpcAddress

Returns a new instance of VpcAddress.

Overloads:

  • #initialize(allocation_id, options = {}) ⇒ VpcAddress

    Parameters:

    • allocation_id (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ VpcAddress

    Options Hash (options):

    • :allocation_id (required, String)
    • :client (Client)


19
20
21
22
23
24
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 19

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @allocation_id = extract_allocation_id(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
end

Instance Method Details

#allocation_idString

Returns:

  • (String)


29
30
31
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 29

def allocation_id
  @allocation_id
end

#associate(options = {}) ⇒ Types::AssociateAddressResult

Examples:

Request syntax with placeholder values


vpc_address.associate({
  instance_id: "String",
  public_ip: "String",
  allow_reassociation: false,
  dry_run: false,
  network_interface_id: "String",
  private_ip_address: "String",
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :instance_id (String)

    The ID of the instance. This is required for EC2-Classic. For EC2-VPC, you can specify either the instance ID or the network interface ID, but not both. The operation fails if you specify an instance ID unless exactly one network interface is attached.

  • :public_ip (String)

    The Elastic IP address. This is required for EC2-Classic.

  • :allow_reassociation (Boolean)

    [EC2-VPC] For a VPC in an EC2-Classic account, specify true to allow an Elastic IP address that is already associated with an instance or network interface to be reassociated with the specified instance or network interface. Otherwise, the operation fails. In a VPC in an EC2-VPC-only account, reassociation is automatic, therefore you can specify false to ensure the operation fails if the Elastic IP address is already associated with another resource.

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is ‘DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.

  • :network_interface_id (String)

    [EC2-VPC] The ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID.

  • :private_ip_address (String)

    [EC2-VPC] The primary or secondary private IP address to associate with the Elastic IP address. If no private IP address is specified, the Elastic IP address is associated with the primary private IP address.

Returns:



154
155
156
157
158
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 154

def associate(options = {})
  options = options.merge(allocation_id: @allocation_id)
  resp = @client.associate_address(options)
  resp.data
end

#associationNetworkInterfaceAssociation?

Returns:



184
185
186
187
188
189
190
191
192
193
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 184

def association
  if data.association_id
    NetworkInterfaceAssociation.new(
      id: data.association_id,
      client: @client
    )
  else
    nil
  end
end

#association_idString

The ID representing the association of the address with an instance in a VPC.

Returns:

  • (String)


48
49
50
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 48

def association_id
  data.association_id
end

#clientClient

Returns:



80
81
82
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 80

def client
  @client
end

#dataTypes::Address

Returns the data for this Aws::EC2::VpcAddress. Calls Client#describe_addresses if #data_loaded? is ‘false`.

Returns:



100
101
102
103
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 100

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns ‘true` if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns ‘true` if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



108
109
110
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 108

def data_loaded?
  !!@data
end

#domainString

Indicates whether this Elastic IP address is for use with instances in EC2-Classic (‘standard`) or instances in a VPC (`vpc`).

Returns:

  • (String)


55
56
57
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 55

def domain
  data.domain
end

#identifiersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.


197
198
199
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 197

def identifiers
  { allocation_id: @allocation_id }
end

#instance_idString

The ID of the instance that the address is associated with (if any).

Returns:

  • (String)


35
36
37
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 35

def instance_id
  data.instance_id
end

#loadself Also known as: reload

Loads, or reloads #data for the current Aws::EC2::VpcAddress. Returns ‘self` making it possible to chain methods.

vpc_address.reload.data

Returns:

  • (self)


90
91
92
93
94
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 90

def load
  resp = @client.describe_addresses(allocation_ids: [@allocation_id])
  @data = resp.addresses[0]
  self
end

#network_interface_idString

The ID of the network interface.

Returns:

  • (String)


61
62
63
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 61

def network_interface_id
  data.network_interface_id
end

#network_interface_owner_idString

The ID of the AWS account that owns the network interface.

Returns:

  • (String)


67
68
69
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 67

def network_interface_owner_id
  data.network_interface_owner_id
end

#private_ip_addressString

The private IP address associated with the Elastic IP address.

Returns:

  • (String)


73
74
75
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 73

def private_ip_address
  data.private_ip_address
end

#public_ipString

The Elastic IP address.

Returns:

  • (String)


41
42
43
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 41

def public_ip
  data.public_ip
end

#release(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


vpc_address.release({
  public_ip: "String",
  dry_run: false,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :public_ip (String)

    [EC2-Classic] The Elastic IP address. Required for EC2-Classic.

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is ‘DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.

Returns:

  • (EmptyStructure)


175
176
177
178
179
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 175

def release(options = {})
  options = options.merge(allocation_id: data.allocation_id)
  resp = @client.release_address(options)
  resp.data
end