

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# トラフィックポリシードキュメントの形式
<a name="api-policies-traffic-policy-document-format"></a>

Amazon Route 53 API、 AWS SDKs の 1 つ、、 AWS CLIまたは を使用してトラフィックポリシーをプログラムで作成する場合は AWS Tools for Windows PowerShell、トラフィックポリシーの定義を JSON 形式の `Document`要素で指定します。

トラフィックポリシーの詳細については、*Amazon Route 53 デベロッパーガイド*の[「トラフィックフローを使用して DNS トラフィックをルーティング](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/traffic-flow.html)する」を参照してください。

**Topics**
+ [基本構文](#traffic-policy-document-format-basic)
+ [エンドポイント定義の構文](#traffic-policy-document-format-endpoints)
+ [ルール定義の構文](#traffic-policy-document-format-rules)
+ [例](#traffic-policy-document-format-examples)

## 基本構文
<a name="traffic-policy-document-format-basic"></a>

トラフィックポリシードキュメントの基本的な構文は次のとおりです。

```
 1. {
 2.    "AWSPolicyFormatVersion": "2015-10-01 | 2023-05-09",
 3.    "RecordType": "{{DNS type for all resource record sets created by this traffic policy}}",
 4.    "StartEndpoint | StartRule": "{{ID that you assign to an endpoint or rule}}",
 5.    "Endpoints": {
 6.       "{{Endpoint ID that you assign}}": {
 7.          {{Endpoint definition}}
 8.       },
 9.       ...
10.    },
11.    "Rules": {
12.       "{{Rule ID that you assign}}": {
13.          {{Rule definition}}
14.       },
15.       ...
16.    }
17. }
```

トラフィックポリシードキュメントの基本的な構文には、次のオブジェクトが含まれています。

**AWSPolicyFormatVersion**  
トラフィックポリシー形式のバージョン、 AWS ローカルゾーンをサポートする最新バージョン、`2023-05-09`。  
以前のバージョン もサポートされています`2015-10-01`。

**RecordType**  
このトラフィックポリシーに基づいて Amazon Route 53 が作成するすべてのリソースレコードセットの DNS タイプ。トラフィックを次の AWS リソースにルーティングする場合は、該当する値を選択します。  
+ **CloudFront ディストリビューション** – **[A: IPv4 形式の IP アドレス]** または **[AAAA: IPv6 形式の IP アドレス]** を選択します。
+ **ELB Application Load Balancer** – **[A: IPv4 形式の IP アドレス]** または **[AAAA: IPv6 形式の IP アドレス]** を選択します。
+ **ELB Classic Load Balancer** – **[A: IPv4 形式の IP アドレス]** または **[AAAA: IPv6 形式の IP アドレス]** を選択します。
+ **ELB Network Load Balancer** – **[A: IPv4 形式の IP アドレス]** または **[AAAA: IPv6 形式の IP  アドレス]** を選択します。
+ **Elastic Beanstalk 環境** – **A: IPv4 形式の IP アドレス**または **AAAA: IPv6 形式の IP アドレス**を選択します。
+ **ウェブサイトエンドポイントとして設定された Amazon S3 バケット**: **[A: IP address in IPv4 format]** (A: IPv4 形式の IP アドレス) を選択します。
トラフィックを他のリソースにルーティングする場合は、リソースに適したタイプを選択します。たとえば、トラフィックをメールサーバーにルーティングする場合は、 を指定します`MX`。Route 53 がサポートする DNS タイプのリストについては、*「Amazon Route 53 デベロッパーガイド*[」の「サポートされている DNS リソースレコードタイプ](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/ResourceRecordTypes.html)」を参照してください。

**StartEndpoint \| StartRule**  
トラフィックポリシーの開始点をエンドポイントとルールのどちらにするか、およびトラフィックポリシードキュメントの他の場所でエンドポイントまたはルールに割り当てた ID。

**エンドポイント**  
このトラフィックポリシーで使用するエンドポイントの定義。詳細については、「[エンドポイント定義の構文](#traffic-policy-document-format-endpoints)」を参照してください。

**Rules**  
このトラフィックポリシーで使用するルールの定義。詳細については、「[ルール定義の構文](#traffic-policy-document-format-rules)」を参照してください。

## エンドポイント定義の構文
<a name="traffic-policy-document-format-endpoints"></a>

トラフィックポリシードキュメントで指定するエンドポイント定義の構文は次のとおりです。

```
1. {
2.    "Type": value | cloudfront | application-load-balancer | elastic-load-balancer | network-load-balancer | elastic-beanstalk | s3-website,
3.    "Region": "AWS region that you created your Amazon S3 bucket in"
4.    "Value": "value applicable to the type of endpoint"
5. }
```

エンドポイント定義の構文には、次のオブジェクトが含まれます。

**タイプ**  
該当する値を指定します。    
**値**  
次のリストのリソース以外のリソースにトラフィックをルーティングするには、 `value`に を指定します`Type`。  
**cloudfront**  
CloudFront ディストリビューションにトラフィックをルーティングするには、 `cloudfront`に を指定します`Type`。  
**application-load-balancer**  
Application Load Balancer にトラフィックをルーティングするには、 `application-load-balancer`に を指定します`Type`。  
**elastic-load-balancer**  
ELB Classic ロードバランサーにトラフィックをルーティングするには、 `elastic-load-balancer`に を指定します`Type`。  
**network-load-balancer**  
ELB Network Load Balancer にトラフィックをルーティングするには、 `network-load-balancer`に を指定します`Type`。  
**elastic-beanstalk**  
Elastic Beanstalk 環境にトラフィックをルーティングするには、 `elastic-beanstalk`に を指定します`Type`。  
**s3 ウェブサイト**  
ウェブサイトエンドポイントとして設定された Amazon S3 バケットにトラフィックをルーティングするには、 `s3-website`に を指定します`Type`。

**リージョン**  
ウェブサイトエンドポイントとして設定された Amazon S3 バケットにトラフィックをルーティングするには、 のバケットを作成したリージョンを指定します`Region`。他のリソースの場合は、 を省略します`Region`。

**値**  
該当する値を指定します。    
**値**  
以下に示すリソース以外のリソースにトラフィックをルーティングするには、 に指定した値に対応する値を指定します`RecordType`。たとえば、 `A`に を指定した場合は`RecordType`、 に IPv4 形式の IP アドレスを指定します`Value`。  
**cloudfront**  
`cloudfront` に を指定した場合は`Type`、CloudFront ディストリビューションの作成時に CloudFront が CloudFront ディストリビューションに割り当てたドメイン名を指定します。たとえば、 です`d111111abcdef8.cloudfront.net`。  
**application-load-balancer**  
`application-load-balancer` に を指定した場合は`Type`、ロードバランサーの DNS 名を指定します。例えば、`exampleAlb-1283637735.us-east-1.elb.amazonaws.com`。  
**elastic-load-balancer**  
`elastic-load-balancer` に を指定した場合は`Type`、ロードバランサーの DNS 名を指定します。たとえば`dualstack`、 で始まる値を使用します`dualstack.my-load-balancer-1234567890.us-west-2.elb.amazonaws.com`。  
**network-load-balancer**  
`network-load-balancer` に を指定した場合は`Type`、ロードバランサーの DNS 名を指定します。例えば、`exampleNlb-74f87b114e21682a.elb.us-east-1.amazonaws.com`。  
**elastic-beanstalk**  
`elastic-beanstalk` に を指定した場合は`Type`、Elastic Beanstalk 環境のドメイン名を指定します。例えば、`example-beanstalk-env-1.eba-ns4qrife.us-east-1.elasticbeanstalk.com`。  
**s3 ウェブサイト**  
`s3-website` に を指定した場合は`Type`、Amazon S3 バケットの名前を指定します。たとえば、 です`example.com.s3-website-us-east-1.amazonaws.com`。  
このトラフィックポリシーに基づいてトラフィックポリシーインスタンスを作成する場合、ここで指定するバケットは、[CreateTrafficPolicyInstance](https://docs.aws.amazon.com/Route53/latest/APIReference/API_CreateTrafficPolicyInstance.html) リクエスト`Name`で に指定するドメイン名 (www.example.com など) と一致する必要があります。`Value` と が一致し`Name`ない場合、Amazon S3 はドメイン名の DNS クエリに応答しません。

## ルール定義の構文
<a name="traffic-policy-document-format-rules"></a>

トラフィックポリシードキュメントで指定するルール定義には、使用するルーティングポリシーのタイプに応じて、フェイルオーバー、位置情報、地理的近接性、レイテンシー、複数値の回答、または重み付けなど、さまざまな構文があります。

**Topics**
+ [フェイルオーバールール](#traffic-policy-document-format-rules-failover)
+ [位置情報ルール](#traffic-policy-document-format-rules-geo)
+ [地理的近接性ルール](#traffic-policy-document-format-rules-geoproximity)
+ [レイテンシールール](#traffic-policy-document-format-rules-latency)
+ [複数値回答ルール](#traffic-policy-document-format-rules-multivalue-answer)
+ [加重ルール](#traffic-policy-document-format-rules-weighted)

### フェイルオーバールール
<a name="traffic-policy-document-format-rules-failover"></a>

詳細については、*Amazon Route 53 デベロッパーガイド*[の「DNS フェイルオーバーの設定](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-failover-configuring.html)」を参照してください。

```
 1. {
 2.    "RuleType": "failover",
 3.    "Primary": {
 4.       "EndpointReference | RuleReference": "{{ID that you assigned to the rule or endpoint that this rule routes traffic to}}",
 5.       "EvaluateTargetHealth": "true" | "false",
 6.       "HealthCheck": "{{optional health check ID}}"
 7.    },
 8.    "Secondary": {
 9.       "EndpointReference | RuleReference": "{{ID that you assigned to the rule or endpoint that this rule routes traffic to}}",
10.       "EvaluateTargetHealth": "true" | "false",
11.       "HealthCheck": "{{optional health check ID}}"
12.    }
13. }
```

フェイルオーバールールを定義するときは、次のオブジェクトを指定します。

**RuleType**  
`failover` を指定します。

**プライマリ \| セカンダリ**  
`Primary` オブジェクトで、対応するリソースが利用可能な場合にトラフィックをルーティングするルールまたはエンドポイントの設定を指定します。  
`Secondary` オブジェクトには、プライマリリソースが利用できないときにトラフィックをルーティングするルールまたはエンドポイントの設定を指定します。

**EndpointReference \| RuleReference**  
トラフィックをエンドポイントにルーティングするか、別のルールにルーティングするか、およびトラフィックポリシードキュメントの他の場所でエンドポイントまたはルールに割り当てた ID。

**EvaluateTargetHealth**  
Amazon Route 53 でエンドポイントの状態を評価し、トラフィックを正常なエンドポイントにのみルーティングするかどうかを示すブール値。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[EvaluateTargetHealth](https://docs.aws.amazon.com/Route53/latest/APIReference/API_AliasTarget.html#Route53-Type-AliasTarget-EvaluateTargetHealth)」を参照してください。

**HealthCheck**  
ヘルスチェックをエンドポイントまたはルールに関連付ける場合は、ヘルスチェックの ID を指定します。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[HealthCheckId](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-HealthCheckId)」を参照してください。

### 位置情報ルール
<a name="traffic-policy-document-format-rules-geo"></a>

位置情報ルールを追加するときは、ユーザーの地理的位置に基づいてトラフィックをルーティングするようにトラフィックポリシーを設定します。詳細については、*「Amazon Route 53 デベロッパーガイド*」の[「位置情報ルーティング](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html#routing-policy-geo)」を参照してください。

```
 1. {
 2.    "RuleType": "geo",
 3.    "Locations": [
 4.       {
 5.          "EndpointReference | RuleReference": "{{ID that you assigned to the rule or endpoint that this rule routes traffic to}}",
 6.          "IsDefault": "true" | "false",
 7.          "Continent": "{{continent name}},
 8.          "Country": "{{country name}},
 9.          "Subdivision": "{{subdivision name}},
10.          "EvaluateTargetHealth": "true" | "false",
11.          "HealthCheck": "{{optional health check ID}}"
12.       },
13.       ...
14.    ]
15. }
```

位置情報ルールを定義するときは、次のオブジェクトを指定します。

**RuleType**  
`geo` を指定します。

**ロケーション**  
トラフィックをルーティングする地理的ロケーションごとに 1 つの値セット (`EndpointReference` \| `RuleReference`、`IsDefault``Continent``Country``Subdivision`、、`EvaluateTargetHealth`、、、`HealthCheck`) を指定します。

**EndpointReference \| RuleReference**  
トラフィックをエンドポイントにルーティングするか、別のルールにルーティングするか、およびトラフィックポリシードキュメントの他の場所でエンドポイントまたはルールに割り当てた ID。

**IsDefault**  
この値のセットがデフォルトの場所を表すかどうかを示すブール値。地理的位置の `CountryCode`要素の値`*`として を指定した場合、この位置の `IsDefault`要素の値は`True`デフォルトで に設定され、同じ位置情報ルールの他の地理的位置の `IsDefault`要素の値`True`として を指定することはできません。`CountryCode` 要素の値`*`として を指定する方法の詳細については、 の次のエントリを参照してください`Continent, Country, Subdivision`。

**Continent、Country、Subdivision**  
ルールまたはエンドポイントにトラフィックをルーティングするユーザーの地理的位置を示す値。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの以下の要素の説明を参照してください。  
+ `GeoLocation`
+ `ContinentCode`
+ `CountryCode`
+ `SubdivisionCode`
詳細については、*「Amazon Route 53 *デベロッパーガイド」の[「ロケーション](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values-geo.html#rrsets-values-geo-location)」を参照してください。  
位置情報は、IP アドレスを場所にマッピングすることで動作します。ただし、一部の IP アドレスは地理的な場所にマッピングされないため、7 つの大陸すべてをカバーする地理的な場所を作成しても、Route 53 は識別できない場所からいくつかの DNS クエリを受け取ります。の値が である地理的な場所を作成することをお勧めします`Country``*`。クエリの 2 つのグループは、このレコードで指定したリソースにルーティングされます。地理的場所を作成していない場所からのクエリと、場所にマッピングされていない IP アドレスからのクエリです。`*` 地理的な場所を作成しない場合、Route 53 はマッピングされていない場所からのクエリに対して「応答なし」レスポンスを返します。

**EvaluateTargetHealth**  
Amazon Route 53 でエンドポイントの状態を評価し、トラフィックを正常なエンドポイントにのみルーティングするかどうかを示すブール値。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[EvaluateTargetHealth](https://docs.aws.amazon.com/Route53/latest/APIReference/API_AliasTarget.html#Route53-Type-AliasTarget-EvaluateTargetHealth)」を参照してください。

**HealthCheck**  
ヘルスチェックをエンドポイントまたはルールに関連付ける場合は、ヘルスチェックの ID を指定します。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[HealthCheckId](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-HealthCheckId)」を参照してください。

### 地理的近接性ルール
<a name="traffic-policy-document-format-rules-geoproximity"></a>

地理的近接性ルールを追加するときは、リソースの地理的位置に基づいてトラフィックをリソースにルーティングするように Amazon Route 53 を設定します。オプションで、バイアスを指定して、特定のエンドポイントまたはルールにより多くのトラフィックをルーティングするか、より少ないトラフィックをルーティングするかを選択することもできます。バイアスを使用して、トラフィックがエンドポイントまたはルールにルーティングされる地理的リージョンのサイズを拡大または縮小します。詳細については、*「Amazon Route 53 デベロッパーガイド*」の[「地理的近接性ルーティング](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html#routing-policy-geoproximity)」を参照してください。

次の例は `AWSPolicyFormatVersion 2023-05-09`専用です。

```
 1. {
 2.    "RuleType": "geoproximity",
 3.    "GeoproximityLocations": [
 4.       { 
 5.          "EndpointReference | RuleReference": "ID that you assigned to the endpoint or rule that this rule routes traffic to",
 6.          "Location":{
 7.             "Type": "Region | LocalZone",
 8.             "LocationName": "AWS Region | AWS Local Zone"
 9.          },
10.          "Bias": "optional value to expand or shrink the geographic region for this rule, -99 to 99",
11.          "EvaluateTargetHealth": "true | false",
12.          "HealthCheck": "optional health check ID"
13.       },
14.       {
15.          "EndpointReference | RuleReference": "ID that you assigned to the endpoint or rule that this rule routes traffic to",
16.          "Location":{
17.             "Type": "Coordinate",
18.             "Latitude": "location south (negative) or north (positive) of the equator, -90 to 90 degrees",
19.             "Longitude": "location west (negative) or east (positive) of the prime meridian, -180 to 180 degrees"
20.          },
21.          "Bias": "optional value to expand or shrink the geographic region for this rule, -99 to 99",
22.          "EvaluateTargetHealth": "true | false",
23.          "HealthCheck": "optional health check ID"
24.       }
25.    ]
26. }
```

次の例は `AWSPolicyFormatVersion 2015-10-01`専用です。

```
 1. {
 2.    "RuleType": "geoproximity",
 3.    "GeoproximityLocations": [
 4.       {
 5.          "EndpointReference | RuleReference": "{{ID that you assigned to the endpoint or rule that this rule routes traffic to}}",
 6.          "Region": "{{AWS Region}}",
 7.          "Bias": "{{optional value to expand or shrink the geographic region for this rule, -99 to 99}}",
 8.          "EvaluateTargetHealth": "true | false",
 9.          "HealthCheck": "{{optional health check ID}}"
10.       },
11.       {
12.          "EndpointReference | RuleReference": "{{ID that you assigned to the endpoint or rule that this rule routes traffic to}}",
13.          "Latitude": "{{location south (negative) or north (positive) of the equator, -90 to 90 degrees}}",
14.          "Longitude": "{{location west (negative) or east (positive) of the prime meridian, -180 to 180 degrees}}",
15.          "Bias": "{{optional value to expand or shrink the geographic region for this rule, -99 to 99}}",
16.          "EvaluateTargetHealth": "true | false",
17.          "HealthCheck": "{{optional health check ID}}"
18.       }
19.    ]
20. }
```

地理的近接性ルールを定義するときは、次のオブジェクトを指定します。

**RuleType**  
`geoproximity` を指定します。

**GeoproximityLocations**  
トラフィックをルーティングするリソースごとに 1 セットの値を指定します。**Location** フィールドを指定できます。これは、 の AWS リージョン、ローカルゾーン、緯度と経度をサポートします`AWSPolicyFormatVersion 2023-05-09`。 AWS リージョン、または の地理的位置の緯度と経度を指定することもできます`AWSPolicyFormatVersion 2015-10-01`。

**EndpointReference \| RuleReference**  
トラフィックをエンドポイントにルーティングするか、別のルールにルーティングするか、およびトラフィックポリシードキュメントの他の場所でエンドポイントまたはルールに割り当てた ID。

**Location (`AWSPolicyFormatVersion 2023-05-09` のみ)**  
Location フィールドは、 AWS リージョン、ローカルゾーン、緯度と経度を次の形式でサポートします。  
ローカルゾーンの場合: `"Location": { "Type": "LocalZone", "LocationName": "aws:route53:us-east-1-atl-1a" }`  
リージョンの場合: `"Location": { "Type": "Region", "LocationName": "aws:route53:us-east-1" },`  
座標の場合: `"Location": { "Type": "Coordinate", "Latitude": "38.9", "Longitude": "-77.01" },`  
有効なリージョンコードのリストについては、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[「リージョン](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-Region)」を参照してください。  
使用可能なローカルゾーンについては、「[AWS Local Zones ロケーション](https://aws.amazon.com/about-aws/global-infrastructure/localzones/locations/)」を参照してください。

**リージョン (`AWSPolicyFormatVersion 2015-10-01` のみ)**  
エンドポイントが AWS リソースの場合は、リソースを作成した AWS リージョンを指定します。次の形式を使用します。  
`aws:route53:`{{region-code}}  
有効なリージョンコードのリストについては、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[「リージョン](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-Region)」を参照してください。

**緯度と経度 (`AWSPolicyFormatVersion 2015-10-01` のみ)**  
エンドポイントが AWS リソースでない場合は、リソースの場所の緯度と経度を入力します。次の点に注意してください。  
+ 緯度は南緯 (負) または北緯 (正) で表します。有効な値の範囲は -90 度から 90 度です。
+ 経度は西経 (負) または東経 (正) で表します。有効な値の範囲は -180 度から 180 度です。
+ 緯度と経度は一部のオンラインマップアプリケーションで入手できます。例えば Google マップでは、その場所の URL に緯度と経度が指定されています。

  https://www.google.com/maps/@**47.6086111**,-**122.3409953**,20z
+ など、小数点以下 2 桁までの精度を入力できます`47.61`。精度の高い値を指定すると、Route 53 はエラーを返します。緯度と経度は赤道上で、0.01 度が約 0.69 マイルです。

**Bias (バイアス)**  
近くのエンドポイントからエンドポイントにより多くのトラフィックをルーティングする場合 (正の値）、またはエンドポイントにより少ないトラフィックをルーティング`Bias`する場合 (負の値) に、 の値を指定します。有効な値の範囲は -99 ～ 99 です。デフォルト値は 0 です。  
の値は、距離に基づく絶対値ではなく、他のリソースの場所に基づく相対値`Bias`です。その結果、変更の効果を予測することは簡単ではありません。例えば、リソースの場所に応じて、バイアスを から `10` に変更`15`すると、ニューヨーク市大都市圏からの大量のトラフィックを加算または減算する違いがわかります。バイアスを小規模に変更して結果を評価してから、必要に応じてさらに変更を行うことをお勧めします。

**EvaluateTargetHealth**  
Route 53 でエンドポイントの状態を評価し、トラフィックを正常なエンドポイントにのみルーティングするかどうかを示すブール値。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[EvaluateTargetHealth](https://docs.aws.amazon.com/Route53/latest/APIReference/API_AliasTarget.html#Route53-Type-AliasTarget-EvaluateTargetHealth)」を参照してください。

**HealthCheck**  
ヘルスチェックをエンドポイントまたはルールに関連付ける場合は、ヘルスチェックの ID を指定します。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[HealthCheckId](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-HealthCheckId)」を参照してください。

### レイテンシールール
<a name="traffic-policy-document-format-rules-latency"></a>

レイテンシールールを追加するときは、ユーザーと、ELB ロードバランサーや Amazon S3 バケットなどの AWS リソースを作成した AWS リージョン間のレイテンシー (遅延時間) に基づいてトラフィックをルーティングするようにトラフィックポリシーを設定します。詳細については、*「Amazon Route 53 デベロッパーガイド*」の[「レイテンシールーティング](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html#routing-policy-latency)」を参照してください。

```
 1. {
 2.    "RuleType": "latency",
 3.    "Regions": [
 4.       {
 5.          "EndpointReference | RuleReference": "{{ID that you assigned to the rule or endpoint that this rule routes traffic to}}",
 6.          "Region": "{{AWS region that you want to route traffic to}}",
 7.          "EvaluateTargetHealth": "true" | "false",
 8.          "HealthCheck": "{{optional health check ID}}"
 9.       },
10.       ...
11.    ]
12. }
```

レイテンシールールを定義するときは、次のオブジェクトを指定します。

**RuleType**  
`latency` を指定します。

**リージョン**  
トラフィックをルーティングするリージョン`HealthCheck`ごとに 1 `Region`つの値セット (`EndpointReference` \| `RuleReference`、`EvaluateTargetHealth`、、) を指定します。

**EndpointReference \| RuleReference**  
トラフィックをエンドポイントにルーティングするか、別のルールにルーティングするか、およびトラフィックポリシードキュメントの他の場所でエンドポイントまたはルールに割り当てた ID。

**リージョン**  
リソースを作成したリージョンの AWS リージョンコード。有効なリージョンコードのリストについては、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[「リージョン](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-Region)」を参照してください。

**EvaluateTargetHealth**  
Amazon Route 53 でエンドポイントの状態を評価し、トラフィックを正常なエンドポイントにのみルーティングするかどうかを示すブール値。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[EvaluateTargetHealth](https://docs.aws.amazon.com/Route53/latest/APIReference/API_AliasTarget.html#Route53-Type-AliasTarget-EvaluateTargetHealth)」を参照してください。

**HealthCheck**  
ヘルスチェックをエンドポイントまたはルールに関連付ける場合は、ヘルスチェックの ID を指定します。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[HealthCheckId](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-HealthCheckId)」を参照してください。

### 複数値回答ルール
<a name="traffic-policy-document-format-rules-multivalue-answer"></a>

複数値回答ルールを追加するときは、トラフィックポリシーを設定して、トラフィックを正常なリソースにほぼランダムにルーティングします。Amazon Route 53 は最大 8 つの正常なレコードで DNS クエリに応答します。8 つ以下の正常なレコードがある場合、Route 53 はすべての正常なレコードですべての DNS クエリに応答します。詳細については、「[MultiValueAnswer](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-MultiValueAnswer)」を参照してください。

```
 1. {
 2.    "RuleType": "multivalue",
 3.    "Items": [
 4.       {
 5.          "EndpointReference": "{{ID that you assigned to the endpoint that this rule routes traffic to}}",
 6.          "HealthCheck": "{{optional health check ID}}"
 7.       },
 8.       ...
 9.    ]
10. }
```

複数値の回答ルールを定義するときは、次のオブジェクトを指定します。

**RuleType**  
`multivalue` を指定します。

**項目**  
トラフィックをルーティングする複数値の回答ルールまたはエンドポイントごとに、値のセット (`EndpointReference` と `HealthCheck`) を 1 つ指定します。

**EndpointReference**  
トラフィックポリシードキュメントの他の場所でエンドポイントに割り当てた ID。

**HealthCheck**  
ヘルスチェックをエンドポイントに関連付ける場合は、ヘルスチェックの ID を指定します。詳細については、「[HealthCheckId](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-HealthCheckId)」を参照してください。

### 加重ルール
<a name="traffic-policy-document-format-rules-weighted"></a>

加重ルールを追加するときは、指定した比率に基づいてトラフィックをルーティングするようにトラフィックポリシーを設定します。たとえば、重みとして 4、5、5、6 (合計 = 20) を指定できます。その結果、トラフィックの 4/20 は平均して最初のエンドポイントまたはルールにルーティングされ、5/20 は 2 番目と 3 番目のエンドポイントまたはルールの両方にルーティングされ、6/20 は最後のエンドポイントまたはルールにルーティングされます。詳細については、*Amazon Route 53 デベロッパーガイド*の[加重ルーティング](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html#routing-policy-weighted)を参照してください。

```
 1. {
 2.    "RuleType": "weighted",
 3.    "Items": [
 4.       {
 5.          "EndpointReference | RuleReference": "{{ID that you assigned to the rule or endpoint that this rule routes traffic to}}",
 6.          "Weight": "{{value between 0 and 255}}",
 7.          "EvaluateTargetHealth": "true" | "false",
 8.          "HealthCheck": "{{optional health check ID}}"
 9.       },
10.       ...
11.    ]
12. }
```

加重ルールを定義するときは、次のオブジェクトを指定します。

**RuleType**  
`weighted` を指定します。

**項目**  
トラフィックをルーティングする加重ルールまたはエンドポイント`HealthCheck`ごとに 1 つの値セット (`EndpointReference` \| `RuleReference``Weight`、`EvaluateTargetHealth`、、) を指定します。

**EndpointReference \| RuleReference**  
トラフィックをエンドポイントにルーティングするか、別のルールにルーティングするか、およびトラフィックポリシードキュメントの他の場所でエンドポイントまたはルールに割り当てた ID。

**Weight**  
対応するエンドポイントまたはルールにルーティングされるトラフィックの割合を決定する 0～255 の値。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[「重](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-Weight)み」を参照してください。

**EvaluateTargetHealth**  
Amazon Route 53 でエンドポイントの状態を評価し、トラフィックを正常なエンドポイントにのみルーティングするかどうかを示すブール値。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[EvaluateTargetHealth](https://docs.aws.amazon.com/Route53/latest/APIReference/API_AliasTarget.html#Route53-Type-AliasTarget-EvaluateTargetHealth)」を参照してください。

**HealthCheck**  
ヘルスチェックをエンドポイントまたはルールに関連付ける場合は、ヘルスチェックの ID を指定します。詳細については、[ChangeResourceRecordSets](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) に関するドキュメントの[HealthCheckId](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-HealthCheckId)」を参照してください。

## 例
<a name="traffic-policy-document-format-examples"></a>

次の例は、フェイルオーバー、位置情報、地理的近接性、レイテンシー、加重ルールの使用方法と、同じトラフィックポリシーで複数のタイプのルールを使用する方法を示しています。

**Topics**
+ [フェイルオーバーの例](#traffic-policy-document-format-examples-failover)
+ [位置情報の例](#traffic-policy-document-format-examples-geolocation)
+ [地理的近接性の例](#traffic-policy-document-format-examples-proximity)
+ [レイテンシーの例](#traffic-policy-document-format-examples-latency)
+ [加重例](#traffic-policy-document-format-examples-weighted)
+ [フェイルオーバー、レイテンシー、位置情報ルールの例](#traffic-policy-document-format-examples-combined)

### フェイルオーバーの例
<a name="traffic-policy-document-format-examples-failover"></a>

```
{
   "AWSPolicyFormatVersion":"2015-10-01",
   "RecordType":"A",
   "StartRule":"site_switch",
   "Endpoints":{
      "my_elb":{
         "Type":"elastic-load-balancer",
         "Value":"elb-111111.us-east-1.elb.amazonaws.com"
      },
      "site_down_banner":{
         "Type":"s3-website",
         "Region":"us-east-1",
         "Value":"www.example.com"
      }
   },
   "Rules":{
      "site_switch":{
         "RuleType":"failover",
         "Primary":{
            "EndpointReference":"my_elb"
         },
         "Secondary":{
            "EndpointReference":"site_down_banner"
         }
      }
   }
}
```

### 位置情報の例
<a name="traffic-policy-document-format-examples-geolocation"></a>

```
{
  "AWSPolicyFormatVersion":"2015-10-01",
  "RecordType":"A",
  "StartRule":"geo_dest",
  "Endpoints":{
    "english":{
      "Type":"value",
      "Value":"192.0.2.1"
    },
    "french":{
      "Type":"value",
      "Value":"192.0.2.2"
    },
    "german":{
      "Type":"value",
      "Value":"192.0.2.3"
    }
  },
  "Rules":{
    "geo_dest":{
      "RuleType":"geo",
      "Locations":[
        {
          "EndpointReference":"english",
          "Country":"*",
          "HealthCheck":"11111111-1111-1111-1111-111111111111"
        },
        {
          "EndpointReference":"french",
          "Country":"FR",
          "IsDefault":false,
          "HealthCheck":"22222222-2222-2222-2222-222222222222"
        },
        {
          "EndpointReference":"french",
          "Country":"BE",
          "IsDefault":false,
          "HealthCheck":"22222222-2222-2222-2222-222222222222"
        },
        {
          "EndpointReference":"german",
          "Country":"DE",
          "IsDefault":false,
          "HealthCheck":"33333333-3333-3333-3333-333333333333"
        }
      ]
    }
  }
}
```

### 地理的近接性の例
<a name="traffic-policy-document-format-examples-proximity"></a>

```
{
  "AWSPolicyFormatVersion":"2015-10-01",
  "RecordType":"A",
  "StartRule":"geoprox-rule",
  "Endpoints":{
    "aws-us-west-1-region":{
      "Type":"elastic-load-balancer",
      "Value":"elb-123456.us-east-1.elb.amazonaws.com"
    },
    "london-data-center":{
      "Type":"value",
      "Value":"192.0.2.1"
    }
  },
  "Rules":{
    "geoprox-rule":{
      "RuleType": "geoproximity",
      "GeoproximityLocations": [
        {
          "EndpointReference": "aws-us-west-1-region",
          "Region": "aws:route53:us-west-1",
          "Bias": "10",
          "HealthCheck": "11111111-1111-1111-1111-111111111111"
        },
        {
          "EndpointReference": "london-data-center",
          "Latitude": "51.50",
          "Longitude": "-0.16",
          "Bias": "0",
          "HealthCheck": "22222222-2222-2222-2222-222222222222"
        }
      ]
    }
  }
}
```

```
{
  "AWSPolicyFormatVersion":"2023-05-09",
  "RecordType":"A",
  "StartRule":"geoprox-rule",
  "Endpoints":{
    "aws-us-west-1-region":{
      "Type":"elastic-load-balancer",
      "Value":"elb-123456.us-west-1.elb.amazonaws.com"
    },
    "aws-us-east-1-atl-local-zone":{
      "Type":"elastic-load-balancer",
      "Value":"elb-123456.us-east-1.elb.amazonaws.com"
    },
    "london-data-center":{
      "Type":"value",
      "Value":"192.0.2.1"
    }
  },
  "Rules":{
    "geoprox-rule":{
      "RuleType": "geoproximity",
      "GeoproximityLocations": [
        {
          "EndpointReference": "aws-us-west-1-region",
          "Location": {
            "Type": "Region",
            "LocationName": "aws:route53:us-west-1"
          },
          "Bias": "-10",
          "HealthCheck": "11111111-1111-1111-1111-111111111111"
        },
        {
          "EndpointReference": "aws-us-east-1-atl-local-zone",
          "Location": {
            "Type": "LocalZone",
            "LocationName": "aws:route53:us-east-1-atl-1a"
          },
          "Bias": "10",
          "HealthCheck": "22222222-2222-2222-2222-222222222222"
        },
        {
          "EndpointReference": "london-data-center",
          "Location": {
            "Type": "Coordinate",
            "Latitude": "51.50",
            "Longitude": "-0.16"
          },
          "Bias": "0",
          "HealthCheck": "33333333-3333-3333-3333-333333333333"
        }
      ]
    }
  }
}
```

### レイテンシーの例
<a name="traffic-policy-document-format-examples-latency"></a>

```
{
  "AWSPolicyFormatVersion":"2015-10-01",
  "RecordType":"A",
  "StartRule":"region_selector",
  "Endpoints":{
    "us_lb":{
      "Type":"elastic-load-balancer",
      "Value":"elb-123456.us-east-1.elb.amazonaws.com"
    },
    "europe_lb":{
      "Type":"elastic-load-balancer",
      "Value":"elb-654321.eu-west-1.elb.amazonaws.com"
    }
  },
  "Rules":{
    "region_selector":{
      "RuleType":"latency",
      "Regions":[
        {
          "Region":"us-east-1",
          "EndpointReference":"us_lb"
        },
        {
          "Region":"eu-west-1",
          "EndpointReference":"europe_lb"
        }
      ]
    }
  }
}
```

### 加重例
<a name="traffic-policy-document-format-examples-weighted"></a>

```
{
  "AWSPolicyFormatVersion":"2015-10-01",
  "RecordType":"A",
  "StartRule":"round_robin",
  "Endpoints":{
    "srv1":{
      "Type":"value",
      "Value":"192.0.2.1"
    },
    "srv2":{
      "Type":"value",
      "Value":"192.0.2.2"
    },
    "srv3":{
      "Type":"value",
      "Value":"192.0.2.3"
    }
  },
  "Rules":{
    "round_robin":{
      "RuleType":"weighted",
      "Items":[
        {
          "EndpointReference":"srv1",
          "Weight":"3",
          "HealthCheck":"11111111-1111-1111-1111-111111111111"
        },
        {
          "EndpointReference":"srv2",
          "Weight":"1",
          "HealthCheck":"22222222-2222-2222-2222-222222222222"
        },
        {
          "EndpointReference":"srv3",
          "Weight":"1",
          "HealthCheck":"33333333-3333-3333-3333-333333333333"
        }
      ]
    }
  }
}
```

### フェイルオーバー、レイテンシー、位置情報ルールの例
<a name="traffic-policy-document-format-examples-combined"></a>

```
{
  "AWSPolicyFormatVersion":"2015-10-01",
  "RecordType":"A",
  "StartRule":"geo_restriction",
  "Endpoints":{
    "east_coast_lb1":{
      "Type":"elastic-load-balancer",
      "Value":"elb-111111.us-east-1.elb.amazonaws.com"
    },
    "east_coast_lb2":{
      "Type":"elastic-load-balancer",
      "Value":"elb-222222.us-east-1.elb.amazonaws.com"
    },
    "west_coast_lb1":{
      "Type":"elastic-load-balancer",
      "Value":"elb-111111.us-west-1.elb.amazonaws.com"
    },
    "west_coast_lb2":{
      "Type":"elastic-load-balancer",
      "Value":"elb-222222.us-west-1.elb.amazonaws.com"
    },
    "denied_message":{
      "Type":"s3-website",
      "Region":"us-east-1",
      "Value":"video.example.com"
    }
  },
  "Rules":{
    "geo_restriction":{
      "RuleType":"geo",
      "Locations":[
        {
          "EndpointReference":"denied_message",
          "IsDefault":true
        },
        {
          "RuleReference":"region_selector",
          "Country":"US"
        }
      ]
    },
    "region_selector":{
      "RuleType":"latency",
      "Regions":[
        {
          "Region":"us-east-1",
          "RuleReference":"east_coast_region"
        },
        {
          "Region":"us-west-1",
          "RuleReference":"west_coast_region"
        }
      ]
    },
    "east_coast_region":{
      "RuleType":"failover",
      "Primary":{
        "EndpointReference":"east_coast_lb1"
      },
      "Secondary":{
        "EndpointReference":"east_coast_lb2"
      }
    },
    "west_coast_region":{
      "RuleType":"failover",
      "Primary":{
        "EndpointReference":"west_coast_lb1"
      },
      "Secondary":{
        "EndpointReference":"west_coast_lb2"
      }
    }
  }
}
```