Skip to content

create_safety_rule

create_safety_rule(
    *,
    config_overrides: Optional[Route53RecoveryControlConfigClientConfig] = None,
    assertion_rule: Optional[NewAssertionRule] = None,
    client_token: Optional[__stringMin1Max64PatternS] = None,
    gating_rule: Optional[NewGatingRule] = None,
    tags: Optional[__mapOf__stringMin0Max256PatternS] = None,
) -> CreateSafetyRuleResponse

Creates a safety rule in a control panel. Safety rules let you add safeguards around changing routing control states, and for enabling and disabling routing controls, to help prevent unexpected outcomes.

There are two types of safety rules: assertion rules and gating rules.

Assertion rule: An assertion rule enforces that, when you change a routing control state, that a certain criteria is met. For example, the criteria might be that at least one routing control state is On after the transaction so that traffic continues to flow to at least one cell for the application. This ensures that you avoid a fail-open scenario.

Gating rule: A gating rule lets you configure a gating routing control as an overall "on/off" switch for a group of routing controls. Or, you can configure more complex gating scenarios, for example by configuring multiple gating routing controls.

For more information, see Safety rules in the Amazon Route 53 Application Recovery Controller Developer Guide.

Parameters:

Raises:

  • InternalServerException –

    500 response - InternalServiceError. Temporary service error. Retry the request.

  • ValidationException –

    400 response - Multiple causes. For example, you might have a malformed query string and input parameter might be out of range, or you might have used parameters together incorrectly.

  • UnknownServiceError –

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

Source code in docs_src/capo_route53_recovery_control_config/_services/route53_recovery_control_config.py
def create_safety_rule(
    self,
    *,
    config_overrides: Optional[Route53RecoveryControlConfigClientConfig] = None,
    assertion_rule: Optional[
        "capo_route53_recovery_control_config.types.new_assertion_rule.NewAssertionRule"
    ] = None,
    client_token: Optional[
        "capo_route53_recovery_control_config.types.__string_min1_max64_pattern_s.__stringMin1Max64PatternS"
    ] = None,
    gating_rule: Optional[
        "capo_route53_recovery_control_config.types.new_gating_rule.NewGatingRule"
    ] = None,
    tags: Optional[
        "capo_route53_recovery_control_config.types.__map_of__string_min0_max256_pattern_s.__mapOf__stringMin0Max256PatternS"
    ] = None,
) -> "capo_route53_recovery_control_config.types.create_safety_rule_response.CreateSafetyRuleResponse":
    """<p>Creates a safety rule in a control panel. Safety rules let you add safeguards around changing routing control states, and for enabling and disabling routing controls, to help prevent unexpected outcomes.</p> <p>There are two types of safety rules: assertion rules and gating rules.</p> <p>Assertion rule: An assertion rule enforces that, when you change a routing control state, that a certain criteria is met. For example, the criteria might be that at least one routing control state is On after the transaction so that traffic continues to flow to at least one cell for the application. This ensures that you avoid a fail-open scenario.</p> <p>Gating rule: A gating rule lets you configure a gating routing control as an overall "on/off" switch for a group of routing controls. Or, you can configure more complex gating scenarios, for example by configuring multiple gating routing controls.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/r53recovery/latest/dg/routing-control.safety-rules.html">Safety rules</a> in the Amazon Route 53 Application Recovery Controller Developer Guide.</p>

    Args:
        assertion_rule: <p>The assertion rule requested.</p>
        client_token: <p>A unique, case-sensitive string of up to 64 ASCII characters. To make an idempotent API request with an action, specify a client token in the request.</p>
        gating_rule: <p>The gating rule requested.</p>
        tags: <p>The tags associated with the safety rule.</p>

    Raises:
        capo_route53_recovery_control_config.errors.internal_server_exception.InternalServerException: <p>500 response - InternalServiceError. Temporary service error. Retry the request.</p>
        capo_route53_recovery_control_config.errors.validation_exception.ValidationException: <p>400 response - Multiple causes. For example, you might have a malformed query string and input parameter might be out of range, or you might have used parameters together incorrectly.</p>
        capo_route53_recovery_control_config.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_route53_recovery_control_config.types.create_safety_rule_request.CreateSafetyRuleRequest]",
    ) -> OperationResponse[
        "capo_route53_recovery_control_config.types.create_safety_rule_response.CreateSafetyRuleResponse"
    ]:
        import capo_route53_recovery_control_config._operations.route53_recovery_control_config.create_safety_rule

        output, http_response = (
            capo_route53_recovery_control_config._operations.route53_recovery_control_config.create_safety_rule.create_safety_rule(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSafetyRule")
    )
    input_: capo_route53_recovery_control_config.types.create_safety_rule_request.CreateSafetyRuleRequest = {}
    if assertion_rule is not None:
        input_["assertion_rule"] = assertion_rule
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if gating_rule is not None:
        input_["gating_rule"] = gating_rule
    if tags is not None:
        input_["tags"] = tags

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