Class: Aws::EC2::Vpc

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

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Actions collapse

Associations collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, options = {}) ⇒ Vpc #initialize(options = {}) ⇒ Vpc

Returns a new instance of Vpc.

Overloads:

  • #initialize(id, options = {}) ⇒ Vpc

    Parameters:

    • id (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ Vpc

    Options Hash (options):

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


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

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

Instance Method Details

#accepted_vpc_peering_connections(options = {}) ⇒ VpcPeeringConnection::Collection

Examples:

Request syntax with placeholder values


accepted_vpc_peering_connections = vpc.accepted_vpc_peering_connections({
  filters: [
    {
      name: "String",
      values: ["String"],
    },
  ],
  dry_run: false,
  vpc_peering_connection_ids: ["String"],
})

Parameters:

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

    ({})

Options Hash (options):

  • :filters (Array<Types::Filter>)

    One or more filters.

    • ‘accepter-vpc-info.cidr-block` - The IPv4 CIDR block of the peer VPC.

    • ‘accepter-vpc-info.owner-id` - The AWS account ID of the owner of the peer VPC.

    • ‘accepter-vpc-info.vpc-id` - The ID of the peer VPC.

    • ‘expiration-time` - The expiration date and time for the VPC peering connection.

    • ‘requester-vpc-info.cidr-block` - The IPv4 CIDR block of the requester’s VPC.

    • ‘requester-vpc-info.owner-id` - The AWS account ID of the owner of the requester VPC.

    • ‘requester-vpc-info.vpc-id` - The ID of the requester VPC.

    • ‘status-code` - The status of the VPC peering connection (`pending-acceptance` | `failed` | `expired` | `provisioning` | `active` | `deleted` | `rejected`).

    • ‘status-message` - A message that provides more information about the status of the VPC peering connection, if applicable.

    • ‘tag`:key=value - The key/value combination of a tag assigned to the resource. Specify the key of the tag in the filter name and the value of the tag in the filter value. For example, for the tag Purpose=X, specify `tag:Purpose` for the filter name and `X` for the filter value.

    • ‘tag-key` - The key of a tag assigned to the resource. This filter is independent of the `tag-value` filter. For example, if you use both the filter “tag-key=Purpose” and the filter “tag-value=X”, you get any resources assigned both the tag key Purpose (regardless of what the tag’s value is), and the tag value X (regardless of what the tag’s key is). If you want to list only resources where Purpose is X, see the ‘tag`:key=value filter.

    • ‘tag-value` - The value of a tag assigned to the resource. This filter is independent of the `tag-key` filter.

    • ‘vpc-peering-connection-id` - The ID of the VPC peering connection.

  • :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`.

  • :vpc_peering_connection_ids (Array<String>)

    One or more VPC peering connection IDs.

    Default: Describes all your VPC peering connections.

Returns:



652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
# File 'lib/aws-sdk-ec2/vpc.rb', line 652

def accepted_vpc_peering_connections(options = {})
  batches = Enumerator.new do |y|
    batch = []
    options = Aws::Util.deep_merge(options, filters: [{
      name: "accepter-vpc-info.vpc-id",
      values: [@id]
    }])
    resp = @client.describe_vpc_peering_connections(options)
    resp.data.vpc_peering_connections.each do |v|
      batch << VpcPeeringConnection.new(
        id: v.vpc_peering_connection_id,
        data: v,
        client: @client
      )
    end
    y.yield(batch)
  end
  VpcPeeringConnection::Collection.new(batches)
end

#associate_dhcp_options(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


vpc.associate_dhcp_options({
  dhcp_options_id: "String", # required
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :dhcp_options_id (required, String)

    The ID of the DHCP options set, or ‘default` to associate no DHCP options with the VPC.

  • :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)


184
185
186
187
188
# File 'lib/aws-sdk-ec2/vpc.rb', line 184

