Scalr\Service\Aws\Ec2\V20140615\Ec2Api::createSubnet PHP Method

createSubnet() public method

Creates a subnet in an existing VPC. You can create up to 20 subnets in a VPC. If you add more than one subnet to a VPC, they're set up in a star topology with a logical router in the middle.
public createSubnet ( string $vpcId, string $cidrBlock, string $availabilityZone = null ) : Scalr\Service\Aws\Ec2\DataType\SubnetData
$vpcId string The ID of the VPC.
$cidrBlock string The CIDR block for the subnet to cover (for example, 10.0.0.0/24).
$availabilityZone string optional The Availability Zone for the subnet. By default AWS selects a zone for you (recommended)
return Scalr\Service\Aws\Ec2\DataType\SubnetData Returns the SubnetData on success.
    public function createSubnet($vpcId, $cidrBlock, $availabilityZone = null)
    {
        $result = null;
        $options = array('VpcId' => (string) $vpcId, 'CidrBlock' => (string) $cidrBlock);
        if ($availabilityZone !== null) {
            $options['AvailabilityZone'] = (string) $availabilityZone;
        }
        $response = $this->client->call(ucfirst(__FUNCTION__), $options);
        if ($response->getError() === false) {
            $sxml = simplexml_load_string($response->getRawContent());
            $result = $this->_loadSubnetData($sxml->subnet);
        }
        return $result;
    }
Ec2Api