Skip to content

delete_config_rule

delete_config_rule(
    config_rule_name: ConfigRuleName,
    *,
    config_overrides: Optional[ConfigServiceClientConfig] = None,
) -> None

Deletes the specified Config rule and all of its evaluation results.

Config sets the state of a rule to DELETING until the deletion is complete. You cannot update a rule while it is in this state. If you make a PutConfigRule or DeleteConfigRule request for the rule, you will receive a ResourceInUseException.

You can check the state of a rule by using the DescribeConfigRules request.

Recommendation: Consider excluding the AWS::Config::ResourceCompliance resource type from recording before deleting rules

Deleting rules creates configuration items (CIs) for AWS::Config::ResourceCompliance that can affect your costs for the configuration recorder. If you are deleting rules which evaluate a large number of resource types, this can lead to a spike in the number of CIs recorded.

To avoid the associated costs, you can opt to disable recording for the AWS::Config::ResourceCompliance resource type before deleting rules, and re-enable recording after the rules have been deleted.

However, since deleting rules is an asynchronous process, it might take an hour or more to complete. During the time when recording is disabled for AWS::Config::ResourceCompliance, rule evaluations will not be recorded in the associated resource’s history.

Parameters:

  • config_rule_name (ConfigRuleName) –

    The name of the Config rule that you want to delete.

Raises:

  • NoSuchConfigRuleException –

    The Config rule in the request is not valid. Verify that the rule is an Config Process Check rule, that the rule name is correct, and that valid Amazon Resouce Names (ARNs) are used before trying again.

  • ResourceInUseException –

    You see this exception in the following cases:

    • For DeleteConfigRule, Config is deleting this rule. Try your request again later.

    • For DeleteConfigRule, the rule is deleting your evaluation results. Try your request again later.

    • For DeleteConfigRule, a remediation action is associated with the rule and Config cannot delete this rule. Delete the remediation action associated with the rule before deleting the rule and try your request again later.

    • For PutConfigOrganizationRule, organization Config rule deletion is in progress. Try your request again later.

    • For DeleteOrganizationConfigRule, organization Config rule creation is in progress. Try your request again later.

    • For PutConformancePack and PutOrganizationConformancePack, a conformance pack creation, update, and deletion is in progress. Try your request again later.

    • For DeleteConformancePack, a conformance pack creation, update, and deletion is in progress. Try your request again later.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_config_service/_services/config_service.py
def delete_config_rule(
    self,
    config_rule_name: "capo_config_service.types.config_rule_name.ConfigRuleName",
    *,
    config_overrides: Optional[ConfigServiceClientConfig] = None,
) -> None:
    """<p>Deletes the specified Config rule and all of its evaluation results.</p> <p>Config sets the state of a rule to <code>DELETING</code> until the deletion is complete. You cannot update a rule while it is in this state. If you make a <code>PutConfigRule</code> or <code>DeleteConfigRule</code> request for the rule, you will receive a <code>ResourceInUseException</code>.</p> <p>You can check the state of a rule by using the <code>DescribeConfigRules</code> request.</p> <note> <p> <b>Recommendation: Consider excluding the <code>AWS::Config::ResourceCompliance</code> resource type from recording before deleting rules</b> </p> <p>Deleting rules creates configuration items (CIs) for <code>AWS::Config::ResourceCompliance</code> that can affect your costs for the configuration recorder. If you are deleting rules which evaluate a large number of resource types, this can lead to a spike in the number of CIs recorded.</p> <p>To avoid the associated costs, you can opt to disable recording for the <code>AWS::Config::ResourceCompliance</code> resource type before deleting rules, and re-enable recording after the rules have been deleted.</p> <p>However, since deleting rules is an asynchronous process, it might take an hour or more to complete. During the time when recording is disabled for <code>AWS::Config::ResourceCompliance</code>, rule evaluations will not be recorded in the associated resource’s history.</p> </note>

    Args:
        config_rule_name: <p>The name of the Config rule that you want to delete.</p>

    Raises:
        capo_config_service.errors.no_such_config_rule_exception.NoSuchConfigRuleException: <p>The Config rule in the request is not valid. Verify that the rule is an Config Process Check rule, that the rule name is correct, and that valid Amazon Resouce Names (ARNs) are used before trying again.</p>
        capo_config_service.errors.resource_in_use_exception.ResourceInUseException: <p>You see this exception in the following cases: </p> <ul> <li> <p>For DeleteConfigRule, Config is deleting this rule. Try your request again later.</p> </li> <li> <p>For DeleteConfigRule, the rule is deleting your evaluation results. Try your request again later.</p> </li> <li> <p>For DeleteConfigRule, a remediation action is associated with the rule and Config cannot delete this rule. Delete the remediation action associated with the rule before deleting the rule and try your request again later.</p> </li> <li> <p>For PutConfigOrganizationRule, organization Config rule deletion is in progress. Try your request again later.</p> </li> <li> <p>For DeleteOrganizationConfigRule, organization Config rule creation is in progress. Try your request again later.</p> </li> <li> <p>For PutConformancePack and PutOrganizationConformancePack, a conformance pack creation, update, and deletion is in progress. Try your request again later.</p> </li> <li> <p>For DeleteConformancePack, a conformance pack creation, update, and deletion is in progress. Try your request again later.</p> </li> </ul>
        capo_config_service.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_config_service.types.delete_config_rule_request.DeleteConfigRuleRequest]",
    ) -> OperationResponse[None]:
        import capo_config_service._operations.starling_dove_service.delete_config_rule

        output, http_response = (
            capo_config_service._operations.starling_dove_service.delete_config_rule.delete_config_rule(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteConfigRule")
    )
    input_: capo_config_service.types.delete_config_rule_request.DeleteConfigRuleRequest = {
        "config_rule_name": config_rule_name
    }

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