def associate_dhcp_options(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.associate_dhcp_options(options)
  resp.data
end

Examples:

Request syntax with placeholder values


vpc.attach_classic_link_instance({
  dry_run: false,
  groups: ["String"], # required
  instance_id: "String", # required
})

Parameters:

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

    ({})

Options Hash (options):

  • :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`.

  • :groups (required, Array<String>)

    The ID of one or more of the VPC’s security groups. You cannot specify security groups from a different VPC.

  • :instance_id (required, String)

    The ID of an EC2-Classic instance to link to the ClassicLink-enabled VPC.

Returns:



210
211
212
213
214
# File 'lib/aws-sdk-ec2/vpc.rb', line 210

def attach_classic_link_instance(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.attach_classic_link_vpc(options)
  resp.data
end

#attach_internet_gateway(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


vpc.attach_internet_gateway({
  dry_run: false,
  internet_gateway_id: "String", # required
})

Parameters:

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

    ({})

Options Hash (options):

  • :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`.

  • :internet_gateway_id (required, String)

    The ID of the Internet gateway.

Returns:

  • (EmptyStructure)


231
232
233
234
235
# File 'lib/aws-sdk-ec2/vpc.rb', line 231

def attach_internet_gateway(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.attach_internet_gateway(options)
  resp.data
end

#cidr_blockString

The primary IPv4 CIDR block for the VPC.

Returns:

  • (String)


36
37
38
# File 'lib/aws-sdk-ec2/vpc.rb', line 36

def cidr_block
  data.cidr_block
end

#cidr_block_association_setArray<Types::VpcCidrBlockAssociation>

Information about the IPv4 CIDR blocks associated with the VPC.

Returns:



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

def cidr_block_association_set
  data.cidr_block_association_set
end

#clientClient

Returns:



86
87
88
# File 'lib/aws-sdk-ec2/vpc.rb', line 86

def client
  @client
end

#create_network_acl(options = {}) ⇒ NetworkAcl

Examples:

Request syntax with placeholder values


networkacl = vpc.create_network_acl({
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :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:



249
250
251
252
253
254
255
256
257
# File 'lib/aws-sdk-ec2/vpc.rb', line 249

def create_network_acl(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.create_network_acl(options)
  NetworkAcl.new(
    id: resp.data.network_acl.network_acl_id,
    data: resp.data.network_acl,
    client: @client
  )
end

#create_route_table(options = {}) ⇒ RouteTable

Examples:

Request syntax with placeholder values


routetable = vpc.create_route_table({
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :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:



271
272
273
274
275
276
277
278
279
# File 'lib/aws-sdk-ec2/vpc.rb', line 271

def create_route_table(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.create_route_table(options)
  RouteTable.new(
    id: resp.data.route_table.route_table_id,
    data: resp.data.route_table,
    client: @client
  )
end

#create_security_group(options = {}) ⇒ SecurityGroup

Examples:

Request syntax with placeholder values


securitygroup = vpc.create_security_group({
  description: "String", # required
  group_name: "String", # required
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :description (required, String)

    A description for the security group. This is informational only.

    Constraints: Up to 255 characters in length

    Constraints for EC2-Classic: ASCII characters

    Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@+=&amp;;{\}!$*

  • :group_name (required, String)

    The name of the security group.

    Constraints: Up to 255 characters in length

    Constraints for EC2-Classic: ASCII characters

    Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@+=&amp;;{\}!$*

  • :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:



313
314
315
316
317
318
319
320
# File 'lib/aws-sdk-ec2/vpc.rb', line 313

def create_security_group(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.create_security_group(options)
  SecurityGroup.new(
    id: resp.data.group_id,
    client: @client
  )
end

#create_subnet(options = {}) ⇒ Subnet

Examples:

Request syntax with placeholder values


subnet = vpc.create_subnet({
  availability_zone: "String",
  cidr_block: "String", # required
  ipv_6_cidr_block: "String",
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :availability_zone (String)

    The Availability Zone for the subnet.

    Default: AWS selects one for you. If you create more than one subnet in your VPC, we may not necessarily select a different zone for each subnet.

  • :cidr_block (required, String)

    The IPv4 network range for the subnet, in CIDR notation. For example, ‘10.0.0.0/24`.

  • :ipv_6_cidr_block (String)

    The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.

  • :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:



349
350
351
352
353
354
355
356
357
# File 'lib/aws-sdk-ec2/vpc.rb', line 349

def create_subnet(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.create_subnet(options)
  Subnet.new(
    id: resp.data.subnet.subnet_id,
    data: resp.data.subnet,
    client: @client
  )
end

#create_tags(options = {}) ⇒ Tag::Collection

Examples:

Request syntax with placeholder values


tag = vpc.create_tags({
  dry_run: false,
  tags: [ # required
    {
      key: "String",
      value: "String",
    },
  ],
})

Parameters:

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

    ({})

Options Hash (options):

  • :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`.

  • :tags (required, Array<Types::Tag>)

    One or more tags. The ‘value` parameter is required, but if you don’t want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.

Returns:



381
382
383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/aws-sdk-ec2/vpc.rb', line 381

def create_tags(options = {})
  batch = []
  options = Aws::Util.deep_merge(options, resources: [@id])
  resp = @client.create_tags(options)
  options[:tags].each do |t|
    batch << Tag.new(
      resource_id: @id,
      key: t[:key],
      value: t[:value],
      client: @client
    )
  end
  Tag::Collection.new([batch], size: batch.size)
end

#dataTypes::Vpc

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

Returns:



106
107
108
109
# File 'lib/aws-sdk-ec2/vpc.rb', line 106

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.



114
115
116
# File 'lib/aws-sdk-ec2/vpc.rb', line 114

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


vpc.delete({
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :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)


408
409
410
411
412
# File 'lib/aws-sdk-ec2/vpc.rb', line 408

def delete(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.delete_vpc(options)
  resp.data
end

#describe_attribute(options = {}) ⇒ Types::DescribeVpcAttributeResult

Examples:

Request syntax with placeholder values


vpc.describe_attribute({
  attribute: "enableDnsSupport", # required, accepts enableDnsSupport, enableDnsHostnames
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :attribute (required, String)

    The VPC attribute.

  • :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:



429
430
431
432
433
# File 'lib/aws-sdk-ec2/vpc.rb', line 429

def describe_attribute(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.describe_vpc_attribute(options)
  resp.data
end

Examples:

Request syntax with placeholder values


vpc.detach_classic_link_instance({
  dry_run: false,
  instance_id: "String", # required
})

Parameters:

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

    ({})

Options Hash (options):

  • :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`.

  • :instance_id (required, String)

    The ID of the instance to unlink from the VPC.

Returns:



450
451
452
453
454
# File 'lib/aws-sdk-ec2/vpc.rb', line 450

def detach_classic_link_instance(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.detach_classic_link_vpc(options)
  resp.data
end

#detach_internet_gateway(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


vpc.detach_internet_gateway({
  dry_run: false,
  internet_gateway_id: "String", # required
})

Parameters:

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

    ({})

Options Hash (options):

  • :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`.

  • :internet_gateway_id (required, String)

    The ID of the Internet gateway.

Returns:

  • (EmptyStructure)


471
472
473
474
475
# File 'lib/aws-sdk-ec2/vpc.rb', line 471

def detach_internet_gateway(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.detach_internet_gateway(options)
  resp.data
end

#dhcp_optionsDhcpOptions?

Returns:



673
674
675
676
677
678
679
680
681
682
# File 'lib/aws-sdk-ec2/vpc.rb', line 673

def dhcp_options
  if data.dhcp_options_id
    DhcpOptions.new(
      id: data.dhcp_options_id,
      client: @client
    )
  else
    nil
  end
end

#dhcp_options_idString

The ID of the set of DHCP options you’ve associated with the VPC (or ‘default` if the default options are associated with the VPC).

Returns:

  • (String)


43
44
45
# File 'lib/aws-sdk-ec2/vpc.rb', line 43

def dhcp_options_id
  data.dhcp_options_id
end

Examples:

Request syntax with placeholder values


vpc.disable_classic_link({
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :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:



489
490
491
492
493
# File 'lib/aws-sdk-ec2/vpc.rb', line 489

def disable_classic_link(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.disable_vpc_classic_link(options)
  resp.data
end

Examples:

Request syntax with placeholder values


vpc.enable_classic_link({
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :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:



507
508
509
510
511
# File 'lib/aws-sdk-ec2/vpc.rb', line 507

def enable_classic_link(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.enable_vpc_classic_link(options)
  resp.data
end

#exists?(options = {}) ⇒ Boolean

Returns ‘true` if the Vpc exists.

Parameters:

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

    ({})

Returns:

  • (Boolean)

    Returns ‘true` if the Vpc exists.



121
122
123
124
125
126
127
128
129
130
# File 'lib/aws-sdk-ec2/vpc.rb', line 121

def exists?(options = {})
  begin
    wait_until_exists(options.merge(max_attempts: 1))
    true
  rescue Aws::Waiters::Errors::UnexpectedError => e
    raise e.error
  rescue Aws::Waiters::Errors::WaiterFailed
    false
  end
end

#idString Also known as: vpc_id

Returns:

  • (String)


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

def id
  @id
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.


1726
1727
1728
# File 'lib/aws-sdk-ec2/vpc.rb', line 1726

def identifiers
  { id: @id }
end

#instance_tenancyString

The allowed tenancy of instances launched into the VPC.

Returns:

  • (String)


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

def instance_tenancy
  data.instance_tenancy
end

#instances(options = {}) ⇒ Instance::Collection

Examples:

Request syntax with placeholder values


instances = vpc.instances({
  filters: [
    {
      name: "String",
      values: ["String"],
    },
  ],
  instance_ids: ["String"],
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :filters (Array<Types::Filter>)

    One or more filters.

    • ‘affinity` - The affinity setting for an instance running on a Dedicated Host (`default` | `host`).

    • ‘architecture` - The instance architecture (`i386` | `x86_64`).

    • ‘availability-zone` - The Availability Zone of the instance.

    • ‘block-device-mapping.attach-time` - The attach time for an EBS volume mapped to the instance, for example, `2010-09-15T17:15:20.000Z`.

    • ‘block-device-mapping.delete-on-termination` - A Boolean that indicates whether the EBS volume is deleted on instance termination.

    • ‘block-device-mapping.device-name` - The device name for the EBS volume (for example, `/dev/sdh` or `xvdh`).

    • ‘block-device-mapping.status` - The status for the EBS volume (`attaching` | `attached` | `detaching` | `detached`).

    • ‘block-device-mapping.volume-id` - The volume ID of the EBS volume.

    • ‘client-token` - The idempotency token you provided when you launched the instance.

    • ‘dns-name` - The public DNS name of the instance.

    • ‘group-id` - The ID of the security group for the instance. EC2-Classic only.

    • ‘group-name` - The name of the security group for the instance. EC2-Classic only.

    • ‘host-id` - The ID of the Dedicated Host on which the instance is running, if applicable.

    • ‘hypervisor` - The hypervisor type of the instance (`ovm` | `xen`).

    • ‘iam-instance-profile.arn` - The instance profile associated with the instance. Specified as an ARN.

    • ‘image-id` - The ID of the image used to launch the instance.

    • ‘instance-id` - The ID of the instance.

    • ‘instance-lifecycle` - Indicates whether this is a Spot Instance or a Scheduled Instance (`spot` | `scheduled`).

    • ‘instance-state-code` - The state of the instance, as a 16-bit unsigned integer. The high byte is an opaque internal value and should be ignored. The low byte is set based on the state represented. The valid values are: 0 (pending), 16 (running), 32 (shutting-down), 48 (terminated), 64 (stopping), and 80 (stopped).

    • ‘instance-state-name` - The state of the instance (`pending` | `running` | `shutting-down` | `terminated` | `stopping` | `stopped`).

    • ‘instance-type` - The type of instance (for example, `t2.micro`).

    • ‘instance.group-id` - The ID of the security group for the instance.

    • ‘instance.group-name` - The name of the security group for the instance.

    • ‘ip-address` - The public IPv4 address of the instance.

    • ‘kernel-id` - The kernel ID.

    • ‘key-name` - The name of the key pair used when the instance was launched.

    • ‘launch-index` - When launching multiple instances, this is the index for the instance in the launch group (for example, 0, 1, 2, and so on).

    • ‘launch-time` - The time when the instance was launched.

    • ‘monitoring-state` - Indicates whether detailed monitoring is enabled (`disabled` | `enabled`).

    • ‘network-interface.addresses.private-ip-address` - The private IPv4 address associated with the network interface.

    • ‘network-interface.addresses.primary` - Specifies whether the IPv4 address of the network interface is the primary private IPv4 address.

    • ‘network-interface.addresses.association.public-ip` - The ID of the association of an Elastic IP address (IPv4) with a network interface.

    • ‘network-interface.addresses.association.ip-owner-id` - The owner ID of the private IPv4 address associated with the network interface.

    • ‘network-interface.association.public-ip` - The address of the Elastic IP address (IPv4) bound to the network interface.

    • ‘network-interface.association.ip-owner-id` - The owner of the Elastic IP address (IPv4) associated with the network interface.

    • ‘network-interface.association.allocation-id` - The allocation ID returned when you allocated the Elastic IP address (IPv4) for your network interface.

    • ‘network-interface.association.association-id` - The association ID returned when the network interface was associated with an IPv4 address.

    • ‘network-interface.attachment.attachment-id` - The ID of the interface attachment.

    • ‘network-interface.attachment.instance-id` - The ID of the instance to which the network interface is attached.

    • ‘network-interface.attachment.instance-owner-id` - The owner ID of the instance to which the network interface is attached.

    • ‘network-interface.attachment.device-index` - The device index to which the network interface is attached.

    • ‘network-interface.attachment.status` - The status of the attachment (`attaching` | `attached` | `detaching` | `detached`).

    • ‘network-interface.attachment.attach-time` - The time that the network interface was attached to an instance.

    • ‘network-interface.attachment.delete-on-termination` - Specifies whether the attachment is deleted when an instance is terminated.

    • ‘network-interface.availability-zone` - The Availability Zone for the network interface.

    • ‘network-interface.description` - The description of the network interface.

    • ‘network-interface.group-id` - The ID of a security group associated with the network interface.

    • ‘network-interface.group-name` - The name of a security group associated with the network interface.

    • ‘network-interface.ipv6-addresses.ipv6-address` - The IPv6 address associated with the network interface.

    • ‘network-interface.mac-address` - The MAC address of the network interface.

    • ‘network-interface.network-interface-id` - The ID of the network interface.

    • ‘network-interface.owner-id` - The ID of the owner of the network interface.

    • ‘network-interface.private-dns-name` - The private DNS name of the network interface.

    • ‘network-interface.requester-id` - The requester ID for the network interface.

    • ‘network-interface.requester-managed` - Indicates whether the network interface is being managed by AWS.

    • ‘network-interface.status` - The status of the network interface (`available`) | `in-use`).

    • ‘network-interface.source-dest-check` - Whether the network interface performs source/destination checking. A value of `true` means checking is enabled, and `false` means checking is disabled. The value must be `false` for the network interface to perform network address translation (NAT) in your VPC.

    • ‘network-interface.subnet-id` - The ID of the subnet for the network interface.

    • ‘network-interface.vpc-id` - The ID of the VPC for the network interface.

    • ‘owner-id` - The AWS account ID of the instance owner.

    • ‘placement-group-name` - The name of the placement group for the instance.

    • ‘platform` - The platform. Use `windows` if you have Windows instances; otherwise, leave blank.

    • ‘private-dns-name` - The private IPv4 DNS name of the instance.

    • ‘private-ip-address` - The private IPv4 address of the instance.

    • ‘product-code` - The product code associated with the AMI used to launch the instance.

    • ‘product-code.type` - The type of product code (`devpay` | `marketplace`).

    • ‘ramdisk-id` - The RAM disk ID.

    • ‘reason` - The reason for the current state of the instance (for example, shows “User Initiated [date]” when you stop or terminate the instance). Similar to the state-reason-code filter.

    • ‘requester-id` - The ID of the entity that launched the instance on your behalf (for example, AWS Management Console, Auto Scaling, and so on).

    • ‘reservation-id` - The ID of the instance’s reservation. A reservation ID is created any time you launch an instance. A reservation ID has a one-to-one relationship with an instance launch request, but can be associated with more than one instance if you launch multiple instances using the same launch request. For example, if you launch one instance, you’ll get one reservation ID. If you launch ten instances using the same launch request, you’ll also get one reservation ID.

    • ‘root-device-name` - The name of the root device for the instance (for example, `/dev/sda1` or `/dev/xvda`).

    • ‘root-device-type` - The type of root device that the instance uses (`ebs` | `instance-store`).

    • ‘source-dest-check` - Indicates whether the instance performs source/destination checking. A value of `true` means that checking is enabled, and `false` means checking is disabled. The value must be `false` for the instance to perform network address translation (NAT) in your VPC.

    • ‘spot-instance-request-id` - The ID of the Spot instance request.

    • ‘state-reason-code` - The reason code for the state change.

    • ‘state-reason-message` - A message that describes the state change.

    • ‘subnet-id` - The ID of the subnet for the instance.

    • ‘tag`:key=value - The key/value combination of a tag assigned to the resource. Specify the key of the tag in the filter name and the value of the tag in the filter value. For example, for the tag Purpose=X, specify `tag:Purpose` for the filter name and `X` for the filter value.

    • ‘tag-key` - The key of a tag assigned to the resource. This filter is independent of the `tag-value` filter. For example, if you use both the filter “tag-key=Purpose” and the filter “tag-value=X”, you get any resources assigned both the tag key Purpose (regardless of what the tag’s value is), and the tag value X (regardless of what the tag’s key is). If you want to list only resources where Purpose is X, see the ‘tag`:key=value filter.

    • ‘tag-value` - The value of a tag assigned to the resource. This filter is independent of the `tag-key` filter.

    • ‘tenancy` - The tenancy of an instance (`dedicated` | `default` | `host`).

    • ‘virtualization-type` - The virtualization type of the instance (`paravirtual` | `hvm`).

    • ‘vpc-id` - The ID of the VPC that the instance is running in.

  • :instance_ids (Array<String>)

    One or more instance IDs.

    Default: Describes all your instances.

  • :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:



969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
# File 'lib/aws-sdk-ec2/vpc.rb', line 969

def instances(options = {})
  batches = Enumerator.new do |y|
    options = Aws::Util.deep_merge(options, filters: [{
      name: "vpc-id",
      values: [@id]
    }])
    resp = @client.describe_instances(options)
    resp.each_page do |page|
      batch = []
      page.data.reservations.each do |r|
        r.instances.each do |i|
          batch << Instance.new(
            id: i.instance_id,
            data: i,
            client: @client
          )
        end
      end
      y.yield(batch)
    end
  end
  Instance::Collection.new(batches)
end

#internet_gateways(options = {}) ⇒ InternetGateway::Collection

Examples:

Request syntax with placeholder values


internet_gateways = vpc.internet_gateways({
  filters: [
    {
      name: "String",
      values: ["String"],
    },
  ],
  dry_run: false,
  internet_gateway_ids: ["String"],
})

Parameters:

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

    ({})

Options Hash (options):

  • :filters (Array<Types::Filter>)

    One or more filters.

    • ‘attachment.state` - The current state of the attachment between the gateway and the VPC (`available`). Present only if a VPC is attached.

    • ‘attachment.vpc-id` - The ID of an attached VPC.

    • ‘internet-gateway-id` - The ID of the Internet gateway.

    • ‘tag`:key=value - The key/value combination of a tag assigned to the resource. Specify the key of the tag in the filter name and the value of the tag in the filter value. For example, for the tag Purpose=X, specify `tag:Purpose` for the filter name and `X` for the filter value.

    • ‘tag-key` - The key of a tag assigned to the resource. This filter is independent of the `tag-value` filter. For example, if you use both the filter “tag-key=Purpose” and the filter “tag-value=X”, you get any resources assigned both the tag key Purpose (regardless of what the tag’s value is), and the tag value X (regardless of what the tag’s key is). If you want to list only resources where Purpose is X, see the ‘tag`:key=value filter.

    • ‘tag-value` - The value of a tag assigned to the resource. This filter is independent of the `tag-key` filter.

  • :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`.

  • :internet_gateway_ids (Array<String>)

    One or more Internet gateway IDs.

    Default: Describes all your Internet gateways.

Returns:



1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
# File 'lib/aws-sdk-ec2/vpc.rb', line 1043

def internet_gateways(options = {})
  batches = Enumerator.new do |y|
    batch = []
    options = Aws::Util.deep_merge(options, filters: [{
      name: "attachment.vpc-id",
      values: [@id]
    }])
    resp = @client.describe_internet_gateways(options)
    resp.data.internet_gateways.each do |i|
      batch << InternetGateway.new(
        id: i.internet_gateway_id,
        data: i,
        client: @client
      )
    end
    y.yield(batch)
  end
  InternetGateway::Collection.new(batches)
end

#ipv_6_cidr_block_association_setArray<Types::VpcIpv6CidrBlockAssociation>

Information about the IPv6 CIDR blocks associated with the VPC.



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

def ipv_6_cidr_block_association_set
  data.ipv_6_cidr_block_association_set
end

#is_defaultBoolean

Indicates whether the VPC is the default VPC.

Returns:

  • (Boolean)


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

def is_default
  data.is_default
end

#loadself Also known as: reload

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

vpc.reload.data

Returns:

  • (self)


96
97
98
99
100
# File 'lib/aws-sdk-ec2/vpc.rb', line 96

def load
  resp = @client.describe_vpcs(vpc_ids: [@id])
  @data = resp.vpcs[0]
  self
end

#modify_attribute(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


vpc.modify_attribute({
  enable_dns_hostnames: {
    value: false,
  },
  enable_dns_support: {
    value: false,
  },
})

Parameters:

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

    ({})

Options Hash (options):

  • :enable_dns_hostnames (Types::AttributeBooleanValue)

    Indicates whether the instances launched in the VPC get DNS hostnames. If enabled, instances in the VPC get DNS hostnames; otherwise, they do not.

    You cannot modify the DNS resolution and DNS hostnames attributes in the same request. Use separate requests for each attribute. You can only enable DNS hostnames if you’ve enabled DNS support.

  • :enable_dns_support (Types::AttributeBooleanValue)

    Indicates whether the DNS resolution is supported for the VPC. If enabled, queries to the Amazon provided DNS server at the 169.254.169.253 IP address, or the reserved IP address at the base of the VPC network range “plus two” will succeed. If disabled, the Amazon provided DNS service in the VPC that resolves public DNS hostnames to IP addresses is not enabled.

    You cannot modify the DNS resolution and DNS hostnames attributes in the same request. Use separate requests for each attribute.

Returns:

  • (EmptyStructure)


543
544
545
546
547
# File 'lib/aws-sdk-ec2/vpc.rb', line 543

def modify_attribute(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.modify_vpc_attribute(options)
  resp.data
end

#network_acls(options = {}) ⇒ NetworkAcl::Collection

Examples:

Request syntax with placeholder values


network_acls = vpc.network_acls({
  filters: [
    {
      name: "String",
      values: ["String"],
    },
  ],
  dry_run: false,
  network_acl_ids: ["String"],
})

Parameters:

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

    ({})

Options Hash (options):

  • :filters (Array<Types::Filter>)

    One or more filters.

    • ‘association.association-id` - The ID of an association ID for the ACL.

    • ‘association.network-acl-id` - The ID of the network ACL involved in the association.

    • ‘association.subnet-id` - The ID of the subnet involved in the association.

    • ‘default` - Indicates whether the ACL is the default network ACL for the VPC.

    • ‘entry.cidr` - The IPv4 CIDR range specified in the entry.

    • ‘entry.egress` - Indicates whether the entry applies to egress traffic.

    • ‘entry.icmp.code` - The ICMP code specified in the entry, if any.

    • ‘entry.icmp.type` - The ICMP type specified in the entry, if any.

    • ‘entry.ipv6-cidr` - The IPv6 CIDR range specified in the entry.

    • ‘entry.port-range.from` - The start of the port range specified in the entry.

    • ‘entry.port-range.to` - The end of the port range specified in the entry.

    • ‘entry.protocol` - The protocol specified in the entry (`tcp` | `udp` | `icmp` or a protocol number).

    • ‘entry.rule-action` - Allows or denies the matching traffic (`allow` | `deny`).

    • ‘entry.rule-number` - The number of an entry (in other words, rule) in the ACL’s set of entries.

    • ‘network-acl-id` - The ID of the network ACL.

    • ‘tag`:key=value - The key/value combination of a tag assigned to the resource. Specify the key of the tag in the filter name and the value of the tag in the filter value. For example, for the tag Purpose=X, specify `tag:Purpose` for the filter name and `X` for the filter value.

    • ‘tag-key` - The key of a tag assigned to the resource. This filter is independent of the `tag-value` filter. For example, if you use both the filter “tag-key=Purpose” and the filter “tag-value=X”, you get any resources assigned both the tag key Purpose (regardless of what the tag’s value is), and the tag value X (regardless of what the tag’s key is). If you want to list only resources where Purpose is X, see the ‘tag`:key=value filter.

    • ‘tag-value` - The value of a tag assigned to the resource. This filter is independent of the `tag-key` filter.

    • ‘vpc-id` - The ID of the VPC for the network ACL.

  • :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_acl_ids (Array<String>)

    One or more network ACL IDs.

    Default: Describes all your network ACLs.

Returns:



1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
# File 'lib/aws-sdk-ec2/vpc.rb', line 1147

def network_acls(options = {})
  batches = Enumerator.new do |y|
    batch = []
    options = Aws::Util.deep_merge(options, filters: [{
      name: "vpc-id",
      values: [@id]
    }])
    resp = @client.describe_network_acls(options)
    resp.data.network_acls.each do |n|
      batch << NetworkAcl.new(
        id: n.network_acl_id,
        data: n,
        client: @client
      )
    end
    y.yield(batch)
  end
  NetworkAcl::Collection.new(batches)
end

#network_interfaces(options = {}) ⇒ NetworkInterface::Collection

Examples:

Request syntax with placeholder values


network_interfaces = vpc.network_interfaces({
  filters: [
    {
      name: "String",
      values: ["String"],
    },
  ],
  dry_run: false,
  network_interface_ids: ["String"],
})

Parameters:

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

    ({})

Options Hash (options):

  • :filters (Array<Types::Filter>)

    One or more filters.

    • ‘addresses.private-ip-address` - The private IPv4 addresses associated with the network interface.

    • ‘addresses.primary` - Whether the private IPv4 address is the primary IP address associated with the network interface.

    • ‘addresses.association.public-ip` - The association ID returned when the network interface was associated with the Elastic IP address (IPv4).

    • ‘addresses.association.owner-id` - The owner ID of the addresses associated with the network interface.

    • ‘association.association-id` - The association ID returned when the network interface was associated with an IPv4 address.

    • ‘association.allocation-id` - The allocation ID returned when you allocated the Elastic IP address (IPv4) for your network interface.

    • ‘association.ip-owner-id` - The owner of the Elastic IP address (IPv4) associated with the network interface.

    • ‘association.public-ip` - The address of the Elastic IP address (IPv4) bound to the network interface.

    • ‘association.public-dns-name` - The public DNS name for the network interface (IPv4).

    • ‘attachment.attachment-id` - The ID of the interface attachment.

    • ‘attachment.attach.time` - The time that the network interface was attached to an instance.

    • ‘attachment.delete-on-termination` - Indicates whether the attachment is deleted when an instance is terminated.

    • ‘attachment.device-index` - The device index to which the network interface is attached.

    • ‘attachment.instance-id` - The ID of the instance to which the network interface is attached.

    • ‘attachment.instance-owner-id` - The owner ID of the instance to which the network interface is attached.

    • ‘attachment.nat-gateway-id` - The ID of the NAT gateway to which the network interface is attached.

    • ‘attachment.status` - The status of the attachment (`attaching` | `attached` | `detaching` | `detached`).

    • ‘availability-zone` - The Availability Zone of the network interface.

    • ‘description` - The description of the network interface.

    • ‘group-id` - The ID of a security group associated with the network interface.

    • ‘group-name` - The name of a security group associated with the network interface.

    • ‘ipv6-addresses.ipv6-address` - An IPv6 address associated with the network interface.

    • ‘mac-address` - The MAC address of the network interface.

    • ‘network-interface-id` - The ID of the network interface.

    • ‘owner-id` - The AWS account ID of the network interface owner.

    • ‘private-ip-address` - The private IPv4 address or addresses of the network interface.

    • ‘private-dns-name` - The private DNS name of the network interface (IPv4).

    • ‘requester-id` - The ID of the entity that launched the instance on your behalf (for example, AWS Management Console, Auto Scaling, and so on).

    • ‘requester-managed` - Indicates whether the network interface is being managed by an AWS service (for example, AWS Management Console, Auto Scaling, and so on).

    • ‘source-desk-check` - Indicates whether the network interface performs source/destination checking. A value of `true` means checking is enabled, and `false` means checking is disabled. The value must be `false` for the network interface to perform network address translation (NAT) in your VPC.

    • ‘status` - The status of the network interface. If the network interface is not attached to an instance, the status is `available`; if a network interface is attached to an instance the status is `in-use`.

    • ‘subnet-id` - The ID of the subnet for the network interface.

    • ‘tag`:key=value - The key/value combination of a tag assigned to the resource. Specify the key of the tag in the filter name and the value of the tag in the filter value. For example, for the tag Purpose=X, specify `tag:Purpose` for the filter name and `X` for the filter value.

    • ‘tag-key` - The key of a tag assigned to the resource. This filter is independent of the `tag-value` filter. For example, if you use both the filter “tag-key=Purpose” and the filter “tag-value=X”, you get any resources assigned both the tag key Purpose (regardless of what the tag’s value is), and the tag value X (regardless of what the tag’s key is). If you want to list only resources where Purpose is X, see the ‘tag`:key=value filter.

    • ‘tag-value` - The value of a tag assigned to the resource. This filter is independent of the `tag-key` filter.

    • ‘vpc-id` - The ID of the VPC for the network interface.

  • :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_ids (Array<String>)

    One or more network interface IDs.

    Default: Describes all your network interfaces.

Returns:



1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
# File 'lib/aws-sdk-ec2/vpc.rb', line 1309

def network_interfaces(options = {})
  batches = Enumerator.new do |y|
    batch = []
    options = Aws::Util.deep_merge(options, filters: [{
      name: "vpc-id",
      values: [@id]
    }])
    resp = @client.describe_network_interfaces(options)
    resp.data.network_interfaces.each do |n|
      batch << NetworkInterface.new(
        id: n.network_interface_id,
        data: n,
        client: @client
      )
    end
    y.yield(batch)
  end
  NetworkInterface::Collection.new(batches)
end

#request_vpc_peering_connection(options = {}) ⇒ VpcPeeringConnection

Examples:

Request syntax with placeholder values


vpcpeeringconnection = vpc.request_vpc_peering_connection({
  dry_run: false,
  peer_owner_id: "String",
  peer_vpc_id: "String",
})

Parameters:

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

    ({})

Options Hash (options):

  • :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`.

  • :peer_owner_id (String)

    The AWS account ID of the owner of the peer VPC.

    Default: Your AWS account ID

  • :peer_vpc_id (String)

    The ID of the VPC with which you are creating the VPC peering connection.

Returns:



570
571
572
573
574
575
576
577
578
# File 'lib/aws-sdk-ec2/vpc.rb', line 570

def request_vpc_peering_connection(options = {})
  options = options.merge(vpc_id: @id)
  resp = @client.create_vpc_peering_connection(options)
  VpcPeeringConnection.new(
    id: resp.data.vpc_peering_connection.vpc_peering_connection_id,
    data: resp.data.vpc_peering_connection,
    client: @client
  )
end

#requested_vpc_peering_connections(options = {}) ⇒ VpcPeeringConnection::Collection

Examples:

Request syntax with placeholder values


requested_vpc_peering_connections = vpc.requested_vpc_peering_connections({
  filters: [
    {
      name: "String",
      values: ["String"],
    },
  ],
  dry_run: false,
  vpc_peering_connection_ids: ["String"],
})

Parameters:

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

    ({})

Options Hash (options):

  • :filters (Array<Types::Filter>)

    One or more filters.

    • ‘accepter-vpc-info.cidr-block` - The IPv4 CIDR block of the peer VPC.

    • ‘accepter-vpc-info.owner-id` - The AWS account ID of the owner of the peer VPC.

    • ‘accepter-vpc-info.vpc-id` - The ID of the peer VPC.

    • ‘expiration-time` - The expiration date and time for the VPC peering connection.

    • ‘requester-vpc-info.cidr-block` - The IPv4 CIDR block of the requester’s VPC.

    • ‘requester-vpc-info.owner-id` - The AWS account ID of the owner of the requester VPC.

    • ‘requester-vpc-info.vpc-id` - The ID of the requester VPC.

    • ‘status-code` - The status of the VPC peering connection (`pending-acceptance` | `failed` | `expired` | `provisioning` | `active` | `deleted` | `rejected`).

    • ‘status-message` - A message that provides more information about the status of the VPC peering connection, if applicable.

    • ‘tag`:key=value - The key/value combination of a tag assigned to the resource. Specify the key of the tag in the filter name and the value of the tag in the filter value. For example, for the tag Purpose=X, specify `tag:Purpose` for the filter name and `X` for the filter value.

    • ‘tag-key` - The key of a tag assigned to the resource. This filter is independent of the `tag-value` filter. For example, if you use both the filter “tag-key=Purpose” and the filter “tag-value=X”, you get any resources assigned both the tag key Purpose (regardless of what the tag’s value is), and the tag value X (regardless of what the tag’s key is). If you want to list only resources where Purpose is X, see the ‘tag`:key=value filter.

    • ‘tag-value` - The value of a tag assigned to the resource. This filter is independent of the `tag-key` filter.

    • ‘vpc-peering-connection-id` - The ID of the VPC peering connection.

  • :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`.

  • :vpc_peering_connection_ids (Array<String>)

    One or more VPC peering connection IDs.

    Default: Describes all your VPC peering connections.

Returns:



1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
# File 'lib/aws-sdk-ec2/vpc.rb', line 1399

def requested_vpc_peering_connections(options = {})
  batches = Enumerator.new do |y|
    batch = []
    options = Aws::Util.deep_merge(options, filters: [{
      name: "requester-vpc-info.vpc-id",
      values: [@id]
    }])
    resp = @client.describe_vpc_peering_connections(options)
    resp.data.vpc_peering_connections.each do |v|
      batch << VpcPeeringConnection.new(
        id: v.vpc_peering_connection_id,
        data: v,
        client: @client
      )
    end
    y.yield(batch)
  end
  VpcPeeringConnection::Collection.new(batches)
end

#route_tables(options = {}) ⇒ RouteTable::Collection

Examples:

Request syntax with placeholder values


route_tables = vpc.route_tables({
  filters: [
    {
      name: "String",
      values: ["String"],
    },
  ],
  dry_run: false,
  route_table_ids: ["String"],
})

Parameters:

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

    ({})

Options Hash (options):

  • :filters (Array<Types::Filter>)

    One or more filters.

    • ‘association.route-table-association-id` - The ID of an association ID for the route table.

    • ‘association.route-table-id` - The ID of the route table involved in the association.

    • ‘association.subnet-id` - The ID of the subnet involved in the association.

    • ‘association.main` - Indicates whether the route table is the main route table for the VPC (`true` | `false`). Route tables that do not have an association ID are not returned in the response.

    • ‘route-table-id` - The ID of the route table.

    • ‘route.destination-cidr-block` - The IPv4 CIDR range specified in a route in the table.

    • ‘route.destination-ipv6-cidr-block` - The IPv6 CIDR range specified in a route in the route table.

    • ‘route.destination-prefix-list-id` - The ID (prefix) of the AWS service specified in a route in the table.

    • ‘route.egress-only-internet-gateway-id` - The ID of an egress-only Internet gateway specified in a route in the route table.

    • ‘route.gateway-id` - The ID of a gateway specified in a route in the table.

    • ‘route.instance-id` - The ID of an instance specified in a route in the table.

    • ‘route.nat-gateway-id` - The ID of a NAT gateway.

    • ‘route.origin` - Describes how the route was created. `CreateRouteTable` indicates that the route was automatically created when the route table was created; `CreateRoute` indicates that the route was manually added to the route table; `EnableVgwRoutePropagation` indicates that the route was propagated by route propagation.

    • ‘route.state` - The state of a route in the route table (`active` | `blackhole`). The blackhole state indicates that the route’s target isn’t available (for example, the specified gateway isn’t attached to the VPC, the specified NAT instance has been terminated, and so on).

    • ‘route.vpc-peering-connection-id` - The ID of a VPC peering connection specified in a route in the table.

    • ‘tag`:key=value - The key/value combination of a tag assigned to the resource. Specify the key of the tag in the filter name and the value of the tag in the filter value. For example, for the tag Purpose=X, specify `tag:Purpose` for the filter name and `X` for the filter value.

    • ‘tag-key` - The key of a tag assigned to the resource. This filter is independent of the `tag-value` filter. For example, if you use both the filter “tag-key=Purpose” and the filter “tag-value=X”, you get any resources assigned both the tag key Purpose (regardless of what the tag’s value is), and the tag value X (regardless of what the tag’s key is). If you want to list only resources where Purpose is X, see the ‘tag`:key=value filter.

    • ‘tag-value` - The value of a tag assigned to the resource. This filter is independent of the `tag-key` filter.

    • ‘vpc-id` - The ID of the VPC for the route table.

  • :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`.

  • :route_table_ids (Array<String>)

    One or more route table IDs.

    Default: Describes all your route tables.

Returns:



1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
# File 'lib/aws-sdk-ec2/vpc.rb', line 1514

def route_tables(options = {})
  batches = Enumerator.new do |y|
    batch = []
    options = Aws::Util.deep_merge(options, filters: [{
      name: "vpc-id",
      values: [@id]
    }])
    resp = @client.describe_route_tables(options)
    resp.data.route_tables.each do |r|
      batch << RouteTable.new(
        id: r.route_table_id,
        data: r,
        client: @client
      )
    end
    y.yield(batch)
  end
  RouteTable::Collection.new(batches)
end

#security_groups(options = {}) ⇒ SecurityGroup::Collection

Examples:

Request syntax with placeholder values


security_groups = vpc.security_groups({
  filters: [
    {
      name: "String",
      values: ["String"],
    },
  ],
  group_ids: ["String"],
  group_names: ["String"],
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :filters (Array<Types::Filter>)

    One or more filters. If using multiple filters for rules, the results include security groups for which any combination of rules - not necessarily a single rule - match all filters.

    • ‘description` - The description of the security group.

    • ‘egress.ip-permission.prefix-list-id` - The ID (prefix) of the AWS service to which the security group allows access.

    • ‘group-id` - The ID of the security group.

    • ‘group-name` - The name of the security group.

    • ‘ip-permission.cidr` - An IPv4 CIDR range that has been granted permission in a security group rule.

    • ‘ip-permission.from-port` - The start of port range for the TCP and UDP protocols, or an ICMP type number.

    • ‘ip-permission.group-id` - The ID of a security group that has been granted permission.

    • ‘ip-permission.group-name` - The name of a security group that has been granted permission.

    • ‘ip-permission.ipv6-cidr` - An IPv6 CIDR range that has been granted permission in a security group rule.

    • ‘ip-permission.protocol` - The IP protocol for the permission (`tcp` | `udp` | `icmp` or a protocol number).

    • ‘ip-permission.to-port` - The end of port range for the TCP and UDP protocols, or an ICMP code.

    • ‘ip-permission.user-id` - The ID of an AWS account that has been granted permission.

    • ‘owner-id` - The AWS account ID of the owner of the security group.

    • ‘tag-key` - The key of a tag assigned to the security group.

    • ‘tag-value` - The value of a tag assigned to the security group.

    • ‘vpc-id` - The ID of the VPC specified when the security group was created.

  • :group_ids (Array<String>)

    One or more security group IDs. Required for security groups in a nondefault VPC.

    Default: Describes all your security groups.

  • :group_names (Array<String>)

    [EC2-Classic and default VPC only] One or more security group names. You can specify either the security group name or the security group ID. For security groups in a nondefault VPC, use the ‘group-name` filter to describe security groups by name.

    Default: Describes all your security groups.

  • :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:



1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
# File 'lib/aws-sdk-ec2/vpc.rb', line 1612

def security_groups(options = {})
  batches = Enumerator.new do |y|
    batch = []
    options = Aws::Util.deep_merge(options, filters: [{
      name: "vpc-id",
      values: [@id]
    }])
    resp = @client.describe_security_groups(options)
    resp.data.security_groups.each do |s|
      batch << SecurityGroup.new(
        id: s.group_id,
        data: s,
        client: @client
      )
    end
    y.yield(batch)
  end
  SecurityGroup::Collection.new(batches)
end

#stateString

The current state of the VPC.

Returns:

  • (String)


49
50
51
# File 'lib/aws-sdk-ec2/vpc.rb', line 49

def state
  data.state
end

#subnets(options = {}) ⇒ Subnet::Collection

Examples:

Request syntax with placeholder values


subnets = vpc.subnets({
  filters: [
    {
      name: "String",
      values: ["String"],
    },
  ],
  subnet_ids: ["String"],
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :filters (Array<Types::Filter>)

    One or more filters.

    • ‘availabilityZone` - The Availability Zone for the subnet. You can also use `availability-zone` as the filter name.

    • ‘available-ip-address-count` - The number of IPv4 addresses in the subnet that are available.

    • ‘cidrBlock` - The IPv4 CIDR block of the subnet. The CIDR block you specify must exactly match the subnet’s CIDR block for information to be returned for the subnet. You can also use ‘cidr` or `cidr-block` as the filter names.

    • ‘defaultForAz` - Indicates whether this is the default subnet for the Availability Zone. You can also use `default-for-az` as the filter name.

    • ‘ipv6-cidr-block-association.ipv6-cidr-block` - An IPv6 CIDR block associated with the subnet.

    • ‘ipv6-cidr-block-association.association-id` - An association ID for an IPv6 CIDR block associated with the subnet.

    • ‘ipv6-cidr-block-association.state` - The state of an IPv6 CIDR block associated with the subnet.

    • ‘state` - The state of the subnet (`pending` | `available`).

    • ‘subnet-id` - The ID of the subnet.

    • ‘tag`:key=value - The key/value combination of a tag assigned to the resource. Specify the key of the tag in the filter name and the value of the tag in the filter value. For example, for the tag Purpose=X, specify `tag:Purpose` for the filter name and `X` for the filter value.

    • ‘tag-key` - The key of a tag assigned to the resource. This filter is independent of the `tag-value` filter. For example, if you use both the filter “tag-key=Purpose” and the filter “tag-value=X”, you get any resources assigned both the tag key Purpose (regardless of what the tag’s value is), and the tag value X (regardless of what the tag’s key is). If you want to list only resources where Purpose is X, see the ‘tag`:key=value filter.

    • ‘tag-value` - The value of a tag assigned to the resource. This filter is independent of the `tag-key` filter.

    • ‘vpc-id` - The ID of the VPC for the subnet.

  • :subnet_ids (Array<String>)

    One or more subnet IDs.

    Default: Describes all your subnets.

  • :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:



1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
# File 'lib/aws-sdk-ec2/vpc.rb', line 1704

def subnets(options = {})
  batches = Enumerator.new do |y|
    batch = []
    options = Aws::Util.deep_merge(options, filters: [{
      name: "vpc-id",
      values: [@id]
    }])
    resp = @client.describe_subnets(options)
    resp.data.subnets.each do |s|
      batch << Subnet.new(
        id: s.subnet_id,
        data: s,
        client: @client
      )
    end
    y.yield(batch)
  end
  Subnet::Collection.new(batches)
end

#tagsArray<Types::Tag>

Any tags assigned to the VPC.

Returns:



79
80
81
# File 'lib/aws-sdk-ec2/vpc.rb', line 79

def tags
  data.tags
end

#wait_until_available(options = {}) ⇒ Vpc

Parameters:

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

    ({})

Options Hash (options):

  • :max_attempts (Integer) — default: 40
  • :delay (Float) — default: 15
  • :before_attempt (Proc)
  • :before_wait (Proc)

Returns:



138
139
140
141
142
143
144
145
146
147
# File 'lib/aws-sdk-ec2/vpc.rb', line 138

def wait_until_available(options = {})
  options, params = separate_params_and_options(options)
  waiter = Waiters::VpcAvailable.new(options)
  yield_waiter_and_warn(waiter, &Proc.new) if block_given?
  waiter.wait(params.merge(vpc_ids: [@id]))
  Vpc.new({
    id: @id,
    client: @client
  })
end

#wait_until_exists(options = {}) ⇒ Vpc

Parameters:

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

    ({})

Options Hash (options):

  • :max_attempts (Integer) — default: 5
  • :delay (Float) — default: 1
  • :before_attempt (Proc)
  • :before_wait (Proc)

Returns:



155
156
157
158
159
160
161
162
163
164
# File 'lib/aws-sdk-ec2/vpc.rb', line 155

def wait_until_exists(options = {})
  options, params = separate_params_and_options(options)
  waiter = Waiters::VpcExists.new(options)
  yield_waiter_and_warn(waiter, &Proc.new) if block_given?
  waiter.wait(params.merge(vpc_ids: [@id]))
  Vpc.new({
    id: @id,
    client: @client
  })
end