Skip to content

terminate_environment

terminate_environment(
    *,
    config_overrides: Optional[ElasticBeanstalkClientConfig] = None,
    environment_id: Optional[EnvironmentId] = None,
    environment_name: Optional[EnvironmentName] = None,
    terminate_resources: Optional[TerminateEnvironmentResources] = None,
    force_terminate: Optional[ForceTerminate] = None,
) -> EnvironmentDescription

Terminates the specified environment.

Parameters:

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

    The ID of the environment to terminate.

    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 terminate.

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

  • terminate_resources (Optional[TerminateEnvironmentResources], default: None ) –

    Indicates whether the associated Amazon Web Services resources should shut down when the environment is terminated:

    • true: The specified environment as well as the associated Amazon Web Services resources, such as Auto Scaling group and LoadBalancer, are terminated.

    • false: Elastic Beanstalk resource management is removed from the environment, but the Amazon Web Services resources continue to operate.

    For more information, see the Elastic Beanstalk User Guide.

    Default: true

    Valid Values: true | false

  • force_terminate (Optional[ForceTerminate], default: None ) –

    Terminates the target environment even if another environment in the same group is dependent on it.

Raises:

Examples:

To terminate an environment The following operation terminates an Elastic Beanstalk environment named my-env:

>>> client.terminate_environment(environment_name='my-env')
Source code in docs_src/capo_elastic_beanstalk/_services/elastic_beanstalk.py
def terminate_environment(
    self,
    *,
    config_overrides: Optional[ElasticBeanstalkClientConfig] = None,
    environment_id: Optional[
        "capo_elastic_beanstalk.types.environment_id.EnvironmentId"
    ] = None,
    environment_name: Optional[
        "capo_elastic_beanstalk.types.environment_name.EnvironmentName"
    ] = None,
    terminate_resources: Optional[
        "capo_elastic_beanstalk.types.terminate_environment_resources.TerminateEnvironmentResources"
    ] = None,
    force_terminate: Optional[
        "capo_elastic_beanstalk.types.force_terminate.ForceTerminate"
    ] = None,
) -> "capo_elastic_beanstalk.types.environment_description.EnvironmentDescription":
    """<p>Terminates the specified environment.</p>

    Args:
        environment_id: <p>The ID of the environment to terminate.</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 terminate.</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>
        terminate_resources: <p>Indicates whether the associated Amazon Web Services resources should shut down when the environment is terminated:</p> <ul> <li> <p> <code>true</code>: The specified environment as well as the associated Amazon Web Services resources, such as Auto Scaling group and LoadBalancer, are terminated.</p> </li> <li> <p> <code>false</code>: Elastic Beanstalk resource management is removed from the environment, but the Amazon Web Services resources continue to operate.</p> </li> </ul> <p> For more information, see the <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/ug/"> Elastic Beanstalk User Guide. </a> </p> <p> Default: <code>true</code> </p> <p> Valid Values: <code>true</code> | <code>false</code> </p>
        force_terminate: <p>Terminates the target environment even if another environment in the same group is dependent on it.</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.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To terminate an environment
        The following operation terminates an Elastic Beanstalk environment named my-env:

        >>> client.terminate_environment(environment_name='my-env')
    """

    def _handler(
        req: "OperationRequest[capo_elastic_beanstalk.types.terminate_environment_message.TerminateEnvironmentMessage]",
    ) -> OperationResponse[
        "capo_elastic_beanstalk.types.environment_description.EnvironmentDescription"
    ]:
        import capo_elastic_beanstalk._operations.aws_elastic_beanstalk_service.terminate_environment

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TerminateEnvironment")
    )
    input_: capo_elastic_beanstalk.types.terminate_environment_message.TerminateEnvironmentMessage = {}
    if environment_id is not None:
        input_["environment_id"] = environment_id
    if environment_name is not None:
        input_["environment_name"] = environment_name
    if terminate_resources is not None:
        input_["terminate_resources"] = terminate_resources
    if force_terminate is not None:
        input_["force_terminate"] = force_terminate

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