create_environment ( $application_name, $environment_name, $opt )

Launches an environment for the specified application using the specified configuration.

Access

public

Parameters

Parameter

Type

Required

Description

$application_name

string

Required

The name of the application that contains the version to be deployed. If no application is found with this name, CreateEnvironment returns an InvalidParameterValue error.

$environment_name

string

Required

A unique name for the deployment environment. Used in the application URL. Constraint: Must be from 4 to 23 characters in length. The name can contain only letters, numbers, and hyphens. It cannot start or end with a hyphen. This name must be unique in your account. If the specified name already exists, AWS Elastic Beanstalk returns an InvalidParameterValue error. Default: If the CNAME parameter is not specified, the environment name becomes part of the CNAME, and therefore part of the visible URL for your application.

$opt

array

Optional

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

  • VersionLabel - string - Optional - The name of the application version to deploy. If the specified application has no associated application versions, AWS Elastic Beanstalk UpdateEnvironment returns an InvalidParameterValue error. Default: If not specified, AWS Elastic Beanstalk attempts to launch the most recently created application version.
  • TemplateName - string - Optional - The name of the configuration template to use in deployment. If no configuration template is found with this name, AWS Elastic Beanstalk returns an InvalidParameterValue error. Condition: You must specify either this parameter or a SolutionStackName, but not both. If you specify both, AWS Elastic Beanstalk returns an InvalidParameterCombination error. If you do not specify either, AWS Elastic Beanstalk returns a MissingRequiredParameter error.
  • SolutionStackName - string - Optional - This is an alternative to specifying a configuration name. If specified, AWS Elastic Beanstalk sets the configuration values to the default values associated with the specified solution stack. Condition: You must specify either this or a TemplateName, but not both. If you specify both, AWS Elastic Beanstalk returns an InvalidParameterCombination error. If you do not specify either, AWS Elastic Beanstalk returns a MissingRequiredParameter error.
  • CNAMEPrefix - string - Optional - If specified, the environment attempts to use this value as the prefix for the CNAME. If not specified, the environment uses the environment name.
  • Description - string - Optional - Describes this environment.
  • OptionSettings - array - Optional - If specified, AWS Elastic Beanstalk sets the specified configuration options to the requested value in the configuration set for the new environment. These override the values obtained from the solution stack or the configuration template.
    • x - array - Optional - This represents a simple array index.
      • Namespace - string - Optional - A unique namespace identifying the option’s associated AWS resource.
      • OptionName - string - Optional - The name of the configuration option.
      • Value - string - Optional - The current value for the configuration option.
  • OptionsToRemove - array - Optional - A list of custom user-defined configuration options to remove from the configuration set for this new environment.
    • x - array - Optional - This represents a simple array index.
      • Namespace - string - Optional - A unique namespace identifying the option’s associated AWS resource.
      • OptionName - string - Optional - The name of the configuration option.
  • 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

Creates a new running environment.

// Instantiate the class
$bean = new AmazonElasticBeanstalk();

// Check that preferred DNS is available
$dns = $bean->check_dns_availability('my-app');

if ((string) $dns->body->CheckDNSAvailabilityResult->Available === 'true')
{
	$response = $bean->create_environment('my-application', 'my-environment', array(
		'VersionLabel' => '1.0',
		'TemplateName' => 'my-template',
		'CNAMEPrefix' => 'my-app',
		'Description' => 'This is the production environment.'
	));

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

Related Methods

Source

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

public function create_environment($application_name, $environment_name, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['ApplicationName'] = $application_name;
    $opt['EnvironmentName'] = $environment_name;
    
    // Optional list + map
    if (isset($opt['OptionSettings']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'OptionSettings' => $opt['OptionSettings']
        ), 'member'));
        unset($opt['OptionSettings']);
    }
    
    // Optional list + map
    if (isset($opt['OptionsToRemove']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'OptionsToRemove' => $opt['OptionsToRemove']
        ), 'member'));
        unset($opt['OptionsToRemove']);
    }

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

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback