create_launch_configuration ( $launch_configuration_name, $image_id, $instance_type, $opt )

Creates a new launch configuration. The launch configuration name must be unique within the scope of the client’s AWS account. The maximum limit of launch configurations, which by default is 100, must not yet have been met; otherwise, the call will fail. When created, the new launch configuration is available for immediate use.

You can create a launch configuration with Amazon EC2 security groups or with Amazon VPC security groups. However, you can’t use Amazon EC2 security groups together with Amazon VPC security groups, or vice versa.

At this time, Auto Scaling launch configurations don’t support compressed (e.g. zipped) user data files.

Access

public

Parameters

Parameter

Type

Required

Description

$launch_configuration_name

string

Required

The name of the launch configuration to create. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]

$image_id

string

Required

Unique ID of the Amazon Machine Image (AMI) which was assigned during registration. For more information about Amazon EC2 images, please see Amazon EC2 product documentation. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]

$instance_type

string

Required

The instance type of the Amazon EC2 instance. For more information about Amazon EC2 instance types, please see Amazon EC2 product documentation [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]

$opt

array

Optional

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

  • KeyName - string - Optional - The name of the Amazon EC2 key pair. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]
  • SecurityGroups - string|array - Optional - The names of the security groups with which to associate Amazon EC2 or Amazon VPC instances. Specify Amazon EC2 security groups using security group names, such as websrv. Specify Amazon VPC security groups using security group IDs, such as sg-12345678. For more information about Amazon EC2 security groups, go to Using Security Groups in the Amazon EC2 product documentation. For more information about Amazon VPC security groups, go to Security Groups in the Amazon VPC product documentation. Pass a string for a single value, or an indexed array for multiple values.
  • UserData - string - Optional - The user data available to the launched Amazon EC2 instances. For more information about Amazon EC2 user data, please see Amazon EC2 product documentation. [Constraints: The value must be between 0 and 21847 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]
  • KernelId - string - Optional - The ID of the kernel associated with the Amazon EC2 AMI. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]
  • RamdiskId - string - Optional - The ID of the RAM disk associated with the Amazon EC2 AMI. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]
  • BlockDeviceMappings - array - Optional - A list of mappings that specify how block devices are exposed to the instance. Each mapping is made up of a VirtualName, a DeviceName, and an ebs data structure that contains information about the associated Elastic Block Storage volume. For more information about Amazon EC2 BlockDeviceMappings, go to Block Device Mapping in the Amazon EC2 product documentation.
    • x - array - Optional - This represents a simple array index.
      • VirtualName - string - Optional - The virtual name associated with the device. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]
      • DeviceName - string - Required - The name of the device within Amazon EC2. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]
      • Ebs - array - Optional - The Elastic Block Storage volume information.
        • x - array - Optional - This represents a simple array index.
          • SnapshotId - string - Optional - The snapshot ID. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]
          • VolumeSize - integer - Optional - The volume size, in gigabytes.
  • InstanceMonitoring - array - Optional - Enables detailed monitoring, which is enabled by default. When detailed monitoring is enabled, CloudWatch will generate metrics every minute and your account will be charged a fee. When you disable detailed monitoring, by specifying False, Cloudwatch will generate metrics every 5 minutes. For information about monitoring, see the Amazon CloudWatch product page.
    • x - array - Optional - This represents a simple array index.
      • Enabled - boolean - Optional - If True, instance monitoring is enabled.
  • SpotPrice - string - Optional - The maximum hourly price to be paid for any Spot Instance launched to fulfill the request. Spot Instances are launched when the price you specify exceeds the current Spot market price. For more information on launching Spot Instances, go to Using Auto Scaling to Launch Spot Instances in the Auto Scaling Developer Guide.
  • IamInstanceProfile - string - Optional - The name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance. For information on launching EC2 instances with an IAM role, go to Launching Auto Scaling Instances With an IAM Role in the Auto Scaling Developer Guide. [Constraints: The value must be between 1 and 1600 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]
  • EbsOptimized - boolean - Optional -
  • 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 auto scaling launch configuration.

// Instantiate the class
$as = new AmazonAS();

// Using a micro instance running the 64-bit, EBS-backed Amazon Linux AMI.
$response = $as->create_launch_configuration('my-launch-config', 'ami-38c33651', 't1.micro', array(
	'KeyName' => 'my-keypair',
	'SecurityGroups' => 'default'
));

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

Related Methods

Source

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

public function create_launch_configuration($launch_configuration_name, $image_id, $instance_type, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['LaunchConfigurationName'] = $launch_configuration_name;
    $opt['ImageId'] = $image_id;
    $opt['InstanceType'] = $instance_type;
    
    // Optional list (non-map)
    if (isset($opt['SecurityGroups']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'SecurityGroups' => (is_array($opt['SecurityGroups']) ? $opt['SecurityGroups'] : array($opt['SecurityGroups']))
        ), 'member'));
        unset($opt['SecurityGroups']);
    }
    
    // Optional list + map
    if (isset($opt['BlockDeviceMappings']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'BlockDeviceMappings' => $opt['BlockDeviceMappings']
        ), 'member'));
        unset($opt['BlockDeviceMappings']);
    }
    
    // Optional map (non-list)
    if (isset($opt['InstanceMonitoring']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'InstanceMonitoring' => $opt['InstanceMonitoring']
        ), 'member'));
        unset($opt['InstanceMonitoring']);
    }

    return $this->authenticate('CreateLaunchConfiguration', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback