Skip to content

create_traffic_policy_instance

create_traffic_policy_instance(
    hosted_zone_id: ResourceId,
    name: DNSName,
    ttl: TTL,
    traffic_policy_id: TrafficPolicyId,
    traffic_policy_version: TrafficPolicyVersion,
    *,
    config_overrides: Optional[Route53ClientConfig] = None,
) -> CreateTrafficPolicyInstanceResponse

Creates resource record sets in a specified hosted zone based on the settings in a specified traffic policy version. In addition, CreateTrafficPolicyInstance associates the resource record sets with a specified domain name (such as example.com) or subdomain name (such as www.example.com). Amazon Route 53 responds to DNS queries for the domain or subdomain name by using the resource record sets that CreateTrafficPolicyInstance created.

After you submit an CreateTrafficPolicyInstance request, there's a brief delay while Amazon Route 53 creates the resource record sets that are specified in the traffic policy definition. Use GetTrafficPolicyInstance with the id of new traffic policy instance to confirm that the CreateTrafficPolicyInstance request completed successfully. For more information, see the State response element.

Parameters:

  • hosted_zone_id (ResourceId) –

    The ID of the hosted zone that you want Amazon Route 53 to create resource record sets in by using the configuration in a traffic policy.

  • name (DNSName) –

    The domain name (such as example.com) or subdomain name (such as www.example.com) for which Amazon Route 53 responds to DNS queries by using the resource record sets that Route 53 creates for this traffic policy instance.

  • ttl (TTL) –

    (Optional) The TTL that you want Amazon Route 53 to assign to all of the resource record sets that it creates in the specified hosted zone.

  • traffic_policy_id (TrafficPolicyId) –

    The ID of the traffic policy that you want to use to create resource record sets in the specified hosted zone.

  • traffic_policy_version (TrafficPolicyVersion) –

    The version of the traffic policy that you want to use to create resource record sets in the specified hosted zone.

Raises:

  • InvalidInput –

    The input is not valid.

  • NoSuchHostedZone –

    No hosted zone exists with the ID that you specified.

  • NoSuchTrafficPolicy –

    No traffic policy exists with the specified ID.

  • TooManyTrafficPolicyInstances –

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

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

    For information about how 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.

  • TrafficPolicyInstanceAlreadyExists –

    There is already a traffic policy instance with the specified ID.

  • 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_instance(
    self,
    hosted_zone_id: "capo_route_53.types.resource_id.ResourceId",
    name: "capo_route_53.types.dns_name.DNSName",
    ttl: "capo_route_53.types.ttl.TTL",
    traffic_policy_id: "capo_route_53.types.traffic_policy_id.TrafficPolicyId",
    traffic_policy_version: "capo_route_53.types.traffic_policy_version.TrafficPolicyVersion",
    *,
    config_overrides: Optional[Route53ClientConfig] = None,
) -> "capo_route_53.types.create_traffic_policy_instance_response.CreateTrafficPolicyInstanceResponse":
    """<p>Creates resource record sets in a specified hosted zone based on the settings in a specified traffic policy version. In addition, <code>CreateTrafficPolicyInstance</code> associates the resource record sets with a specified domain name (such as example.com) or subdomain name (such as www.example.com). Amazon Route 53 responds to DNS queries for the domain or subdomain name by using the resource record sets that <code>CreateTrafficPolicyInstance</code> created.</p> <note> <p>After you submit an <code>CreateTrafficPolicyInstance</code> request, there's a brief delay while Amazon Route 53 creates the resource record sets that are specified in the traffic policy definition. Use <code>GetTrafficPolicyInstance</code> with the <code>id</code> of new traffic policy instance to confirm that the <code>CreateTrafficPolicyInstance</code> request completed successfully. For more information, see the <code>State</code> response element.</p> </note>

    Args:
        hosted_zone_id: <p>The ID of the hosted zone that you want Amazon Route 53 to create resource record sets in by using the configuration in a traffic policy.</p>
        name: <p>The domain name (such as example.com) or subdomain name (such as www.example.com) for which Amazon Route 53 responds to DNS queries by using the resource record sets that Route 53 creates for this traffic policy instance.</p>
        ttl: <p>(Optional) The TTL that you want Amazon Route 53 to assign to all of the resource record sets that it creates in the specified hosted zone.</p>
        traffic_policy_id: <p>The ID of the traffic policy that you want to use to create resource record sets in the specified hosted zone.</p>
        traffic_policy_version: <p>The version of the traffic policy that you want to use to create resource record sets in the specified hosted zone.</p>

    Raises:
        capo_route_53.errors.invalid_input.InvalidInput: <p>The input is not valid.</p>
        capo_route_53.errors.no_such_hosted_zone.NoSuchHostedZone: <p>No hosted zone exists with the ID that you specified.</p>
        capo_route_53.errors.no_such_traffic_policy.NoSuchTrafficPolicy: <p>No traffic policy exists with the specified ID.</p>
        capo_route_53.errors.too_many_traffic_policy_instances.TooManyTrafficPolicyInstances: <p>This traffic policy instance can't be created because the current account has reached the limit on the number of traffic policy instances.</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>For information about how 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_instance_already_exists.TrafficPolicyInstanceAlreadyExists: <p>There is already a traffic policy instance with the specified ID.</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_instance_request.CreateTrafficPolicyInstanceRequest]",
    ) -> OperationResponse[
        "capo_route_53.types.create_traffic_policy_instance_response.CreateTrafficPolicyInstanceResponse"
    ]:
        import capo_route_53._operations.aws_dns_v20130401.create_traffic_policy_instance

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateTrafficPolicyInstance")
    )
    input_: capo_route_53.types.create_traffic_policy_instance_request.CreateTrafficPolicyInstanceRequest = {
        "hosted_zone_id": hosted_zone_id,
        "name": name,
        "ttl": ttl,
        "traffic_policy_id": traffic_policy_id,
        "traffic_policy_version": traffic_policy_version,
    }

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