create_vpc ( $cidr_block, $opt )

Creates a VPC with the CIDR block you specify. The smallest VPC you can create uses a /28 netmask (16 IP addresses), and the largest uses a /18 netmask (16,384 IP addresses). To help you decide how big to make your VPC, go to the topic about creating VPCs in the Amazon Virtual Private Cloud Developer Guide.

By default, each instance you launch in the VPC has the default DHCP options (the standard EC2 host name, no domain name, no DNS server, no NTP server, and no NetBIOS server or node type).

Access

public

Parameters

Parameter

Type

Required

Description

$cidr_block

string

Required

A valid CIDR block.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • InstanceTenancy - string - Optional - The allowed tenancy of instances launched into the VPC. A value of default means instances can be launched with any tenancy; a value of dedicated means instances must be launched with tenancy as dedicated.
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Create a new virtual private cloud.

Here is the flow:

  1. Create a new VPC with create_vpc() and a CIDR block.
  2. Create a new Route Table with create_route_table().
  3. Create a new Internet Gateway with create_internet_gateway().
  4. Attach the Internet Gateway to the VPC with attach_internet_gateway().
  5. Create a new Route with create_route().
$ec2 = new AmazonEC2();

$response = $ec2->create_vpc('10.0.0.0/20');

var_dump($response->isOK());
Result:
bool(true)

Related Methods

Source

Method defined in services/ec2.class.php | Toggle source view (7 lines) | View on GitHub

public function create_vpc($cidr_block, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['CidrBlock'] = $cidr_block;
    
    return $this->authenticate('CreateVpc', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback