本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用 Amazon CLI 带区域移位的示例
本节介绍使用区域偏移的简单应用示例,以及使用 API 操作在 Amazon Command Line Interface Amazon Route 53 应用程序恢复控制器中使用区域移位功能。这些示例旨在帮助您基本了解如何使用 CLI 处理区域偏移。
Route 53 ARC 中的区域切换允许您暂时将受支持资源的流量从可用区移开,这样您的应用程序就可以继续在中的其他可用区域正常运行。 Amazon Web Services 区域可用区转移目前支持关闭了跨可用区负载均衡的网络负载均衡器和应用程序负载均衡器。
我们来看一个使用 Amazon Command Line Interface开始可用区转移的示例。您也可以使用 Amazon CLI 更新可用区转移,例如,设置新的到期时间。所有可用区转移都是暂时性的,最初必须设置为三天内到期。但是您后期可以更新可用区转移,以设置新的到期时间。
有关使用的更多信息 Amazon CLI,请参阅Amazon CLI 命令参考。有关可用区转移 API 操作的列表和指向更多信息的链接,请参阅可用区转移 API 操作。
启动可用区转移
您可以使用 start-zonal-shift
命令在 CLI 中启动可用区转移。
aws arc-zonal-shift start-zonal-shift \ --resource-identifier="arn:aws:testservice::111122223333:ExampleALB123456890" \ --away-from="usw2-az1" \ --expires-in="5m" \ --comment="Shifting traffic away from USW2-AZ1"
{ "zonalShiftId": "2222222-3333-444-1111", "resourceIdentifier": "arn:aws:testservice::111122223333:ExampleALB123456890", "awayFrom": "usw2-az1", "expiryTime": 2022-11-14T01:40:42+00:00, "startTime": 2022-11-14T01:35:42+00:00, "status": "ACTIVE", "comment": "Shifting traffic away from USW2-AZ1" }
获取托管资源
您可以使用 get-managed-resource
命令在 CLI 中获取有关托管资源的信息。
aws arc-zonal-shift get-managed-resource \ --resource-identifier="arn:aws:testservice::111122223333:ExampleALB123456890
{ "arn": "arn:aws:testservice::111122223333:ExampleALB123456890", "name": "TestResource", "appliedWeights": { "usw2-az1": 1.0, "usw2-az2": 1.0, "usw2-az3": 1.0 }, "zonalShifts": [] }
列出托管资源
您可以使用 list-managed-resources
命令在 CLI 中列出您账户中的托管资源。
aws arc-zonal-shift list-managed-resources
{ "items": [ { "arn": "arn:aws:testservice::111122223333:ExampleALB123456890", "name": "TestResource", "availabilityZones": [ "usw2-az1", "usw2-az2", "usw2-az3" ] } ] }
列出可用区转移
您可以使用 list-zonal-shifts
命令在 CLI 中列出您账户中的可用区转移。
aws arc-zonal-shift list-zonal-shifts
{ "items": [ { "zonalShiftId": "2222222-3333-444-1111", "resourceIdentifier": "arn:aws:testservice::111122223333:ExampleALB123456890", "awayFrom": "usw2-az1", "expiryTime": 2022-11-15T09:10:42+00:00, "startTime": 2022-11-13T01:35:42+00:00, "status": "ACTIVE", "comment": "Shifting traffic away from USW2-AZ1" } ] }
更新可用区转移
您可以使用 update-zonal-shift
命令在 CLI 中更新可用区转移。
aws arc-zonal-shift update-zonal-shift \ --zonal-shift-id="="arn:aws:testservice::111122223333:ExampleALB123456890" \ --expires-in="1h" \ --comment="Still shifting traffic away from USW2-AZ1"
{ "zonalShiftId": "2222222-3333-444-1111", "resourceIdentifier": "arn:aws:testservice::111122223333:ExampleALB123456890", "awayFrom": "usw2-az1", "expiryTime": 2022-11-15T10:35:42+00:00, "startTime": 2022-11-15T09:35:42+00:00, "status": "ACTIVE", "comment": "Still shifting traffic away from USW2-AZ1" }
取消可用区转移
您可以使用 cancel-zonal-shift
命令在 CLI 中取消可用区转移。
aws arc-zonal-shift cancel-zonal-shift \ --zonal-shift-id="="arn:aws:testservice::111122223333:ExampleALB123456890"
{ "zonalShiftId": "2222222-3333-444-1111", "resourceIdentifier": "arn:aws:testservice::111122223333:ExampleALB123456890", "awayFrom": "usw2-az1", "expiryTime": 2022-11-15T10:35:42+00:00, "startTime": 2022-11-15T09:35:42+00:00, "status": "CANCELED", "comment": "Shifting traffic away from USW2-AZ1" }