Skip to content

delete_environment

delete_environment(
    environment_id: Name,
    application_id: Name,
    *,
    config_overrides: Optional[AppConfigClientConfig] = None,
    deletion_protection_check: Optional[DeletionProtectionCheck] = None,
) -> None

Deletes an environment.

To prevent users from unintentionally deleting actively-used environments, enable deletion protection.

Parameters:

  • environment_id (Name) –

    The ID of the environment that you want to delete.

  • application_id (Name) –

    The application ID that includes the environment that you want to delete.

  • deletion_protection_check (Optional[DeletionProtectionCheck], default: None ) –

    A parameter to configure deletion protection. Deletion protection prevents a user from deleting an environment if your application called either GetLatestConfiguration or in the environment during the specified interval.

    This parameter supports the following values:

    • BYPASS: Instructs AppConfig to bypass the deletion protection check and delete a configuration profile even if deletion protection would have otherwise prevented it.

    • APPLY: Instructs the deletion protection check to run, even if deletion protection is disabled at the account level. APPLY also forces the deletion protection check to run against resources created in the past hour, which are normally excluded from deletion protection checks.

    • ACCOUNT_DEFAULT: The default setting, which instructs AppConfig to implement the deletion protection value specified in the UpdateAccountSettings API.

Raises:

Examples:

To delete an environment The following delete-environment example deletes the specified application environment.

>>> client.delete_environment(application_id='339ohji', environment_id='54j1r29')
Source code in docs_src/capo_appconfig/_services/app_config.py
def delete_environment(
    self,
    environment_id: "capo_appconfig.types.name.Name",
    application_id: "capo_appconfig.types.name.Name",
    *,
    config_overrides: Optional[AppConfigClientConfig] = None,
    deletion_protection_check: Optional[
        "capo_appconfig.types.deletion_protection_check.DeletionProtectionCheck"
    ] = None,
) -> None:
    """<p>Deletes an environment.</p> <p>To prevent users from unintentionally deleting actively-used environments, enable <a href="https://docs.aws.amazon.com/appconfig/latest/userguide/deletion-protection.html">deletion protection</a>.</p>

    Args:
        environment_id: <p>The ID of the environment that you want to delete.</p>
        application_id: <p>The application ID that includes the environment that you want to delete.</p>
        deletion_protection_check: <p>A parameter to configure deletion protection. Deletion protection prevents a user from deleting an environment if your application called either <a href="https://docs.aws.amazon.com/appconfig/2019-10-09/APIReference/API_appconfigdata_GetLatestConfiguration.html">GetLatestConfiguration</a> or in the environment during the specified interval. </p> <p>This parameter supports the following values:</p> <ul> <li> <p> <code>BYPASS</code>: Instructs AppConfig to bypass the deletion protection check and delete a configuration profile even if deletion protection would have otherwise prevented it. </p> </li> <li> <p> <code>APPLY</code>: Instructs the deletion protection check to run, even if deletion protection is disabled at the account level. <code>APPLY</code> also forces the deletion protection check to run against resources created in the past hour, which are normally excluded from deletion protection checks.</p> </li> <li> <p> <code>ACCOUNT_DEFAULT</code>: The default setting, which instructs AppConfig to implement the deletion protection value specified in the <code>UpdateAccountSettings</code> API.</p> </li> </ul>

    Raises:
        capo_appconfig.errors.bad_request_exception.BadRequestException: <p>The input fails to satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_appconfig.errors.conflict_exception.ConflictException: <p>The request could not be processed because of conflict in the current state of the resource.</p>
        capo_appconfig.errors.internal_server_exception.InternalServerException: <p>There was an internal failure in the AppConfig service.</p>
        capo_appconfig.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource could not be found.</p>
        capo_appconfig.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To delete an environment
        The following delete-environment example deletes the specified application environment.

        >>> client.delete_environment(application_id='339ohji', environment_id='54j1r29')
    """

    def _handler(
        req: "OperationRequest[capo_appconfig.types.delete_environment_request.DeleteEnvironmentRequest]",
    ) -> OperationResponse[None]:
        import capo_appconfig._operations.amazon_app_config.delete_environment

        output, http_response = (
            capo_appconfig._operations.amazon_app_config.delete_environment.delete_environment(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteEnvironment")
    )
    input_: capo_appconfig.types.delete_environment_request.DeleteEnvironmentRequest = {
        "environment_id": environment_id,
        "application_id": application_id,
    }
    if deletion_protection_check is not None:
        input_["deletion_protection_check"] = deletion_protection_check

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