Skip to content

create_environment

create_environment(
    application_name: ApplicationName,
    *,
    config_overrides: Optional[ElasticBeanstalkClientConfig] = None,
    environment_name: Optional[EnvironmentName] = None,
    group_name: Optional[GroupName] = None,
    description: Optional[Description] = None,
    cname_prefix: Optional[DNSCnamePrefix] = None,
    tier: Optional[EnvironmentTier] = None,
    tags: Optional[Tags] = None,
    version_label: Optional[VersionLabel] = None,
    template_name: Optional[ConfigurationTemplateName] = None,
    solution_stack_name: Optional[SolutionStackName] = None,
    platform_arn: Optional[PlatformArn] = None,
    option_settings: Optional[ConfigurationOptionSettingsList] = None,
    options_to_remove: Optional[OptionsSpecifierList] = None,
    operations_role: Optional[OperationsRole] = None,
) -> EnvironmentDescription

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

Parameters:

  • application_name (ApplicationName) –

    The name of the application that is associated with this environment.

  • environment_name (Optional[EnvironmentName], default: None ) –

    A unique name for the environment.

    Constraint: Must be from 4 to 40 characters in length. The name can contain only letters, numbers, and hyphens. It can't start or end with a hyphen. This name must be unique within a region in your account. If the specified name already exists in the region, Elastic Beanstalk returns an InvalidParameterValue error.

    If you don't specify the CNAMEPrefix parameter, the environment name becomes part of the CNAME, and therefore part of the visible URL for your application.

  • group_name (Optional[GroupName], default: None ) –

    The name of the group to which the target environment belongs. Specify a group name only if the environment's name is specified in an environment manifest and not with the environment name parameter. See Environment Manifest (env.yaml) for details.

  • description (Optional[Description], default: None ) –

    Your description for this environment.

  • cname_prefix (Optional[DNSCnamePrefix], default: None ) –

    If specified, the environment attempts to use this value as the prefix for the CNAME in your Elastic Beanstalk environment URL. If not specified, the CNAME is generated automatically by appending a random alphanumeric string to the environment name.

  • tier (Optional[EnvironmentTier], default: None ) –

    Specifies the tier to use in creating this environment. The environment tier that you choose determines whether Elastic Beanstalk provisions resources on Amazon EC2 instances or on an Amazon EKS cluster, and, for Amazon EC2, whether the environment serves HTTP(S) requests or processes background tasks from a queue.

  • tags (Optional[Tags], default: None ) –

    Specifies the tags applied to resources in the environment.

  • version_label (Optional[VersionLabel], default: None ) –

    The name of the application version to deploy.

    Default: If not specified, Elastic Beanstalk attempts to deploy the sample application.

  • template_name (Optional[ConfigurationTemplateName], default: None ) –

    The name of the Elastic Beanstalk configuration template to use with the environment.

    If you specify TemplateName, then don't specify SolutionStackName.

  • solution_stack_name (Optional[SolutionStackName], default: None ) –

    The name of an Elastic Beanstalk solution stack (platform version) to use with the environment. If specified, Elastic Beanstalk sets the configuration values to the default values associated with the specified solution stack. For a list of current solution stacks, see Elastic Beanstalk Supported Platforms in the Elastic Beanstalk Platforms guide.

    If you specify SolutionStackName, don't specify PlatformArn or TemplateName.

  • platform_arn (Optional[PlatformArn], default: None ) –

    The Amazon Resource Name (ARN) of the custom platform to use with the environment. For more information, see Custom Platforms in the Elastic Beanstalk Developer Guide.

    If you specify PlatformArn, don't specify SolutionStackName.

  • option_settings (Optional[ConfigurationOptionSettingsList], default: None ) –

    If specified, 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.

  • options_to_remove (Optional[OptionsSpecifierList], default: None ) –

    A list of custom user-defined configuration options to remove from the configuration set for this new environment.

  • operations_role (Optional[OperationsRole], default: None ) –

    The operations role feature of Elastic Beanstalk is in beta release and is subject to change.

    The Amazon Resource Name (ARN) of an existing IAM role to be used as the environment's operations role. If specified, Elastic Beanstalk uses the operations role for permissions to downstream services during this call and during subsequent calls acting on this environment. To specify an operations role, you must have the iam:PassRole permission for the role.

Raises:

Examples:

To create a new environment for an application The following operation creates a new environment for version v1 of a java application named my-app:

>>> client.create_environment(application_name='my-app', environment_name='my-env', cname_prefix='my-app', version_label='v1', solution_stack_name='64bit Amazon Linux 2015.03 v2.0.0 running Tomcat 8 Java 8')
Source code in docs_src/capo_elastic_beanstalk/_services/elastic_beanstalk.py
def create_environment(
    self,
    application_name: "capo_elastic_beanstalk.types.application_name.ApplicationName",
    *,
    config_overrides: Optional[ElasticBeanstalkClientConfig] = None,
    environment_name: Optional[
        "capo_elastic_beanstalk.types.environment_name.EnvironmentName"
    ] = None,
    group_name: Optional[
        "capo_elastic_beanstalk.types.group_name.GroupName"
    ] = None,
    description: Optional[
        "capo_elastic_beanstalk.types.description.Description"
    ] = None,
    cname_prefix: Optional[
        "capo_elastic_beanstalk.types.dns_cname_prefix.DNSCnamePrefix"
    ] = None,
    tier: Optional[
        "capo_elastic_beanstalk.types.environment_tier.EnvironmentTier"
    ] = None,
    tags: Optional["capo_elastic_beanstalk.types.tags.Tags"] = None,
    version_label: Optional[
        "capo_elastic_beanstalk.types.version_label.VersionLabel"
    ] = None,
    template_name: Optional[
        "capo_elastic_beanstalk.types.configuration_template_name.ConfigurationTemplateName"
    ] = None,
    solution_stack_name: Optional[
        "capo_elastic_beanstalk.types.solution_stack_name.SolutionStackName"
    ] = None,
    platform_arn: Optional[
        "capo_elastic_beanstalk.types.platform_arn.PlatformArn"
    ] = None,
    option_settings: Optional[
        "capo_elastic_beanstalk.types.configuration_option_settings_list.ConfigurationOptionSettingsList"
    ] = None,
    options_to_remove: Optional[
        "capo_elastic_beanstalk.types.options_specifier_list.OptionsSpecifierList"
    ] = None,
    operations_role: Optional[
        "capo_elastic_beanstalk.types.operations_role.OperationsRole"
    ] = None,
) -> "capo_elastic_beanstalk.types.environment_description.EnvironmentDescription":
    """<p>Launches an Elastic Beanstalk environment for the specified application using the specified configuration.</p>

    Args:
        application_name: <p>The name of the application that is associated with this environment.</p>
        environment_name: <p>A unique name for the environment.</p> <p>Constraint: Must be from 4 to 40 characters in length. The name can contain only letters, numbers, and hyphens. It can't start or end with a hyphen. This name must be unique within a region in your account. If the specified name already exists in the region, Elastic Beanstalk returns an <code>InvalidParameterValue</code> error. </p> <p>If you don't specify the <code>CNAMEPrefix</code> parameter, the environment name becomes part of the CNAME, and therefore part of the visible URL for your application.</p>
        group_name: <p>The name of the group to which the target environment belongs. Specify a group name only if the environment's name is specified in an environment manifest and not with the environment name parameter. See <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-cfg-manifest.html">Environment Manifest (env.yaml)</a> for details.</p>
        description: <p>Your description for this environment.</p>
        cname_prefix: <p>If specified, the environment attempts to use this value as the prefix for the CNAME in your Elastic Beanstalk environment URL. If not specified, the CNAME is generated automatically by appending a random alphanumeric string to the environment name.</p>
        tier: <p>Specifies the tier to use in creating this environment. The environment tier that you choose determines whether Elastic Beanstalk provisions resources on Amazon EC2 instances or on an Amazon EKS cluster, and, for Amazon EC2, whether the environment serves HTTP(S) requests or processes background tasks from a queue.</p>
        tags: <p>Specifies the tags applied to resources in the environment.</p>
        version_label: <p>The name of the application version to deploy.</p> <p>Default: If not specified, Elastic Beanstalk attempts to deploy the sample application.</p>
        template_name: <p>The name of the Elastic Beanstalk configuration template to use with the environment.</p> <note> <p>If you specify <code>TemplateName</code>, then don't specify <code>SolutionStackName</code>.</p> </note>
        solution_stack_name: <p>The name of an Elastic Beanstalk solution stack (platform version) to use with the environment. If specified, Elastic Beanstalk sets the configuration values to the default values associated with the specified solution stack. For a list of current solution stacks, see <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html">Elastic Beanstalk Supported Platforms</a> in the <i>Elastic Beanstalk Platforms</i> guide.</p> <note> <p>If you specify <code>SolutionStackName</code>, don't specify <code>PlatformArn</code> or <code>TemplateName</code>.</p> </note>
        platform_arn: <p>The Amazon Resource Name (ARN) of the custom platform to use with the environment. For more information, see <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/custom-platforms.html">Custom Platforms</a> in the <i>Elastic Beanstalk Developer Guide</i>.</p> <note> <p>If you specify <code>PlatformArn</code>, don't specify <code>SolutionStackName</code>.</p> </note>
        option_settings: <p>If specified, 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.</p>
        options_to_remove: <p>A list of custom user-defined configuration options to remove from the configuration set for this new environment.</p>
        operations_role: <important> <p>The operations role feature of Elastic Beanstalk is in beta release and is subject to change.</p> </important> <p>The Amazon Resource Name (ARN) of an existing IAM role to be used as the environment's operations role. If specified, Elastic Beanstalk uses the operations role for permissions to downstream services during this call and during subsequent calls acting on this environment. To specify an operations role, you must have the <code>iam:PassRole</code> permission for the role.</p>

    Raises:
        capo_elastic_beanstalk.errors.insufficient_privileges_exception.InsufficientPrivilegesException: <p>The specified account does not have sufficient privileges for one or more Amazon Web Services services.</p>
        capo_elastic_beanstalk.errors.too_many_environments_exception.TooManyEnvironmentsException: <p>The specified account has reached its limit of environments.</p>
        capo_elastic_beanstalk.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a new environment for an application
        The following operation creates a new environment for version v1 of a java application named my-app:

        >>> client.create_environment(application_name='my-app', environment_name='my-env', cname_prefix='my-app', version_label='v1', solution_stack_name='64bit Amazon Linux 2015.03 v2.0.0 running Tomcat 8 Java 8')
    """

    def _handler(
        req: "OperationRequest[capo_elastic_beanstalk.types.create_environment_message.CreateEnvironmentMessage]",
    ) -> OperationResponse[
        "capo_elastic_beanstalk.types.environment_description.EnvironmentDescription"
    ]:
        import capo_elastic_beanstalk._operations.aws_elastic_beanstalk_service.create_environment

        output, http_response = (
            capo_elastic_beanstalk._operations.aws_elastic_beanstalk_service.create_environment.create_environment(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateEnvironment")
    )
    input_: capo_elastic_beanstalk.types.create_environment_message.CreateEnvironmentMessage = {
        "application_name": application_name
    }
    if environment_name is not None:
        input_["environment_name"] = environment_name
    if group_name is not None:
        input_["group_name"] = group_name
    if description is not None:
        input_["description"] = description
    if cname_prefix is not None:
        input_["cname_prefix"] = cname_prefix
    if tier is not None:
        input_["tier"] = tier
    if tags is not None:
        input_["tags"] = tags
    if version_label is not None:
        input_["version_label"] = version_label
    if template_name is not None:
        input_["template_name"] = template_name
    if solution_stack_name is not None:
        input_["solution_stack_name"] = solution_stack_name
    if platform_arn is not None:
        input_["platform_arn"] = platform_arn
    if option_settings is not None:
        input_["option_settings"] = option_settings
    if options_to_remove is not None:
        input_["options_to_remove"] = options_to_remove
    if operations_role is not None:
        input_["operations_role"] = operations_role

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output