Skip to content

create_resiliency_policy

create_resiliency_policy(
    policy_name: EntityName,
    tier: ResiliencyPolicyTier,
    policy: DisruptionPolicy,
    *,
    config_overrides: Optional[resiliencehubClientConfig] = None,
    policy_description: Optional[EntityDescription] = None,
    data_location_constraint: Optional[DataLocationConstraint] = None,
    client_token: Optional[ClientToken] = None,
    tags: Optional[TagMap] = None,
) -> CreateResiliencyPolicyResponse

Creates a resiliency policy for an application.

Resilience Hub allows you to provide a value of zero for rtoInSecs and rpoInSecs of your resiliency policy. But, while assessing your application, the lowest possible assessment result is near zero. Hence, if you provide value zero for rtoInSecs and rpoInSecs, the estimated workload RTO and estimated workload RPO result will be near zero and the Compliance status for your application will be set to Policy breached.

Parameters:

  • policy_name (EntityName) –

    Name of the resiliency policy.

  • policy_description (Optional[EntityDescription], default: None ) –

    Description of the resiliency policy.

  • data_location_constraint (Optional[DataLocationConstraint], default: None ) –

    Specifies a high-level geographical location constraint for where your resilience policy data can be stored.

  • tier (ResiliencyPolicyTier) –

    The tier for this resiliency policy, ranging from the highest severity (MissionCritical) to lowest (NonCritical).

  • policy (DisruptionPolicy) –

    The type of resiliency policy to be created, including the recovery time objective (RTO) and recovery point objective (RPO) in seconds.

  • client_token (Optional[ClientToken], default: None ) –

    Used for an idempotency token. A client token is a unique, case-sensitive string of up to 64 ASCII characters. You should not reuse the same client token for other API requests.

  • tags (Optional[TagMap], default: None ) –

    Tags assigned to the resource. A tag is a label that you assign to an Amazon Web Services resource. Each tag consists of a key/value pair.

Raises:

  • AccessDeniedException –

    You don't have permissions to perform the requested operation. The user or role that is making the request must have at least one IAM permissions policy attached that grants the required permissions.

  • ConflictException –

    This exception occurs when a conflict with a previous successful write is detected. This generally occurs when the previous write did not have time to propagate to the host serving the current request. A retry (with appropriate backoff logic) is the recommended response to this exception.

  • InternalServerException –

    This exception occurs when there is an internal failure in the Resilience Hub service.

  • ServiceQuotaExceededException –

    This exception occurs when you have exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use Service Quotas to request a service quota increase.

  • ThrottlingException –

    This exception occurs when you have exceeded the limit on the number of requests per second.

  • ValidationException –

    This exception occurs when a request is not valid.

  • UnknownServiceError –

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

Source code in docs_src/capo_resiliencehub/_services/resiliencehub.py
def create_resiliency_policy(
    self,
    policy_name: "capo_resiliencehub.types.entity_name.EntityName",
    tier: "capo_resiliencehub.types.resiliency_policy_tier.ResiliencyPolicyTier",
    policy: "capo_resiliencehub.types.disruption_policy.DisruptionPolicy",
    *,
    config_overrides: Optional[resiliencehubClientConfig] = None,
    policy_description: Optional[
        "capo_resiliencehub.types.entity_description.EntityDescription"
    ] = None,
    data_location_constraint: Optional[
        "capo_resiliencehub.types.data_location_constraint.DataLocationConstraint"
    ] = None,
    client_token: Optional[
        "capo_resiliencehub.types.client_token.ClientToken"
    ] = None,
    tags: Optional["capo_resiliencehub.types.tag_map.TagMap"] = None,
) -> "capo_resiliencehub.types.create_resiliency_policy_response.CreateResiliencyPolicyResponse":
    """<p>Creates a resiliency policy for an application.</p> <note> <p>Resilience Hub allows you to provide a value of zero for <code>rtoInSecs</code> and <code>rpoInSecs</code> of your resiliency policy. But, while assessing your application, the lowest possible assessment result is near zero. Hence, if you provide value zero for <code>rtoInSecs</code> and <code>rpoInSecs</code>, the estimated workload RTO and estimated workload RPO result will be near zero and the <b>Compliance status</b> for your application will be set to <b>Policy breached</b>.</p> </note>

    Args:
        policy_name: <p>Name of the resiliency policy.</p>
        policy_description: <p>Description of the resiliency policy.</p>
        data_location_constraint: <p>Specifies a high-level geographical location constraint for where your resilience policy data can be stored.</p>
        tier: <p>The tier for this resiliency policy, ranging from the highest severity (<code>MissionCritical</code>) to lowest (<code>NonCritical</code>).</p>
        policy: <p>The type of resiliency policy to be created, including the recovery time objective (RTO) and recovery point objective (RPO) in seconds.</p>
        client_token: <p>Used for an idempotency token. A client token is a unique, case-sensitive string of up to 64 ASCII characters. You should not reuse the same client token for other API requests.</p>
        tags: <p>Tags assigned to the resource. A tag is a label that you assign to an Amazon Web Services resource. Each tag consists of a key/value pair.</p>

    Raises:
        capo_resiliencehub.errors.access_denied_exception.AccessDeniedException: <p>You don't have permissions to perform the requested operation. The user or role that is making the request must have at least one IAM permissions policy attached that grants the required permissions.</p>
        capo_resiliencehub.errors.conflict_exception.ConflictException: <p>This exception occurs when a conflict with a previous successful write is detected. This generally occurs when the previous write did not have time to propagate to the host serving the current request. A retry (with appropriate backoff logic) is the recommended response to this exception.</p>
        capo_resiliencehub.errors.internal_server_exception.InternalServerException: <p>This exception occurs when there is an internal failure in the Resilience Hub service.</p>
        capo_resiliencehub.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>This exception occurs when you have exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use Service Quotas to request a service quota increase.</p>
        capo_resiliencehub.errors.throttling_exception.ThrottlingException: <p>This exception occurs when you have exceeded the limit on the number of requests per second.</p>
        capo_resiliencehub.errors.validation_exception.ValidationException: <p>This exception occurs when a request is not valid.</p>
        capo_resiliencehub.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_resiliencehub.types.create_resiliency_policy_request.CreateResiliencyPolicyRequest]",
    ) -> OperationResponse[
        "capo_resiliencehub.types.create_resiliency_policy_response.CreateResiliencyPolicyResponse"
    ]:
        import capo_resiliencehub._operations.aws_resilience_hub.create_resiliency_policy

        output, http_response = (
            capo_resiliencehub._operations.aws_resilience_hub.create_resiliency_policy.create_resiliency_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_resiliencehub.types.create_resiliency_policy_request.CreateResiliencyPolicyRequest",
    ) -> dict[str, Any]:
        import capo_resiliencehub.types.create_resiliency_policy_request

        return capo_resiliencehub.types.create_resiliency_policy_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_resiliencehub.types.create_resiliency_policy_response.CreateResiliencyPolicyResponse",
    ) -> dict[str, Any]:
        import capo_resiliencehub.types.create_resiliency_policy_response

        return capo_resiliencehub.types.create_resiliency_policy_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateResiliencyPolicy",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_resiliencehub.types.create_resiliency_policy_request.CreateResiliencyPolicyRequest = {
        "policy_name": policy_name,
        "tier": tier,
        "policy": policy,
    }
    if policy_description is not None:
        input_["policy_description"] = policy_description
    if data_location_constraint is not None:
        input_["data_location_constraint"] = data_location_constraint
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    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