Skip to content

create_traffic_policy

create_traffic_policy(
    name: TrafficPolicyName,
    document: TrafficPolicyDocument,
    *,
    config_overrides: Optional[Route53ClientConfig] = None,
    comment: Optional[TrafficPolicyComment] = None,
) -> CreateTrafficPolicyResponse

Creates a traffic policy, which you use to create multiple DNS resource record sets for one domain name (such as example.com) or one subdomain name (such as www.example.com).

Parameters:

Raises:

  • InvalidInput –

    The input is not valid.

  • InvalidTrafficPolicyDocument –

    The format of the traffic policy document that you specified in the Document element is not valid.

  • TooManyTrafficPolicies –

    This traffic policy can't be created because the current account has reached the limit on the number of traffic policies.

    For information about default limits, see Limits in the Amazon Route 53 Developer Guide.

    To get the current limit for an account, see GetAccountLimit.

    To request a higher limit, create a case with the Amazon Web Services Support Center.

  • TrafficPolicyAlreadyExists –

    A traffic policy that has the same value for Name already exists.

  • UnknownServiceError –

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

Source code in docs_src/capo_route_53/_services/route53.py
def create_traffic_policy(
    self,
    name: "capo_route_53.types.traffic_policy_name.TrafficPolicyName",
    document: "capo_route_53.types.traffic_policy_document.TrafficPolicyDocument",
    *,
    config_overrides: Optional[Route53ClientConfig] = None,
    comment: Optional[
        "capo_route_53.types.traffic_policy_comment.TrafficPolicyComment"
    ] = None,
) -> (
    "capo_route_53.types.create_traffic_policy_response.CreateTrafficPolicyResponse"
):
    """<p>Creates a traffic policy, which you use to create multiple DNS resource record sets for one domain name (such as example.com) or one subdomain name (such as www.example.com).</p>

    Args:
        name: <p>The name of the traffic policy.</p>
        document: <p>The definition of this traffic policy in JSON format. For more information, see <a href="https://docs.aws.amazon.com/Route53/latest/APIReference/api-policies-traffic-policy-document-format.html">Traffic Policy Document Format</a>.</p>
        comment: <p>(Optional) Any comments that you want to include about the traffic policy.</p>

    Raises:
        capo_route_53.errors.invalid_input.InvalidInput: <p>The input is not valid.</p>
        capo_route_53.errors.invalid_traffic_policy_document.InvalidTrafficPolicyDocument: <p>The format of the traffic policy document that you specified in the <code>Document</code> element is not valid.</p>
        capo_route_53.errors.too_many_traffic_policies.TooManyTrafficPolicies: <p>This traffic policy can't be created because the current account has reached the limit on the number of traffic policies.</p> <p>For information about default limits, see <a href="https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DNSLimitations.html">Limits</a> in the <i>Amazon Route 53 Developer Guide</i>.</p> <p>To get the current limit for an account, see <a href="https://docs.aws.amazon.com/Route53/latest/APIReference/API_GetAccountLimit.html">GetAccountLimit</a>. </p> <p>To request a higher limit, <a href="http://aws.amazon.com/route53-request">create a case</a> with the Amazon Web Services Support Center.</p>
        capo_route_53.errors.traffic_policy_already_exists.TrafficPolicyAlreadyExists: <p>A traffic policy that has the same value for <code>Name</code> already exists.</p>
        capo_route_53.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_route_53.types.create_traffic_policy_request.CreateTrafficPolicyRequest]",
    ) -> OperationResponse[
        "capo_route_53.types.create_traffic_policy_response.CreateTrafficPolicyResponse"
    ]:
        import capo_route_53._operations.aws_dns_v20130401.create_traffic_policy

        output, http_response = (
            capo_route_53._operations.aws_dns_v20130401.create_traffic_policy.create_traffic_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateTrafficPolicy")
    )
    input_: capo_route_53.types.create_traffic_policy_request.CreateTrafficPolicyRequest = {
        "name": name,
        "document": document,
    }
    if comment is not None:
        input_["comment"] = comment

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