You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::EC2::Vpc

Inherits:
Resources::Resource show all
Defined in:
(unknown)

Instance Attribute Summary collapse

Attributes inherited from Resources::Resource

#client, #identifiers

Instance Method Summary collapse

Methods inherited from Resources::Resource

add_data_attribute, add_identifier, #data, data_attributes, #data_loaded?, identifiers, #load, #wait_until

Methods included from Resources::OperationMethods

#add_batch_operation, #add_operation, #batch_operation, #batch_operation_names, #batch_operations, #operation, #operation_names, #operations

Constructor Details

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

Overloads:

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

    Parameters:

    • id (String)

    Options Hash (options):

    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

  • #initialize(options = {}) ⇒ Object

    Options Hash (options):

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

      When `:client is not given, the options hash is used to construct a new Client object.

Instance Attribute Details

#cidr_blockString (readonly)

The primary IPv4 CIDR block for the VPC.

Returns:

  • (String)

    The primary IPv4 CIDR block for the VPC.

#cidr_block_association_setArray<Types::VpcCidrBlockAssociation> (readonly)

Information about the IPv4 CIDR blocks associated with the VPC.

Returns:

#dhcp_options_idString (readonly)

The ID of the set of DHCP options you\'ve associated with the VPC.

Returns:

  • (String)

    The ID of the set of DHCP options you\'ve associated with the VPC.

#idString (readonly)

Returns:

  • (String)

#instance_tenancyString (readonly)

The allowed tenancy of instances launched into the VPC.

Possible values:

  • default
  • dedicated
  • host

Returns:

  • (String)

    The allowed tenancy of instances launched into the VPC.

#ipv_6_cidr_block_association_setArray<Types::VpcIpv6CidrBlockAssociation> (readonly)

Information about the IPv6 CIDR blocks associated with the VPC.

Returns:

#is_defaultBoolean (readonly)

Indicates whether the VPC is the default VPC.

Returns:

  • (Boolean)

    Indicates whether the VPC is the default VPC.

#owner_idString (readonly)

The ID of the AWS account that owns the VPC.

Returns:

  • (String)

    The ID of the AWS account that owns the VPC.

#stateString (readonly)

The current state of the VPC.

Possible values:

  • pending
  • available

Returns:

  • (String)

    The current state of the VPC.

#tagsArray<Types::Tag> (readonly)

Any tags assigned to the VPC.

Returns:

  • (Array<Types::Tag>)

    Any tags assigned to the VPC.

#vpc_idString (readonly)

The ID of the VPC.

Returns:

  • (String)

    The ID of the VPC.

Instance Method Details

#accepted_vpc_peering_connections(options = {}) ⇒ Collection<VpcPeeringConnection>

Returns a Collection of Aws::EC2::VpcPeeringConnection resources. No API requests are made until you call an enumerable method on the collection. Client#describe_vpc_peering_connections will be called multiple times until every Aws::EC2::VpcPeeringConnection has been yielded.

Examples:

Request syntax example with placeholder values


vpc.accepted_vpc_peering_connections({
  dry_run: false,
  vpc_peering_connection_ids: ["VpcPeeringConnectionId"],
  next_token: "String",
  max_results: 1,
})

Enumerating Aws::EC2::VpcPeeringConnection resources.

vpc.accepted_vpc_peering_connections.each do |vpcpeeringconnection|
  # yields each vpcpeeringconnection
end

Enumerating Aws::EC2::VpcPeeringConnection resources with a limit.

vpc.accepted_vpc_peering_connections.limit(10).each do |vpcpeeringconnection|
  # yields at most 10 accepted_vpc_peering_connections
end

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.

  • :vpc_peering_connection_ids (Array<String>)

    One or more VPC peering connection IDs.

    Default: Describes all your VPC peering connections.

  • :next_token (String)

    The token for the next page of results.

  • :max_results (Integer)

    The maximum number of results to return with a single call. To retrieve the remaining results, make another call with the returned nextToken value.

Returns:

See Also:

#associate_dhcp_options(options = {}) ⇒ Struct

Associates a set of DHCP options (that you've previously created) with the specified VPC, or associates no DHCP options with the VPC.

After you associate the options with the VPC, any existing instances and all new instances that you launch in that VPC use the options. You don't need to restart or relaunch the instances. They automatically pick up the changes within a few hours, depending on how frequently the instance renews its DHCP lease. You can explicitly renew the lease using the operating system on the instance.

For more information, see DHCP Options Sets in the Amazon Virtual Private Cloud User Guide.

Examples:

Request syntax example with placeholder values


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

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:

  • (Struct)

    Returns an empty response.

See Also:

Links an EC2-Classic instance to a ClassicLink-enabled VPC through one or more of the VPC's security groups. You cannot link an EC2-Classic instance to more than one VPC at a time. You can only link an instance that's in the running state. An instance is automatically unlinked from a VPC when it's stopped - you can link it to the VPC again when you restart it.

After you've linked an instance, you cannot change the VPC security groups that are associated with it. To change the security groups, you must first unlink the instance, and then link it again.

Linking your instance to a VPC is sometimes referred to as attaching your instance.

Examples:

Request syntax example with placeholder values


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

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:

See Also:

#attach_internet_gateway(options = {}) ⇒ Struct

Attaches an internet gateway or a virtual private gateway to a VPC, enabling connectivity between the internet and the VPC. For more information about your VPC and internet gateway, see the Amazon Virtual Private Cloud User Guide.

Examples:

Request syntax example with placeholder values


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

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:

  • (Struct)

    Returns an empty response.

See Also:

#create_network_acl(options = {}) ⇒ NetworkAcl

Examples:

Request syntax example with placeholder values


vpc.create_network_acl({
  dry_run: false,
  tag_specifications: [
    {
      resource_type: "client-vpn-endpoint", # accepts client-vpn-endpoint, customer-gateway, dedicated-host, dhcp-options, egress-only-internet-gateway, elastic-ip, elastic-gpu, export-image-task, export-instance-task, fleet, fpga-image, host-reservation, image, import-image-task, import-snapshot-task, instance, internet-gateway, key-pair, launch-template, local-gateway-route-table-vpc-association, natgateway, network-acl, network-interface, placement-group, reserved-instances, route-table, security-group, snapshot, spot-fleet-request, spot-instances-request, subnet, traffic-mirror-filter, traffic-mirror-session, traffic-mirror-target, transit-gateway, transit-gateway-attachment, transit-gateway-multicast-domain, transit-gateway-route-table, volume, vpc, vpc-peering-connection, vpn-connection, vpn-gateway, vpc-flow-log
      tags: [
        {
          key: "String",
          value: "String",
        },
      ],
    },
  ],
})

Basic usage

networkacl = vpc.create_network_acl(options)
networkacl.id
#=> "networkacl-id"

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.

  • :tag_specifications (Array<Types::TagSpecification>)

    The tags to assign to the network ACL.

Returns:

See Also:

#create_route_table(options = {}) ⇒ RouteTable

Examples:

Request syntax example with placeholder values


vpc.create_route_table({
  dry_run: false,
  tag_specifications: [
    {
      resource_type: "client-vpn-endpoint", # accepts client-vpn-endpoint, customer-gateway, dedicated-host, dhcp-options, egress-only-internet-gateway, elastic-ip, elastic-gpu, export-image-task, export-instance-task, fleet, fpga-image, host-reservation, image, import-image-task, import-snapshot-task, instance, internet-gateway, key-pair, launch-template, local-gateway-route-table-vpc-association, natgateway, network-acl, network-interface, placement-group, reserved-instances, route-table, security-group, snapshot, spot-fleet-request, spot-instances-request, subnet, traffic-mirror-filter, traffic-mirror-session, traffic-mirror-target, transit-gateway, transit-gateway-attachment, transit-gateway-multicast-domain, transit-gateway-route-table, volume, vpc, vpc-peering-connection, vpn-connection, vpn-gateway, vpc-flow-log
      tags: [
        {
          key: "String",
          value: "String",
        },
      ],
    },
  ],
})

Basic usage

routetable = vpc.create_route_table(options)
routetable.id
#=> "routetable-id"

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.

  • :tag_specifications (Array<Types::TagSpecification>)

    The tags to assign to the route table.

Returns:

See Also:

#create_security_group(options = {}) ⇒ SecurityGroup

Examples:

Request syntax example with placeholder values


vpc.create_security_group({
  description: "String", # required
  group_name: "String", # required
  tag_specifications: [
    {
      resource_type: "client-vpn-endpoint", # accepts client-vpn-endpoint, customer-gateway, dedicated-host, dhcp-options, egress-only-internet-gateway, elastic-ip, elastic-gpu, export-image-task, export-instance-task, fleet, fpga-image, host-reservation, image, import-image-task, import-snapshot-task, instance, internet-gateway, key-pair, launch-template, local-gateway-route-table-vpc-association, natgateway, network-acl, network-interface, placement-group, reserved-instances, route-table, security-group, snapshot, spot-fleet-request, spot-instances-request, subnet, traffic-mirror-filter, traffic-mirror-session, traffic-mirror-target, transit-gateway, transit-gateway-attachment, transit-gateway-multicast-domain, transit-gateway-route-table, volume, vpc, vpc-peering-connection, vpn-connection, vpn-gateway, vpc-flow-log
      tags: [
        {
          key: "String",
          value: "String",
        },
      ],
    },
  ],
  dry_run: false,
})

Basic usage

securitygroup = vpc.create_security_group(options)
securitygroup.id
#=> "securitygroup-id"

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 ._-:/()#,@[]+=&;{}!$*

  • :group_name (required, String)

    The name of the security group.

    Constraints: Up to 255 characters in length. Cannot start with sg-.

    Constraints for EC2-Classic: ASCII characters

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

  • :tag_specifications (Array<Types::TagSpecification>)

    The tags to assign to the security group.

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

See Also:

#create_subnet(options = {}) ⇒ Subnet

Examples:

Request syntax example with placeholder values


vpc.create_subnet({
  tag_specifications: [
    {
      resource_type: "client-vpn-endpoint", # accepts client-vpn-endpoint, customer-gateway, dedicated-host, dhcp-options, egress-only-internet-gateway, elastic-ip, elastic-gpu, export-image-task, export-instance-task, fleet, fpga-image, host-reservation, image, import-image-task, import-snapshot-task, instance, internet-gateway, key-pair, launch-template, local-gateway-route-table-vpc-association, natgateway, network-acl, network-interface, placement-group, reserved-instances, route-table, security-group, snapshot, spot-fleet-request, spot-instances-request, subnet, traffic-mirror-filter, traffic-mirror-session, traffic-mirror-target, transit-gateway, transit-gateway-attachment, transit-gateway-multicast-domain, transit-gateway-route-table, volume, vpc, vpc-peering-connection, vpn-connection, vpn-gateway, vpc-flow-log
      tags: [
        {
          key: "String",
          value: "String",
        },
      ],
    },
  ],
  availability_zone: "String",
  availability_zone_id: "String",
  cidr_block: "String", # required
  ipv_6_cidr_block: "String",
  outpost_arn: "String",
  dry_run: false,
})

Basic usage

subnet = vpc.create_subnet(options)
subnet.id
#=> "subnet-id"

Options Hash (options):

  • :tag_specifications (Array<Types::TagSpecification>)

    The tags to assign to the subnet.

  • :availability_zone (String)

    The Availability Zone or Local Zone for the subnet.

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

    To create a subnet in a Local Zone, set this value to the Local Zone ID, for example us-west-2-lax-1a. For information about the Regions that support Local Zones, see Available Regions in the Amazon Elastic Compute Cloud User Guide.

    To create a subnet in an Outpost, set this value to the Availability Zone for the Outpost and specify the Outpost ARN.

  • :availability_zone_id (String)

    The AZ ID or the Local Zone ID of the subnet.

  • :cidr_block (required, String)

    The IPv4 network range for the subnet, in CIDR notation. For example, 10.0.0.0/24. We modify the specified CIDR block to its canonical form; for example, if you specify 100.68.0.18/18, we modify it to 100.68.0.0/18.

  • :ipv_6_cidr_block (String)

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

  • :outpost_arn (String)

    The Amazon Resource Name (ARN) of the Outpost. If you specify an Outpost ARN, you must also specify the Availability Zone of the Outpost subnet.

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

See Also:

#create_tags(options = {}) ⇒ Array<Tag>

Examples:

Request syntax example with placeholder values


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

Basic usage

tags = vpc.create_tags(options)
tags.map(&:value)
#=> ["tag-value", ...]

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

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

See Also:

#delete(options = {}) ⇒ Struct

Deletes the specified VPC. You must detach or delete all gateways and resources that are associated with the VPC before you can delete it. For example, you must terminate all instances running in the VPC, delete all security groups associated with the VPC (except the default one), delete all route tables associated with the VPC (except the default one), and so on.

Examples:

Request syntax example with placeholder values


vpc.delete({
  dry_run: false,
})

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:

  • (Struct)

    Returns an empty response.

See Also:

#delete_tags(options = {}) ⇒ Array<Tag>

Examples:

Request syntax example with placeholder values


vpc.delete_tags({
  dry_run: false,
  tags: [
    {
      key: "String",
      value: "String",
    },
  ],
})

Basic usage

tags = vpc.delete_tags(options)
tags.map(&:value)
#=> ["tag-value", ...]

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 (Array<Types::Tag>)

    The tags to delete. Specify a tag key and an optional tag value to delete specific tags. If you specify a tag key without a tag value, we delete any tag with this key regardless of its value. If you specify a tag key with an empty string as the tag value, we delete the tag only if its value is an empty string.

    If you omit this parameter, we delete all user-defined tags for the specified resources. We do not delete AWS-generated tags (tags that have the aws: prefix).

Returns:

See Also:

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

Describes the specified attribute of the specified VPC. You can specify only one attribute at a time.

Examples:

Request syntax example with placeholder values


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

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:

See Also:

Unlinks (detaches) a linked EC2-Classic instance from a VPC. After the instance has been unlinked, the VPC security groups are no longer associated with it. An instance is automatically unlinked from a VPC when it's stopped.

Examples:

Request syntax example with placeholder values


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

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:

See Also:

#detach_internet_gateway(options = {}) ⇒ Struct

Detaches an internet gateway from a VPC, disabling connectivity between the internet and the VPC. The VPC must not contain any running instances with Elastic IP addresses or public IPv4 addresses.

Examples:

Request syntax example with placeholder values


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

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:

  • (Struct)

    Returns an empty response.

See Also:

#dhcp_optionsDhcpOptions?

Returns:

Disables ClassicLink for a VPC. You cannot disable ClassicLink for a VPC that has EC2-Classic instances linked to it.

Examples:

Request syntax example with placeholder values


vpc.disable_classic_link({
  dry_run: false,
})

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:

See Also:

Enables a VPC for ClassicLink. You can then link EC2-Classic instances to your ClassicLink-enabled VPC to allow communication over private IP addresses. You cannot enable your VPC for ClassicLink if any of your VPC route tables have existing routes for address ranges within the 10.0.0.0/8 IP address range, excluding local routes for VPCs in the 10.0.0.0/16 and 10.1.0.0/16 IP address ranges. For more information, see ClassicLink in the Amazon Elastic Compute Cloud User Guide.

Examples:

Request syntax example with placeholder values


vpc.enable_classic_link({
  dry_run: false,
})

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:

See Also:

#exists?Boolean

Returns true if this Vpc exists. Returns false otherwise.

Returns:

  • (Boolean)

    Returns true if this Vpc exists. Returns false otherwise.

#instances(options = {}) ⇒ Collection<Instance>

Returns a Collection of Instance resources. No API requests are made until you call an enumerable method on the collection. Client#describe_instances will be called multiple times until every Instance has been yielded.

Examples:

Request syntax example with placeholder values


vpc.instances({
  instance_ids: ["InstanceId"],
  dry_run: false,
  max_results: 1,
  next_token: "String",
})

Enumerating Instance resources.

vpc.instances.each do |instance|
  # yields each instance
end

Enumerating Instance resources with a limit.

vpc.instances.limit(10).each do |instance|
  # yields at most 10 instances
end

Batch operations callable on the returned collection


# calls Client#create_tags on each batch
vpc.instances.batch_create_tags

# calls Client#delete_tags on each batch
vpc.instances.batch_delete_tags!

# calls Client#monitor_instances on each batch
vpc.instances.batch_monitor

# calls Client#reboot_instances on each batch
vpc.instances.batch_reboot

# calls Client#start_instances on each batch
vpc.instances.batch_start

# calls Client#stop_instances on each batch
vpc.instances.batch_stop

# calls Client#terminate_instances on each batch
vpc.instances.batch_terminate!

# calls Client#unmonitor_instances on each batch
vpc.instances.batch_unmonitor

Options Hash (options):

  • :instance_ids (Array<String>)

    The 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.

  • :max_results (Integer)

    The maximum number of results to return in a single call. To retrieve the remaining results, make another call with the returned NextToken value. This value can be between 5 and 1000. You cannot specify this parameter and the instance IDs parameter in the same call.

  • :next_token (String)

    The token to request the next page of results.

Returns:

See Also:

#internet_gateways(options = {}) ⇒ Collection<InternetGateway>

Returns a Collection of InternetGateway resources. No API requests are made until you call an enumerable method on the collection. Client#describe_internet_gateways will be called multiple times until every InternetGateway has been yielded.

Examples:

Request syntax example with placeholder values


vpc.internet_gateways({
  dry_run: false,
  internet_gateway_ids: ["InternetGatewayId"],
  next_token: "String",
  max_results: 1,
})

Enumerating InternetGateway resources.

vpc.internet_gateways.each do |internetgateway|
  # yields each internetgateway
end

Enumerating InternetGateway resources with a limit.

vpc.internet_gateways.limit(10).each do |internetgateway|
  # yields at most 10 internet_gateways
end

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

    One or more internet gateway IDs.

    Default: Describes all your internet gateways.

  • :next_token (String)

    The token for the next page of results.

  • :max_results (Integer)

    The maximum number of results to return with a single call. To retrieve the remaining results, make another call with the returned nextToken value.

Returns:

See Also:

#modify_attribute(options = {}) ⇒ Struct

Modifies the specified attribute of the specified VPC.

Examples:

Request syntax example with placeholder values


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

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\" 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:

  • (Struct)

    Returns an empty response.

See Also:

#network_acls(options = {}) ⇒ Collection<NetworkAcl>

Returns a Collection of NetworkAcl resources. No API requests are made until you call an enumerable method on the collection. Client#describe_network_acls will be called multiple times until every NetworkAcl has been yielded.

Examples:

Request syntax example with placeholder values


vpc.network_acls({
  dry_run: false,
  network_acl_ids: ["NetworkAclId"],
  next_token: "String",
  max_results: 1,
})

Enumerating NetworkAcl resources.

vpc.network_acls.each do |networkacl|
  # yields each networkacl
end

Enumerating NetworkAcl resources with a limit.

vpc.network_acls.limit(10).each do |networkacl|
  # yields at most 10 network_acls
end

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.

  • :network_acl_ids (Array<String>)

    One or more network ACL IDs.

    Default: Describes all your network ACLs.

  • :next_token (String)

    The token for the next page of results.

  • :max_results (Integer)

    The maximum number of results to return with a single call. To retrieve the remaining results, make another call with the returned nextToken value.

Returns:

See Also:

#network_interfaces(options = {}) ⇒ Collection<NetworkInterface>

Returns a Collection of NetworkInterface resources. No API requests are made until you call an enumerable method on the collection. Client#describe_network_interfaces will be called multiple times until every NetworkInterface has been yielded.

Examples:

Request syntax example with placeholder values


vpc.network_interfaces({
  dry_run: false,
  network_interface_ids: ["NetworkInterfaceId"],
  next_token: "String",
  max_results: 1,
})

Enumerating NetworkInterface resources.

vpc.network_interfaces.each do |networkinterface|
  # yields each networkinterface
end

Enumerating NetworkInterface resources with a limit.

vpc.network_interfaces.limit(10).each do |networkinterface|
  # yields at most 10 network_interfaces
end

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.

  • :network_interface_ids (Array<String>)

    One or more network interface IDs.

    Default: Describes all your network interfaces.

  • :next_token (String)

    The token to retrieve the next page of results.

  • :max_results (Integer)

    The maximum number of items to return for this request. The request returns a token that you can specify in a subsequent call to get the next set of results. You cannot specify this parameter and the network interface IDs parameter in the same request.

Returns:

See Also:

#request_vpc_peering_connection(options = {}) ⇒ VpcPeeringConnection

Examples:

Request syntax example with placeholder values


vpc.request_vpc_peering_connection({
  dry_run: false,
  peer_owner_id: "String",
  peer_vpc_id: "String",
  peer_region: "String",
  tag_specifications: [
    {
      resource_type: "client-vpn-endpoint", # accepts client-vpn-endpoint, customer-gateway, dedicated-host, dhcp-options, egress-only-internet-gateway, elastic-ip, elastic-gpu, export-image-task, export-instance-task, fleet, fpga-image, host-reservation, image, import-image-task, import-snapshot-task, instance, internet-gateway, key-pair, launch-template, local-gateway-route-table-vpc-association, natgateway, network-acl, network-interface, placement-group, reserved-instances, route-table, security-group, snapshot, spot-fleet-request, spot-instances-request, subnet, traffic-mirror-filter, traffic-mirror-session, traffic-mirror-target, transit-gateway, transit-gateway-attachment, transit-gateway-multicast-domain, transit-gateway-route-table, volume, vpc, vpc-peering-connection, vpn-connection, vpn-gateway, vpc-flow-log
      tags: [
        {
          key: "String",
          value: "String",
        },
      ],
    },
  ],
})

Basic usage

vpcpeeringconnection = vpc.request_vpc_peering_connection(options)
vpcpeeringconnection.id
#=> "vpcpeeringconnection-id"

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 accepter VPC.

    Default: Your AWS account ID

  • :peer_vpc_id (String)

    The ID of the VPC with which you are creating the VPC peering connection. You must specify this parameter in the request.

  • :peer_region (String)

    The Region code for the accepter VPC, if the accepter VPC is located in a Region other than the Region in which you make the request.

    Default: The Region in which you make the request.

  • :tag_specifications (Array<Types::TagSpecification>)

    The tags to assign to the peering connection.

Returns:

See Also:

#requested_vpc_peering_connections(options = {}) ⇒ Collection<VpcPeeringConnection>

Returns a Collection of Aws::EC2::VpcPeeringConnection resources. No API requests are made until you call an enumerable method on the collection. Client#describe_vpc_peering_connections will be called multiple times until every Aws::EC2::VpcPeeringConnection has been yielded.

Examples:

Request syntax example with placeholder values


vpc.requested_vpc_peering_connections({
  dry_run: false,
  vpc_peering_connection_ids: ["VpcPeeringConnectionId"],
  next_token: "String",
  max_results: 1,
})

Enumerating Aws::EC2::VpcPeeringConnection resources.

vpc.requested_vpc_peering_connections.each do |vpcpeeringconnection|
  # yields each vpcpeeringconnection
end

Enumerating Aws::EC2::VpcPeeringConnection resources with a limit.

vpc.requested_vpc_peering_connections.limit(10).each do |vpcpeeringconnection|
  # yields at most 10 requested_vpc_peering_connections
end

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.

  • :vpc_peering_connection_ids (Array<String>)

    One or more VPC peering connection IDs.

    Default: Describes all your VPC peering connections.

  • :next_token (String)

    The token for the next page of results.

  • :max_results (Integer)

    The maximum number of results to return with a single call. To retrieve the remaining results, make another call with the returned nextToken value.

Returns:

See Also:

#route_tables(options = {}) ⇒ Collection<RouteTable>

Returns a Collection of RouteTable resources. No API requests are made until you call an enumerable method on the collection. Client#describe_route_tables will be called multiple times until every RouteTable has been yielded.

Examples:

Request syntax example with placeholder values


vpc.route_tables({
  dry_run: false,
  route_table_ids: ["RouteTableId"],
  next_token: "String",
  max_results: 1,
})

Enumerating RouteTable resources.

vpc.route_tables.each do |routetable|
  # yields each routetable
end

Enumerating RouteTable resources with a limit.

vpc.route_tables.limit(10).each do |routetable|
  # yields at most 10 route_tables
end

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.

  • :route_table_ids (Array<String>)

    One or more route table IDs.

    Default: Describes all your route tables.

  • :next_token (String)

    The token for the next page of results.

  • :max_results (Integer)

    The maximum number of results to return with a single call. To retrieve the remaining results, make another call with the returned nextToken value.

Returns:

See Also:

#security_groups(options = {}) ⇒ Collection<SecurityGroup>

Returns a Collection of SecurityGroup resources. No API requests are made until you call an enumerable method on the collection. Client#describe_security_groups will be called multiple times until every SecurityGroup has been yielded.

Examples:

Request syntax example with placeholder values


vpc.security_groups({
  group_ids: ["String"],
  group_names: ["SecurityGroupName"],
  dry_run: false,
  next_token: "String",
  max_results: 1,
})

Enumerating SecurityGroup resources.

vpc.security_groups.each do |securitygroup|
  # yields each securitygroup
end

Enumerating SecurityGroup resources with a limit.

vpc.security_groups.limit(10).each do |securitygroup|
  # yields at most 10 security_groups
end

Options Hash (options):

  • :group_ids (Array<String>)

    The IDs of the security groups. Required for security groups in a nondefault VPC.

    Default: Describes all your security groups.

  • :group_names (Array<String>)

    [EC2-Classic and default VPC only] The names of the security groups. 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.

  • :next_token (String)

    The token to request the next page of results.

  • :max_results (Integer)

    The maximum number of results to return in a single call. To retrieve the remaining results, make another request with the returned NextToken value. This value can be between 5 and 1000. If this parameter is not specified, then all results are returned.

Returns:

See Also:

#subnets(options = {}) ⇒ Collection<Subnet>

Returns a Collection of Subnet resources. No API requests are made until you call an enumerable method on the collection. Client#describe_subnets will be called multiple times until every Subnet has been yielded.

Examples:

Request syntax example with placeholder values


vpc.subnets({
  subnet_ids: ["SubnetId"],
  dry_run: false,
  next_token: "String",
  max_results: 1,
})

Enumerating Subnet resources.

vpc.subnets.each do |subnet|
  # yields each subnet
end

Enumerating Subnet resources with a limit.

vpc.subnets.limit(10).each do |subnet|
  # yields at most 10 subnets
end

Options Hash (options):

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

  • :next_token (String)

    The token for the next page of results.

  • :max_results (Integer)

    The maximum number of results to return with a single call. To retrieve the remaining results, make another call with the returned nextToken value.

Returns:

See Also:

#wait_until_available {|waiter| ... } ⇒ Vpc

Waits until this Vpc is available. This method waits by polling Client#describe_vpcs until successful. An error is raised after a configurable number of failed checks.

This waiter uses the following defaults:

Configuration Default
#delay 15
#max_attempts 40

You can modify defaults and register callbacks by passing a block argument.

Examples:

Basic usage

vpc.wait_until_available

Yield Parameters:

Returns:

  • (Vpc)

    Returns a copy of this Vpc that is not loaded.

Raises:

See Also:

#wait_until_exists {|waiter| ... } ⇒ Vpc

Waits until this Vpc is exists. This method waits by polling Client#describe_vpcs until successful. An error is raised after a configurable number of failed checks.

This waiter uses the following defaults:

Configuration Default
#delay 1
#max_attempts 5

You can modify defaults and register callbacks by passing a block argument.

Examples:

Basic usage

vpc.wait_until_exists

Yield Parameters:

Returns:

  • (Vpc)

    Returns a copy of this Vpc that is not loaded.

Raises:

See Also: