Skip to content

update_environment

update_environment(
    *,
    config_overrides: Optional[ElasticBeanstalkClientConfig] = None,
    application_name: Optional[ApplicationName] = None,
    environment_id: Optional[EnvironmentId] = None,
    environment_name: Optional[EnvironmentName] = None,
    group_name: Optional[GroupName] = None,
    description: Optional[Description] = None,
    tier: Optional[EnvironmentTier] = 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,
) -> EnvironmentDescription

Updates the environment description, deploys a new application version, updates the configuration settings to an entirely new configuration template, or updates select configuration option values in the running environment.

Attempting to update both the release and configuration is not allowed and Elastic Beanstalk returns an InvalidParameterCombination error.

When updating the configuration settings to a new template or individual settings, a draft configuration is created and DescribeConfigurationSettings for this environment returns two setting descriptions with different DeploymentStatus values.

Parameters:

  • application_name (Optional[ApplicationName], default: None ) –

    The name of the application with which the environment is associated.

  • environment_id (Optional[EnvironmentId], default: None ) –

    The ID of the environment to update.

    If no environment with this ID exists, Elastic Beanstalk returns an InvalidParameterValue error.

    Condition: You must specify either this or an EnvironmentName, or both. If you do not specify either, Elastic Beanstalk returns MissingRequiredParameter error.

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

    The name of the environment to update. If no environment with this name exists, Elastic Beanstalk returns an InvalidParameterValue error.

    Condition: You must specify either this or an EnvironmentId, or both. If you do not specify either, Elastic Beanstalk returns MissingRequiredParameter error.

  • 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 or environment ID parameters. See Environment Manifest (env.yaml) for details.

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

    If this parameter is specified, Elastic Beanstalk updates the description of this environment.

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

    This specifies the tier to use to update the environment.

    Condition: At this time, if you change the tier version, name, or type, Elastic Beanstalk returns InvalidParameterValue error.

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

    If this parameter is specified, Elastic Beanstalk deploys the named application version to the environment. If no such application version is found, returns an InvalidParameterValue error.

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

    If this parameter is specified, Elastic Beanstalk deploys this configuration template to the environment. If no such configuration template is found, Elastic Beanstalk returns an InvalidParameterValue error.

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

    This specifies the platform version that the environment will run after the environment is updated.

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

    The ARN of the platform, if used.

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

    If specified, Elastic Beanstalk updates the configuration set associated with the running environment and sets the specified configuration options to the requested value.

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

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

Raises:

Examples:

To configure option settings The following operation configures several options in the aws:elb:loadbalancer namespace:

>>> client.update_environment(environment_name='my-env', option_settings=[{'Namespace': 'aws:elb:healthcheck', 'OptionName': 'Interval', 'Value': '15'}, {'Namespace': 'aws:elb:healthcheck', 'OptionName': 'Timeout', 'Value': '8'}, {'Namespace': 'aws:elb:healthcheck', 'OptionName': 'HealthyThreshold', 'Value': '2'}, {'Namespace': 'aws:elb:healthcheck', 'OptionName': 'UnhealthyThreshold', 'Value': '3'}])
To update an environment to a new version
The following operation updates an environment named "my-env" to version "v2" of the application to which it belongs:
>>> client.update_environment(environment_name='my-env', version_label='v2')
Source code in docs_src/capo_elastic_beanstalk/_services/elastic_beanstalk.py
def update_environment(
    self,
    *,
    config_overrides: Optional[ElasticBeanstalkClientConfig] = None,
    application_name: Optional[
        "capo_elastic_beanstalk.types.application_name.ApplicationName"
    ] = None,
    environment_id: Optional[
        "capo_elastic_beanstalk.types.environment_id.EnvironmentId"
    ] = 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,
    tier: Optional[
        "capo_elastic_beanstalk.types.environment_tier.EnvironmentTier"
    ] = 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,
) -> "capo_elastic_beanstalk.types.environment_description.EnvironmentDescription":
    """<p>Updates the environment description, deploys a new application version, updates the configuration settings to an entirely new configuration template, or updates select configuration option values in the running environment.</p> <p> Attempting to update both the release and configuration is not allowed and Elastic Beanstalk returns an <code>InvalidParameterCombination</code> error. </p> <p> When updating the configuration settings to a new template or individual settings, a draft configuration is created and <a>DescribeConfigurationSettings</a> for this environment returns two setting descriptions with different <code>DeploymentStatus</code> values. </p>

    Args:
        application_name: <p>The name of the application with which the environment is associated.</p>
        environment_id: <p>The ID of the environment to update.</p> <p>If no environment with this ID exists, Elastic Beanstalk returns an <code>InvalidParameterValue</code> error.</p> <p>Condition: You must specify either this or an EnvironmentName, or both. If you do not specify either, Elastic Beanstalk returns <code>MissingRequiredParameter</code> error. </p>
        environment_name: <p>The name of the environment to update. If no environment with this name exists, Elastic Beanstalk returns an <code>InvalidParameterValue</code> error. </p> <p>Condition: You must specify either this or an EnvironmentId, or both. If you do not specify either, Elastic Beanstalk returns <code>MissingRequiredParameter</code> error. </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 or environment ID parameters. 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>If this parameter is specified, Elastic Beanstalk updates the description of this environment.</p>
        tier: <p>This specifies the tier to use to update the environment.</p> <p>Condition: At this time, if you change the tier version, name, or type, Elastic Beanstalk returns <code>InvalidParameterValue</code> error. </p>
        version_label: <p>If this parameter is specified, Elastic Beanstalk deploys the named application version to the environment. If no such application version is found, returns an <code>InvalidParameterValue</code> error. </p>
        template_name: <p>If this parameter is specified, Elastic Beanstalk deploys this configuration template to the environment. If no such configuration template is found, Elastic Beanstalk returns an <code>InvalidParameterValue</code> error. </p>
        solution_stack_name: <p>This specifies the platform version that the environment will run after the environment is updated.</p>
        platform_arn: <p>The ARN of the platform, if used.</p>
        option_settings: <p>If specified, Elastic Beanstalk updates the configuration set associated with the running environment and sets the specified configuration options to the requested value.</p>
        options_to_remove: <p>A list of custom user-defined configuration options to remove from the configuration set for this environment.</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_buckets_exception.TooManyBucketsException: <p>The specified account has reached its limit of Amazon S3 buckets.</p>
        capo_elastic_beanstalk.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To configure option settings
        The following operation configures several options in the aws:elb:loadbalancer namespace:

        >>> client.update_environment(environment_name='my-env', option_settings=[{'Namespace': 'aws:elb:healthcheck', 'OptionName': 'Interval', 'Value': '15'}, {'Namespace': 'aws:elb:healthcheck', 'OptionName': 'Timeout', 'Value': '8'}, {'Namespace': 'aws:elb:healthcheck', 'OptionName': 'HealthyThreshold', 'Value': '2'}, {'Namespace': 'aws:elb:healthcheck', 'OptionName': 'UnhealthyThreshold', 'Value': '3'}])
        To update an environment to a new version
        The following operation updates an environment named "my-env" to version "v2" of the application to which it belongs:

        >>> client.update_environment(environment_name='my-env', version_label='v2')
    """

    def _handler(
        req: "OperationRequest[capo_elastic_beanstalk.types.update_environment_message.UpdateEnvironmentMessage]",
    ) -> OperationResponse[
        "capo_elastic_beanstalk.types.environment_description.EnvironmentDescription"
    ]:
        import capo_elastic_beanstalk._operations.aws_elastic_beanstalk_service.update_environment

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateEnvironment")
    )
    input_: capo_elastic_beanstalk.types.update_environment_message.UpdateEnvironmentMessage = {}
    if application_name is not None:
        input_["application_name"] = application_name
    if environment_id is not None:
        input_["environment_id"] = environment_id
    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 tier is not None:
        input_["tier"] = tier
    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

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