使用 Lightsail 示例 AWS CLI - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用 Lightsail 示例 AWS CLI

以下代码示例向您展示了如何使用 with Lightsail 来执行操作和实现常见场景。 AWS Command Line Interface

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接,您可以在其中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例演示如何使用 allocate-static-ip

AWS CLI

创建静态 IP

以下allocate-static-ip示例创建了可以附加到实例的指定静态 IP。

aws lightsail allocate-static-ip \ --static-ip-name StaticIp-1

输出:

{ "operations": [ { "id": "b5d06d13-2f19-4683-889f-dEXAMPLEed79", "resourceName": "StaticIp-1", "resourceType": "StaticIp", "createdAt": 1571071325.076, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "AllocateStaticIp", "status": "Succeeded", "statusChangedAt": 1571071325.274 } ] }

以下代码示例演示如何使用 attach-disk

AWS CLI

将块存储磁盘挂接到实例

以下attach-disk示例将磁盘挂载Disk-1到实例上WordPress_Multisite-1,磁盘路径为 /dev/xvdf

aws lightsail attach-disk \ --disk-name Disk-1 \ --disk-path /dev/xvdf \ --instance-name WordPress_Multisite-1

输出:

{ "operations": [ { "id": "10a08267-19ce-43be-b913-6EXAMPLE7e80", "resourceName": "Disk-1", "resourceType": "Disk", "createdAt": 1571071465.472, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "WordPress_Multisite-1", "operationType": "AttachDisk", "status": "Started", "statusChangedAt": 1571071465.472 }, { "id": "2912c477-5295-4539-88c9-bEXAMPLEd1f0", "resourceName": "WordPress_Multisite-1", "resourceType": "Instance", "createdAt": 1571071465.474, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "Disk-1", "operationType": "AttachDisk", "status": "Started", "statusChangedAt": 1571071465.474 } ] }

以下代码示例演示如何使用 attach-instances-to-load-balancer

AWS CLI

将实例连接到负载均衡器

以下attach-instances-to-load-balancer示例将实例MEAN-1MEAN-2、和附加MEAN-3到负载均衡器LoadBalancer-1

aws lightsail attach-instances-to-load-balancer \ --instance-names {"MEAN-1","MEAN-2","MEAN-3"} \ --load-balancer-name LoadBalancer-1

输出:

{ "operations": [ { "id": "8055d19d-abb2-40b9-b527-1EXAMPLE3c7b", "resourceName": "LoadBalancer-1", "resourceType": "LoadBalancer", "createdAt": 1571071699.892, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "MEAN-2", "operationType": "AttachInstancesToLoadBalancer", "status": "Started", "statusChangedAt": 1571071699.892 }, { "id": "c35048eb-8538-456a-a118-0EXAMPLEfb73", "resourceName": "MEAN-2", "resourceType": "Instance", "createdAt": 1571071699.887, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "LoadBalancer-1", "operationType": "AttachInstancesToLoadBalancer", "status": "Started", "statusChangedAt": 1571071699.887 }, { "id": "910d09e0-adc5-4372-bc2e-0EXAMPLEd891", "resourceName": "LoadBalancer-1", "resourceType": "LoadBalancer", "createdAt": 1571071699.882, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "MEAN-3", "operationType": "AttachInstancesToLoadBalancer", "status": "Started", "statusChangedAt": 1571071699.882 }, { "id": "178b18ac-43e8-478c-9bed-1EXAMPLE4755", "resourceName": "MEAN-3", "resourceType": "Instance", "createdAt": 1571071699.901, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "LoadBalancer-1", "operationType": "AttachInstancesToLoadBalancer", "status": "Started", "statusChangedAt": 1571071699.901 }, { "id": "fb62536d-2a98-4190-a6fc-4EXAMPLE7470", "resourceName": "LoadBalancer-1", "resourceType": "LoadBalancer", "createdAt": 1571071699.885, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "MEAN-1", "operationType": "AttachInstancesToLoadBalancer", "status": "Started", "statusChangedAt": 1571071699.885 }, { "id": "787dac0d-f98d-46c3-8571-3EXAMPLE5a85", "resourceName": "MEAN-1", "resourceType": "Instance", "createdAt": 1571071699.901, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "LoadBalancer-1", "operationType": "AttachInstancesToLoadBalancer", "status": "Started", "statusChangedAt": 1571071699.901 } ] }

以下代码示例演示如何使用 attach-load-balancer-tls-certificate

AWS CLI

将TLS证书附加到负载均衡器

以下attach-load-balancer-tls-certificate示例将负载均衡器TLS证书附加Certificate2到负载均衡器LoadBalancer-1

aws lightsail attach-load-balancer-tls-certificate \ --certificate-name Certificate2 \ --load-balancer-name LoadBalancer-1

输出:

{ "operations": [ { "id": "cf1ad6e3-3cbb-4b8a-a7f2-3EXAMPLEa118", "resourceName": "LoadBalancer-1", "resourceType": "LoadBalancer", "createdAt": 1571072255.416, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "Certificate2", "operationType": "AttachLoadBalancerTlsCertificate", "status": "Succeeded", "statusChangedAt": 1571072255.416 }, { "id": "dae1bcfb-d531-4c06-b4ea-bEXAMPLEc04e", "resourceName": "Certificate2", "resourceType": "LoadBalancerTlsCertificate", "createdAt": 1571072255.416, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "LoadBalancer-1", "operationType": "AttachLoadBalancerTlsCertificate", "status": "Succeeded", "statusChangedAt": 1571072255.416 } ] }

以下代码示例演示如何使用 attach-static-ip

AWS CLI

将静态 IP 附加到实例

以下attach-static-ip示例将静态 IP 附加StaticIp-1到实例MEAN-1

aws lightsail attach-static-ip \ --static-ip-name StaticIp-1 \ --instance-name MEAN-1

输出:

{ "operations": [ { "id": "45e6fa13-4808-4b8d-9292-bEXAMPLE20b2", "resourceName": "StaticIp-1", "resourceType": "StaticIp", "createdAt": 1571072569.375, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "MEAN-1", "operationType": "AttachStaticIp", "status": "Succeeded", "statusChangedAt": 1571072569.375 }, { "id": "9ee09a17-863c-4e51-8a6d-3EXAMPLE5475", "resourceName": "MEAN-1", "resourceType": "Instance", "createdAt": 1571072569.376, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "StaticIp-1", "operationType": "AttachStaticIp", "status": "Succeeded", "statusChangedAt": 1571072569.376 } ] }

以下代码示例演示如何使用 close-instance-public-ports

AWS CLI

关闭实例的防火墙端口

以下close-instance-public-ports示例关闭了实例22上的TCP端口MEAN-2

aws lightsail close-instance-public-ports \ --instance-name MEAN-2 \ --port-info fromPort=22,protocol=TCP,toPort=22

输出:

{ "operation": { "id": "4f328636-1c96-4649-ae6d-1EXAMPLEf446", "resourceName": "MEAN-2", "resourceType": "Instance", "createdAt": 1571072845.737, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "22/tcp", "operationType": "CloseInstancePublicPorts", "status": "Succeeded", "statusChangedAt": 1571072845.737 } }

以下代码示例演示如何使用 copy-snapshot

AWS CLI

示例 1:在同一 AWS 区域内复制快照

以下copy-snapshot示例将实例快照复制MEAN-1-1571075291为同一 AWS 区域MEAN-1-Copy内的实例快照us-west-2

aws lightsail copy-snapshot \ --source-snapshot-name MEAN-1-1571075291 \ --target-snapshot-name MEAN-1-Copy \ --source-region us-west-2

输出:

{ "operations": [ { "id": "ced16fc1-f401-4556-8d82-1EXAMPLEb982", "resourceName": "MEAN-1-Copy", "resourceType": "InstanceSnapshot", "createdAt": 1571075581.498, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "us-west-2:MEAN-1-1571075291", "operationType": "CopySnapshot", "status": "Started", "statusChangedAt": 1571075581.498 } ] }

有关更多信息,请参阅《Lightsail 开发者指南》中的 Amazon Lightsail 中将快照从一个 AWS 区域复制到另一个区域。

示例 2:将快照从一个 AWS 区域复制到另一个区域

以下copy-snapshot示例将实例快照MEAN-1-1571075291作为实例快照MEAN-1-1571075291-Copy从 AWS Region 复制us-west-2us-east-1

aws lightsail copy-snapshot \ --source-snapshot-name MEAN-1-1571075291 \ --target-snapshot-name MEAN-1-1571075291-Copy \ --source-region us-west-2 \ --region us-east-1

输出:

{ "operations": [ { "id": "91116b79-119c-4451-b44a-dEXAMPLEd97b", "resourceName": "MEAN-1-1571075291-Copy", "resourceType": "InstanceSnapshot", "createdAt": 1571075695.069, "location": { "availabilityZone": "all", "regionName": "us-east-1" }, "isTerminal": false, "operationDetails": "us-west-2:MEAN-1-1571075291", "operationType": "CopySnapshot", "status": "Started", "statusChangedAt": 1571075695.069 } ] }

有关更多信息,请参阅《Lightsail 开发者指南》中的 Amazon Lightsail 中将快照从一个 AWS 区域复制到另一个区域。

示例 3:在同一 AWS 区域内复制自动快照

以下copy-snapshot示例将实例2019-10-14的自动快照复制WordPress-1为 AWS 区域WordPress-1-10142019中的手动快照us-west-2

aws lightsail copy-snapshot \ --source-resource-name WordPress-1 \ --restore-date 2019-10-14 \ --target-snapshot-name WordPress-1-10142019 \ --source-region us-west-2

输出:

{ "operations": [ { "id": "be3e6754-cd1d-48e6-ad9f-2EXAMPLE1805", "resourceName": "WordPress-1-10142019", "resourceType": "InstanceSnapshot", "createdAt": 1571082412.311, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "us-west-2:WordPress-1", "operationType": "CopySnapshot", "status": "Started", "statusChangedAt": 1571082412.311 } ] }

有关更多信息,请参阅 Lightsail 开发者指南中的在 Amazon Lightsail 中保存实例或磁盘的自动快照

示例 4:将自动快照从一个 AWS 区域复制到另一个区域

以下copy-snapshot示例将实例2019-10-14的自动快照WordPress-1作为手动快照WordPress-1-10142019从 AWS 区域复制us-west-2us-east-1

aws lightsail copy-snapshot \ --source-resource-name WordPress-1 \ --restore-date 2019-10-14 \ --target-snapshot-name WordPress-1-10142019 \ --source-region us-west-2 \ --region us-east-1

输出:

{ "operations": [ { "id": "dffa128b-0b07-476e-b390-bEXAMPLE3775", "resourceName": "WordPress-1-10142019", "resourceType": "InstanceSnapshot", "createdAt": 1571082493.422, "location": { "availabilityZone": "all", "regionName": "us-east-1" }, "isTerminal": false, "operationDetails": "us-west-2:WordPress-1", "operationType": "CopySnapshot", "status": "Started", "statusChangedAt": 1571082493.422 } ] }

有关更多信息,请参阅 Lightsail 开发者指南中的在 Amazon Lightsail 中保存实例或磁盘的自动快照

以下代码示例演示如何使用 create-disk-from-snapshot

AWS CLI

使用磁盘快照创建磁盘

以下create-disk-from-snapshot示例根据指定的块存储磁盘快照创建了一个Disk-2名为的块存储磁盘。该磁盘在指定的 AWS 区域和可用区中创建,存储空间为 32 GB。

aws lightsail create-disk-from-snapshot \ --disk-name Disk-2 \ --disk-snapshot-name Disk-1-1566839161 \ --availability-zone us-west-2a \ --size-in-gb 32

输出:

{ "operations": [ { "id": "d42b605d-5ef1-4b4a-8791-7a3e8b66b5e7", "resourceName": "Disk-2", "resourceType": "Disk", "createdAt": 1569624941.471, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "CreateDiskFromSnapshot", "status": "Started", "statusChangedAt": 1569624941.791 } ] }

有关更多信息,请参阅 Lights ail 开发者指南中的在 Amazon Lightsail 中使用快照创建块存储磁盘

以下代码示例演示如何使用 create-disk-snapshot

AWS CLI

示例 1:创建磁盘快照

以下create-disk-snapshot示例创建了指定块存储磁盘DiskSnapshot-1的名为的快照。

aws lightsail create-disk-snapshot \ --disk-name Disk-1 \ --disk-snapshot-name DiskSnapshot-1

输出:

{ "operations": [ { "id": "fa74c6d2-03a3-4f42-a7c7-792f124d534b", "resourceName": "DiskSnapshot-1", "resourceType": "DiskSnapshot", "createdAt": 1569625129.739, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "Disk-1", "operationType": "CreateDiskSnapshot", "status": "Started", "statusChangedAt": 1569625129.739 }, { "id": "920a25df-185c-4528-87cd-7b85f5488c06", "resourceName": "Disk-1", "resourceType": "Disk", "createdAt": 1569625129.739, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "DiskSnapshot-1", "operationType": "CreateDiskSnapshot", "status": "Started", "statusChangedAt": 1569625129.739 } ] }

示例 2:创建实例系统磁盘的快照

以下create-disk-snapshot示例创建指定实例系统磁盘的快照。

aws lightsail create-disk-snapshot \ --instance-name WordPress-1 \ --disk-snapshot-name SystemDiskSnapshot-1

输出:

{ "operations": [ { "id": "f508cf1c-6597-42a6-a4c3-4aebd75af0d9", "resourceName": "SystemDiskSnapshot-1", "resourceType": "DiskSnapshot", "createdAt": 1569625294.685, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "WordPress-1", "operationType": "CreateDiskSnapshot", "status": "Started", "statusChangedAt": 1569625294.685 }, { "id": "0bb9f712-da3b-4d99-b508-3bf871d989e5", "resourceName": "WordPress-1", "resourceType": "Instance", "createdAt": 1569625294.685, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "SystemDiskSnapshot-1", "operationType": "CreateDiskSnapshot", "status": "Started", "statusChangedAt": 1569625294.685 } ] }

有关更多信息,请参阅 Lightsail 开发者指南中的亚马逊 Lightsail 中的快照和在 Amazon Lightsail 中创建实例根卷的快照。

以下代码示例演示如何使用 create-disk

AWS CLI

创建块存储磁盘

以下create-disk示例在指定的 AWS 区域和可用区Disk-1中创建一个具有 32 GB 存储空间的块存储磁盘。

aws lightsail create-disk \ --disk-name Disk-1 \ --availability-zone us-west-2a \ --size-in-gb 32

输出:

{ "operations": [ { "id": "1c85e2ec-86ba-4697-b936-77f4d3dc013a", "resourceName": "Disk-1", "resourceType": "Disk", "createdAt": 1569449220.36, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "CreateDisk", "status": "Started", "statusChangedAt": 1569449220.588 } ] }

以下代码示例演示如何使用 create-domain-entry

AWS CLI

创建域名条目(DNS记录)

以下create-domain-entry示例为指定域的顶点创建一条指向实例 IP 地址的DNS记录 (A)。

注意:Lightsail 的域名相关API操作仅在该地区可用。us-east-1如果您的CLI配置文件配置为使用其他区域,则必须包含该--region us-east-1参数,否则命令将失败。

aws lightsail create-domain-entry \ --region us-east-1 \ --domain-name example.com \ --domain-entry name=example.com,type=A,target=192.0.2.0

输出:

{ "operation": { "id": "5be4494d-56f4-41fc-8730-693dcd0ef9e2", "resourceName": "example.com", "resourceType": "Domain", "createdAt": 1569865296.519, "location": { "availabilityZone": "all", "regionName": "global" }, "isTerminal": true, "operationType": "CreateDomainEntry", "status": "Succeeded", "statusChangedAt": 1569865296.519 } }

有关更多信息,请参阅 DNSAmazon Lightsail 和《Lightsail 开发者指南》中的 “在亚马逊 Lightsail 中创建DNS区域来管理您的域名DNS记录”。

以下代码示例演示如何使用 create-domain

AWS CLI

创建域(DNS区域)

以下create-domain示例为指定域创建DNS区域。

注意:Lightsail 的域名相关API操作仅在该地区可用。us-east-1如果您的CLI配置文件配置为使用其他区域,则必须包含该--region us-east-1参数,否则命令将失败。

aws lightsail create-domain \ --region us-east-1 \ --domain-name example.com

输出:

{ "operation": { "id": "64e522c8-9ae1-4c05-9b65-3f237324dc34", "resourceName": "example.com", "resourceType": "Domain", "createdAt": 1569864291.92, "location": { "availabilityZone": "all", "regionName": "global" }, "isTerminal": true, "operationType": "CreateDomain", "status": "Succeeded", "statusChangedAt": 1569864292.109 } }

有关更多信息,请参阅 DNSAmazon Lightsail 和《Lightsail 开发者指南》中的 “在亚马逊 Lightsail 中创建DNS区域来管理您的域名DNS记录”。

以下代码示例演示如何使用 create-instance-snapshot

AWS CLI

创建实例的快照

以下create-instance-snapshot示例从指定实例创建快照。

aws lightsail create-instance-snapshot \ --instance-name WordPress-1 \ --instance-snapshot-name WordPress-Snapshot-1

输出:

{ "operations": [ { "id": "4c3db559-9dd0-41e7-89c0-2cb88c19786f", "resourceName": "WordPress-Snapshot-1", "resourceType": "InstanceSnapshot", "createdAt": 1569866438.48, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "WordPress-1", "operationType": "CreateInstanceSnapshot", "status": "Started", "statusChangedAt": 1569866438.48 }, { "id": "c04fdc45-2981-488c-88b5-d6d2fd759a6a", "resourceName": "WordPress-1", "resourceType": "Instance", "createdAt": 1569866438.48, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "WordPress-Snapshot-1", "operationType": "CreateInstanceSnapshot", "status": "Started", "statusChangedAt": 1569866438.48 } ] }

以下代码示例演示如何使用 create-instances-from-snapshot

AWS CLI

使用快照创建实例

以下create-instances-from-snapshot示例使用价值 12 美元的USD捆绑包,在指定的 AWS 区域和可用区中根据指定的实例快照创建实例。

注意:您指定的捆绑包的规格必须等于或大于用于创建快照的原始源实例的捆绑包。

aws lightsail create-instances-from-snapshot \ --instance-snapshot-name WordPress-1-1569866208 \ --instance-names WordPress-2 \ --availability-zone us-west-2a \ --bundle-id small_3_0

输出:

{ "operations": [ { "id": "003f8271-b711-464d-b9b8-7f3806cb496e", "resourceName": "WordPress-2", "resourceType": "Instance", "createdAt": 1569865914.908, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "CreateInstancesFromSnapshot", "status": "Started", "statusChangedAt": 1569865914.908 } ] }

以下代码示例演示如何使用 create-instances

AWS CLI

示例 1:创建单个实例

以下create-instances示例使用 WordPress 蓝图和 5.00 美元的USD捆绑包在指定的 AWS 区域和可用区创建实例。

aws lightsail create-instances \ --instance-names Instance-1 \ --availability-zone us-west-2a \ --blueprint-id wordpress \ --bundle-id nano_3_0

输出:

{ "operations": [ { "id": "9a77158f-7be3-4d6d-8054-cf5ae2b720cc", "resourceName": "Instance-1", "resourceType": "Instance", "createdAt": 1569447986.061, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "CreateInstance", "status": "Started", "statusChangedAt": 1569447986.061 } ] }

示例 2:一次创建多个实例

以下create-instances示例使用 WordPress 蓝图和 5.00 美元的USD捆绑包,在指定的 AWS 区域和可用区创建三个实例。

aws lightsail create-instances \ --instance-names {"Instance1","Instance2","Instance3"} \ --availability-zone us-west-2a \ --blueprint-id wordpress \ --bundle-id nano_3_0

输出:

{ "operations": [ { "id": "5492f015-9d2e-48c6-8eea-b516840e6903", "resourceName": "Instance1", "resourceType": "Instance", "createdAt": 1569448780.054, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "CreateInstance", "status": "Started", "statusChangedAt": 1569448780.054 }, { "id": "c58b5f46-2676-44c8-b95c-3ad375898515", "resourceName": "Instance2", "resourceType": "Instance", "createdAt": 1569448780.054, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "CreateInstance", "status": "Started", "statusChangedAt": 1569448780.054 }, { "id": "a5ad8006-9bee-4499-9eb7-75e42e6f5882", "resourceName": "Instance3", "resourceType": "Instance", "createdAt": 1569448780.054, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "CreateInstance", "status": "Started", "statusChangedAt": 1569448780.054 } ] }

以下代码示例演示如何使用 create-key-pair

AWS CLI

创建密钥对

以下create-key-pair示例创建了一个 key pair,您可以使用该密钥对进行身份验证和连接到实例。

aws lightsail create-key-pair \ --key-pair-name MyPersonalKeyPair

输出提供了私钥 base64 值,您可以使用该值对对使用已创建密钥对的实例进行身份验证。注意:将私钥 base64 值复制并粘贴到安全位置,因为以后无法检索它。

{ "keyPair": { "name": "MyPersonalKeyPair", "arn": "arn:aws:lightsail:us-west-2:111122223333:KeyPair/55025c71-198f-403b-b42f-a69433e724fb", "supportCode": "621291663362/MyPersonalKeyPair", "createdAt": 1569866556.567, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "KeyPair" }, "publicKeyBase64": "ssh-rsa ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCV0xUEwx96amPERH7K1bVT1tTFl9OmNk6o7m5YVHk9xlOdMbDRbFvhtXvw4jzJXXz5pBMxWOaGMz5K8QyTVOznoqp13Z8SBooH29hgmBNXiII1XPzEwqbj8mfo1+YVM5s5VuxWwm+BHUgedGUXno6uF7agqxZNO1kPLJBIVTW26SSYBJ0tE+y804UyVsjrbUqCaMXDhmfXpWulMPwuXhwcKh7e8hwoTfkiX0E6Ql+KqF/MiA3w6DCjEqvvdIO7SiEZJFsuGNfYDDN3w60Rel5MUhmn3OJdn4y/A7NWb3IxL4pPfVE4rgFRKU8n1jp9kwRnlVMVBOWuGXk6n+H6M2f1 ", "privateKeyBase64": "-----BEGIN RSA PRIVATE KEY-----EXAMPLETCCAfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC\nVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6\nb24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsEXAMPLEd\nBgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhcNMTEwNDI1MjA0NTIxWhcN\nMTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYD\nVQQHEwdTZWF0dGxlMQ8wDQEXAMPLEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25z\nb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFt\nYXpvbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMEXAMPLE4GmWIWJ\n21uUSfwfEvySWtC2XADZ4nB+BLYgVIk60CpiwsZ3G93vUEIO3IyNoH/f0wYK8m9T\nrDHudUZg3qX4waLG5M43q7Wgc/MbQITxOUSQv7c7ugFFDzQGBzZswY6786m86gpE\nIbb3OhjZnzcvQAaREXAMPLEMm2nrAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAtCu4\nnUhVVxYUntneD9+h8Mg9q6q+auNKyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0Fkb\nFFBjvSfpJIlJ00zbhNYS5f6GuoEDmFJl0ZxBHjJnyp378OEXAMPLELvjx79LjSTb\nNYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE=\n-----END RSA PRIVATE KEY-----", "operation": { "id": "67f984db-9994-45fe-ad38-59bafcaf82ef", "resourceName": "MyPersonalKeyPair", "resourceType": "KeyPair", "createdAt": 1569866556.567, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "CreateKeyPair", "status": "Succeeded", "statusChangedAt": 1569866556.704 } }

以下代码示例演示如何使用 create-load-balancer-tls-certificate

AWS CLI

为负载均衡器创建TLS证书

以下create-load-balancer-tls-certificate示例创建了一个附加到指定负载均衡器的TLS证书。创建的证书适用于指定的域。注意:只能为负载均衡器创建两个证书。

aws lightsail create-load-balancer-tls-certificate \ --certificate-alternative-names abc.example.com \ --certificate-domain-name example.com \ --certificate-name MySecondCertificate \ --load-balancer-name MyFirstLoadBalancer

输出:

{ "operations": [ { "id": "be663aed-cb46-41e2-9b23-e2f747245bd4", "resourceName": "MySecondCertificate", "resourceType": "LoadBalancerTlsCertificate", "createdAt": 1569867364.971, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "MyFirstLoadBalancer", "operationType": "CreateLoadBalancerTlsCertificate", "status": "Succeeded", "statusChangedAt": 1569867365.219 }, { "id": "f3dfa930-969e-41cc-ac7d-337178716f6d", "resourceName": "MyFirstLoadBalancer", "resourceType": "LoadBalancer", "createdAt": 1569867364.971, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "MySecondCertificate", "operationType": "CreateLoadBalancerTlsCertificate", "status": "Succeeded", "statusChangedAt": 1569867365.219 } ] }

以下代码示例演示如何使用 create-load-balancer

AWS CLI

创建负载均衡器

以下create-load-balancer示例使用TLS证书创建负载均衡器。该TLS证书适用于指定的域,并将流量路由到端口 80 上的实例。

aws lightsail create-load-balancer \ --certificate-alternative-names www.example.com test.example.com \ --certificate-domain-name example.com \ --certificate-name Certificate-1 \ --instance-port 80 \ --load-balancer-name LoadBalancer-1

输出:

{ "operations": [ { "id": "cc7b920a-83d8-4762-a74e-9174fe1540be", "resourceName": "LoadBalancer-1", "resourceType": "LoadBalancer", "createdAt": 1569867169.406, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "CreateLoadBalancer", "status": "Started", "statusChangedAt": 1569867169.406 }, { "id": "658ed43b-f729-42f3-a8e4-3f8024d3c98d", "resourceName": "LoadBalancer-1", "resourceType": "LoadBalancerTlsCertificate", "createdAt": 1569867170.193, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "LoadBalancer-1", "operationType": "CreateLoadBalancerTlsCertificate", "status": "Succeeded", "statusChangedAt": 1569867170.54 }, { "id": "4757a342-5181-4870-b1e0-227eebc35ab5", "resourceName": "LoadBalancer-1", "resourceType": "LoadBalancer", "createdAt": 1569867170.193, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "Certificate-1", "operationType": "CreateLoadBalancerTlsCertificate", "status": "Succeeded", "statusChangedAt": 1569867170.54 } ] }

有关更多信息,请参阅 Lightsail 开发者指南中的 Lightsail 负载均衡器

以下代码示例演示如何使用 create-relational-database-from-snapshot

AWS CLI

从快照创建托管数据库

以下create-relational-database-from-snapshot示例使用价值 15 美元的USD标准数据库捆绑包,从指定 AWS 区域和可用区的指定快照创建托管数据库。注:您指定的捆绑包的规格必须等于或大于用于创建快照的原始源数据库的捆绑包。

aws lightsail create-relational-database-from-snapshot \ --relational-database-snapshot-name Database-Oregon-1-1566839359 \ --relational-database-name Database-1 \ --availability-zone us-west-2a \ --relational-database-bundle-id micro_1_0 \ --no-publicly-accessible

输出:

{ "operations": [ { "id": "ad6d9193-9d5c-4ea1-97ae-8fe6de600b4c", "resourceName": "Database-1", "resourceType": "RelationalDatabase", "createdAt": 1569867916.938, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "CreateRelationalDatabaseFromSnapshot", "status": "Started", "statusChangedAt": 1569867918.643 } ] }

以下代码示例演示如何使用 create-relational-database-snapshot

AWS CLI

创建托管数据库的快照

以下create-relational-database-snapshot示例创建指定托管数据库的快照。

aws lightsail create-relational-database-snapshot \ --relational-database-name Database1 \ --relational-database-snapshot-name RelationalDatabaseSnapshot1

输出:

{ "operations": [ { "id": "853667fb-ea91-4c02-8d20-8fc5fd43b9eb", "resourceName": "RelationalDatabaseSnapshot1", "resourceType": "RelationalDatabaseSnapshot", "createdAt": 1569868074.645, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "Database1", "operationType": "CreateRelationalDatabaseSnapshot", "status": "Started", "statusChangedAt": 1569868074.645 }, { "id": "fbafa521-3cac-4be8-9773-1c143780b239", "resourceName": "Database1", "resourceType": "RelationalDatabase", "createdAt": 1569868074.645, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "RelationalDatabaseSnapshot1", "operationType": "CreateRelationalDatabaseSnapshot", "status": "Started", "statusChangedAt": 1569868074.645 } ] }

以下代码示例演示如何使用 create-relational-database

AWS CLI

创建托管数据库

以下create-relational-database示例使用 My SQL 5.6 数据库引擎 (mysql_5_6) 和价值 15 美元的USD标准数据库捆绑包 (micro_1_0) 在指定的 AWS 区域和可用区创建托管数据库。托管数据库已预先填充主用户名,不可公开访问。

aws lightsail create-relational-database \ --relational-database-name Database-1 \ --availability-zone us-west-2a \ --relational-database-blueprint-id mysql_5_6 \ --relational-database-bundle-id micro_1_0 \ --master-database-name dbmaster \ --master-username user \ --no-publicly-accessible

输出:

{ "operations": [ { "id": "b52bedee-73ed-4798-8d2a-9c12df89adcd", "resourceName": "Database-1", "resourceType": "RelationalDatabase", "createdAt": 1569450017.244, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "CreateRelationalDatabase", "status": "Started", "statusChangedAt": 1569450018.637 } ] }

以下代码示例演示如何使用 delete-auto-snapshot

AWS CLI

删除自动快照

以下delete-auto-snapshot示例删除了实例2019-10-10的自动快照WordPress-1

aws lightsail delete-auto-snapshot \ --resource-name WordPress-1 \ --date 2019-10-10

输出:

{ "operations": [ { "id": "31c36e09-3d52-46d5-b6d8-7EXAMPLE534a", "resourceName": "WordPress-1", "resourceType": "Instance", "createdAt": 1571088141.501, "location": { "availabilityZone": "us-west-2", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "DeleteAutoSnapshot-2019-10-10", "operationType": "DeleteAutoSnapshot", "status": "Succeeded" } ] }

有关更多信息,请参阅 Lightsail 开发者指南中的在 Amazon Lightsail 中删除实例或磁盘的自动快照

以下代码示例演示如何使用 delete-disk-snapshot

AWS CLI

删除块存储磁盘的快照

以下delete-disk-snapshot示例删除块存储磁盘的指定快照

aws lightsail delete-disk-snapshot \ --disk-snapshot-name DiskSnapshot-1

输出:

{ "operations": [ { "id": "d1e5766d-b81e-4595-ad5d-02afbccfcd5d", "resourceName": "DiskSnapshot-1", "resourceType": "DiskSnapshot", "createdAt": 1569873552.79, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "DeleteDiskSnapshot", "status": "Succeeded", "statusChangedAt": 1569873552.79 } ] }

以下代码示例演示如何使用 delete-disk

AWS CLI

删除块存储磁盘

以下delete-disk示例删除了指定的块存储磁盘。

aws lightsail delete-disk \ --disk-name Disk-1

输出:

{ "operations": [ { "id": "6378c70f-4d75-4f7a-ab66-730fca0bb2fc", "resourceName": "Disk-1", "resourceType": "Disk", "createdAt": 1569872887.864, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "DeleteDisk", "status": "Succeeded", "statusChangedAt": 1569872887.864 } ] }

以下代码示例演示如何使用 delete-domain-entry

AWS CLI

删除域名条目(DNS记录)

以下delete-domain-entry示例从现有域中删除指定的域条目。

注意:Lightsail 的域名相关API操作仅在该地区可用。us-east-1如果您的CLI配置文件配置为使用其他区域,则必须包含该--region us-east-1参数,否则命令将失败。

aws lightsail delete-domain-entry \ --region us-east-1 \ --domain-name example.com \ --domain-entry name=123.example.com,target=192.0.2.0,type=A

输出:

{ "operation": { "id": "06eacd01-d785-420e-8daa-823150c7dca1", "resourceName": "example.com ", "resourceType": "Domain", "createdAt": 1569874157.005, "location": { "availabilityZone": "all", "regionName": "global" }, "isTerminal": true, "operationType": "DeleteDomainEntry", "status": "Succeeded", "statusChangedAt": 1569874157.005 } }

以下代码示例演示如何使用 delete-domain

AWS CLI

删除域(DNS区域)

以下delete-domain示例删除了指定的域和该域中的所有条目(DNS记录)。

注意:Lightsail 的域名相关API操作仅在该地区可用。us-east-1如果您的CLI配置文件配置为使用其他区域,则必须包含该--region us-east-1参数,否则命令将失败。

aws lightsail delete-domain \ --region us-east-1 \ --domain-name example.com

输出:

{ "operation": { "id": "fcef5265-5af1-4a46-a3d7-90b5e18b9b32", "resourceName": "example.com", "resourceType": "Domain", "createdAt": 1569873788.13, "location": { "availabilityZone": "all", "regionName": "global" }, "isTerminal": true, "operationType": "DeleteDomain", "status": "Succeeded", "statusChangedAt": 1569873788.13 } }

以下代码示例演示如何使用 delete-instance-snapshot

AWS CLI

title

以下delete-instance-snapshot示例删除了实例的指定快照。

aws lightsail delete-instance-snapshot \ --instance-snapshot-name WordPress-1-Snapshot-1

输出:

{ "operations": [ { "id": "14dad182-976a-46c6-bfd4-9480482bf0ea", "resourceName": "WordPress-1-Snapshot-1", "resourceType": "InstanceSnapshot", "createdAt": 1569874524.562, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "DeleteInstanceSnapshot", "status": "Succeeded", "statusChangedAt": 1569874524.562 } ] }

以下代码示例演示如何使用 delete-instance

AWS CLI

删除实例

以下delete-instance示例删除了指定的实例。

aws lightsail delete-instance \ --instance-name WordPress-1

输出:

{ "operations": [ { "id": "d77345a3-8f80-4d2e-b47d-aaa622718df2", "resourceName": "Disk-1", "resourceType": "Disk", "createdAt": 1569874357.469, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "WordPress-1", "operationType": "DetachDisk", "status": "Started", "statusChangedAt": 1569874357.469 }, { "id": "708fa606-2bfd-4e48-a2c1-0b856585b5b1", "resourceName": "WordPress-1", "resourceType": "Instance", "createdAt": 1569874357.465, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "Disk-1", "operationType": "DetachDisk", "status": "Started", "statusChangedAt": 1569874357.465 }, { "id": "3187e823-8acb-405d-b098-fad5ceb17bec", "resourceName": "WordPress-1", "resourceType": "Instance", "createdAt": 1569874357.829, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "DeleteInstance", "status": "Succeeded", "statusChangedAt": 1569874357.829 } ] }

以下代码示例演示如何使用 delete-key-pair

AWS CLI

删除密钥对

以下delete-key-pair示例删除指定的 key pair。

aws lightsail delete-key-pair \ --key-pair-name MyPersonalKeyPair

输出:

{ "operation": { "id": "81621463-df38-4810-b866-6e801a15abbf", "resourceName": "MyPersonalKeyPair", "resourceType": "KeyPair", "createdAt": 1569874626.466, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "DeleteKeyPair", "status": "Succeeded", "statusChangedAt": 1569874626.685 } }

以下代码示例演示如何使用 delete-known-host-keys

AWS CLI

从实例中删除已知的主机密钥

以下delete-known-host-keys示例从指定实例中删除已知的主机密钥。

aws lightsail delete-known-host-keys \ --instance-name Instance-1

输出:

{ "operations": [ { "id": "c61afe9c-45a4-41e6-a97e-d212364da3f5", "resourceName": "Instance-1", "resourceType": "Instance", "createdAt": 1569874760.201, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "DeleteKnownHostKeys", "status": "Succeeded", "statusChangedAt": 1569874760.201 } ] }

有关更多信息,请参阅 Lightsail 开发者指南中的解决基于亚马逊 Lightsail 浏览器SSH或RDP客户端的连接问题

以下代码示例演示如何使用 delete-load-balancer-tls-certificate

AWS CLI

删除负载均衡器的TLS证书

以下delete-load-balancer-tls-certificate示例从指定的负载均衡器中删除指定TLS证书。

aws lightsail delete-load-balancer-tls-certificate \ --load-balancer-name MyFirstLoadBalancer \ --certificate-name MyFirstCertificate

输出:

{ "operations": [ { "id": "50bec274-e45e-4caa-8a69-b763ef636583", "resourceName": "MyFirstCertificate", "resourceType": "LoadBalancerTlsCertificate", "createdAt": 1569874989.48, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "DeleteLoadBalancerTlsCertificate", "status": "Started", "statusChangedAt": 1569874989.48 }, { "id": "78c58cdc-a59a-4b27-8213-500638634a8f", "resourceName": "MyFirstLoadBalancer", "resourceType": "LoadBalancer", "createdAt": 1569874989.48, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "DeleteLoadBalancerTlsCertificate", "status": "Started", "statusChangedAt": 1569874989.48 } ] }

以下代码示例演示如何使用 delete-load-balancer

AWS CLI

删除负载均衡器

以下delete-load-balancer示例删除了指定的负载均衡器和所有关联的TLS证书。

aws lightsail delete-load-balancer \ --load-balancer-name MyFirstLoadBalancer

输出:

{ "operations": [ { "id": "a8c968c7-72a3-4680-a714-af8f03eea535", "resourceName": "MyFirstLoadBalancer", "resourceType": "LoadBalancer", "createdAt": 1569875092.125, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "DeleteLoadBalancer", "status": "Succeeded", "statusChangedAt": 1569875092.125 }, { "id": "f91a29fc-8ce3-4e69-a227-ea70ca890bf5", "resourceName": "MySecondCertificate", "resourceType": "LoadBalancerTlsCertificate", "createdAt": 1569875091.938, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "DeleteLoadBalancerTlsCertificate", "status": "Started", "statusChangedAt": 1569875091.938 }, { "id": "cf64c060-154b-4eb4-ba57-84e2e41563d6", "resourceName": "MyFirstLoadBalancer", "resourceType": "LoadBalancer", "createdAt": 1569875091.94, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "DeleteLoadBalancerTlsCertificate", "status": "Started", "statusChangedAt": 1569875091.94 } ] }

有关更多信息,请参阅指南中的标题。

以下代码示例演示如何使用 delete-relational-database-snapshot

AWS CLI

删除托管数据库的快照

以下delete-relational-database-snapshot示例删除托管数据库的指定快照。

aws lightsail delete-relational-database-snapshot \ --relational-database-snapshot-name Database-Oregon-1-1566839359

输出:

{ "operations": [ { "id": "b99acae8-735b-4823-922f-30af580e3729", "resourceName": "Database-Oregon-1-1566839359", "resourceType": "RelationalDatabaseSnapshot", "createdAt": 1569875293.58, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "DeleteRelationalDatabaseSnapshot", "status": "Succeeded", "statusChangedAt": 1569875293.58 } ] }

以下代码示例演示如何使用 delete-relational-database

AWS CLI

删除托管数据库

以下delete-relational-database示例删除了指定的托管数据库。

aws lightsail delete-relational-database \ --relational-database-name Database-1

输出:

{ "operations": [ { "id": "3b0c41c1-053d-46f0-92a3-14f76141dc86", "resourceName": "Database-1", "resourceType": "RelationalDatabase", "createdAt": 1569875210.999, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "DeleteRelationalDatabase", "status": "Started", "statusChangedAt": 1569875210.999 }, { "id": "01ddeae8-a87a-4a4b-a1f3-092c71bf9180", "resourceName": "Database-1", "resourceType": "RelationalDatabase", "createdAt": 1569875211.029, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "Database-1-FinalSnapshot-1569875210793", "operationType": "CreateRelationalDatabaseSnapshot", "status": "Started", "statusChangedAt": 1569875211.029 }, { "id": "74d73681-30e8-4532-974e-1f23cd3f9f73", "resourceName": "Database-1-FinalSnapshot-1569875210793", "resourceType": "RelationalDatabaseSnapshot", "createdAt": 1569875211.029, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "Database-1", "operationType": "CreateRelationalDatabaseSnapshot", "status": "Started", "statusChangedAt": 1569875211.029 } ] }

以下代码示例演示如何使用 detach-static-ip

AWS CLI

将静态 IP 与实例分离

以下detach-static-ip示例将静态 IP 与任何连接StaticIp-1的实例分离。

aws lightsail detach-static-ip \ --static-ip-name StaticIp-1

输出:

{ "operations": [ { "id": "2a43d8a3-9f2d-4fe7-bdd0-eEXAMPLE3cf3", "resourceName": "StaticIp-1", "resourceType": "StaticIp", "createdAt": 1571088261.999, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "MEAN-1", "operationType": "DetachStaticIp", "status": "Succeeded", "statusChangedAt": 1571088261.999 }, { "id": "41a7d40c-74e8-4d2e-a837-cEXAMPLEf747", "resourceName": "MEAN-1", "resourceType": "Instance", "createdAt": 1571088262.022, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "StaticIp-1", "operationType": "DetachStaticIp", "status": "Succeeded", "statusChangedAt": 1571088262.022 } ] }

以下代码示例演示如何使用 get-active-names

AWS CLI

获取活动资源名称

以下get-active-names示例返回已配置 AWS 区域中的活动资源名称。

aws lightsail get-active-names

输出:

{ "activeNames": [ "WordPress-1", "StaticIp-1", "MEAN-1", "Plesk_Hosting_Stack_on_Ubuntu-1" ] }

以下代码示例演示如何使用 get-auto-snapshots

AWS CLI

获取实例的可用自动快照

例如,以下get-auto-snapshots示例返回可用的自动快照WordPress-1

aws lightsail get-auto-snapshots \ --resource-name WordPress-1

输出:

{ "resourceName": "WordPress-1", "resourceType": "Instance", "autoSnapshots": [ { "date": "2019-10-14", "createdAt": 1571033872.0, "status": "Success", "fromAttachedDisks": [] }, { "date": "2019-10-13", "createdAt": 1570947473.0, "status": "Success", "fromAttachedDisks": [] }, { "date": "2019-10-12", "createdAt": 1570861072.0, "status": "Success", "fromAttachedDisks": [] }, { "date": "2019-10-11", "createdAt": 1570774672.0, "status": "Success", "fromAttachedDisks": [] } ] }

有关更多信息,请参阅 Lightsail 开发者指南中的在 Amazon Lightsail 中保存实例或磁盘的自动快照

以下代码示例演示如何使用 get-blueprints

AWS CLI

获取新实例的蓝图

以下get-blueprints示例显示了有关所有可用蓝图的详细信息,这些蓝图可用于在 Amazon Lightsail 中创建新实例。

aws lightsail get-blueprints

输出:

{ "blueprints": [ { "blueprintId": "wordpress", "name": "WordPress", "group": "wordpress", "type": "app", "description": "Bitnami, the leaders in application packaging, and Automattic, the experts behind WordPress, have teamed up to offer this official WordPress image. This image is a pre-configured, ready-to-run image for running WordPress on Amazon Lightsail. WordPress is the world's most popular content management platform. Whether it's for an enterprise or small business website, or a personal or corporate blog, content authors can easily create content using its new Gutenberg editor, and developers can extend the base platform with additional features. Popular plugins like Jetpack, Akismet, All in One SEO Pack, WP Mail, Google Analytics for WordPress, and Amazon Polly are all pre-installed in this image. Let's Encrypt SSL certificates are supported through an auto-configuration script.", "isActive": true, "minPower": 0, "version": "6.5.3-0", "versionCode": "1", "productUrl": "https://aws.amazon.com/marketplace/pp/B00NN8Y43U", "licenseUrl": "https://aws.amazon.com/marketplace/pp/B00NN8Y43U#pdp-usage", "platform": "LINUX_UNIX" }, { "blueprintId": "lamp_8_bitnami", "name": "LAMP (PHP 8)", "group": "lamp_8", "type": "app", "description": "LAMP with PHP 8.X packaged by Bitnami enables you to quickly start building your websites and applications by providing a coding framework. As a developer, it provides standalone project directories to store your applications. This blueprint is configured for production environments. It includes SSL auto-configuration with Let's Encrypt certificates, and the latest releases of PHP, Apache, and MariaDB on Linux. This application also includes phpMyAdmin, PHP main modules and Composer.", "isActive": true, "minPower": 0, "version": "8.2.18-4", "versionCode": "1", "productUrl": "https://aws.amazon.com/marketplace/pp/prodview-6g3gzfcih6dvu", "licenseUrl": "https://aws.amazon.com/marketplace/pp/prodview-6g3gzfcih6dvu#pdp-usage", "platform": "LINUX_UNIX" }, { "blueprintId": "nodejs", "name": "Node.js", "group": "node", "type": "app", "description": "Node.js packaged by Bitnami is a pre-configured, ready to run image for Node.js on Amazon EC2. It includes the latest version of Node.js, Apache, Python and Redis. The image supports multiple Node.js applications, each with its own virtual host and project directory. It is configured for production use and is secure by default, as all ports except HTTP, HTTPS and SSH ports are closed. Let's Encrypt SSL certificates are supported through an auto-configuration script. Developers benefit from instant access to a secure, update and consistent Node.js environment without having to manually install and configure multiple components and libraries.", "isActive": true, "minPower": 0, "version": "18.20.2-0", "versionCode": "1", "productUrl": "https://aws.amazon.com/marketplace/pp/B00NNZUAKO", "licenseUrl": "https://aws.amazon.com/marketplace/pp/B00NNZUAKO#pdp-usage", "platform": "LINUX_UNIX" }, ... } ] }

以下代码示例演示如何使用 get-bundles

AWS CLI

获取新实例的捆绑包

以下get-bundles示例显示了可用于在 Amazon Lightsail 中创建新实例的所有可用捆绑包的详细信息。

aws lightsail get-bundles

输出:

{ "bundles": [ { "price": 5.0, "cpuCount": 2, "diskSizeInGb": 20, "bundleId": "nano_3_0", "instanceType": "nano", "isActive": true, "name": "Nano", "power": 298, "ramSizeInGb": 0.5, "transferPerMonthInGb": 1024, "supportedPlatforms": [ "LINUX_UNIX" ] }, { "price": 7.0, "cpuCount": 2, "diskSizeInGb": 40, "bundleId": "micro_3_0", "instanceType": "micro", "isActive": true, "name": "Micro", "power": 500, "ramSizeInGb": 1.0, "transferPerMonthInGb": 2048, "supportedPlatforms": [ "LINUX_UNIX" ] }, { "price": 12.0, "cpuCount": 2, "diskSizeInGb": 60, "bundleId": "small_3_0", "instanceType": "small", "isActive": true, "name": "Small", "power": 1000, "ramSizeInGb": 2.0, "transferPerMonthInGb": 3072, "supportedPlatforms": [ "LINUX_UNIX" ] }, ... } ] }

以下代码示例演示如何使用 get-cloud-formation-stack-records

AWS CLI

获取 CloudFormation 堆栈记录及其关联堆栈

以下get-cloud-formation-stack-records示例显示了有关 CloudFormation 堆栈记录及其关联堆栈的详细信息,这些堆栈用于根据导出的 Amazon Lightsail 快照创建亚马逊EC2资源。

aws lightsail get-cloud-formation-stack-records

输出:

{ "cloudFormationStackRecords": [ { "name": "CloudFormationStackRecord-588a4243-e2d1-490d-8200-3a7513ecebdf", "arn": "arn:aws:lightsail:us-west-2:111122223333:CloudFormationStackRecord/28d646ab-27bc-48d9-a422-1EXAMPLE6d37", "createdAt": 1565301666.586, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "CloudFormationStackRecord", "state": "Succeeded", "sourceInfo": [ { "resourceType": "ExportSnapshotRecord", "name": "ExportSnapshotRecord-e02f23d7-0453-4aa9-9c95-91aa01a141dd", "arn": "arn:aws:lightsail:us-west-2:111122223333:ExportSnapshotRecord/f12b8792-f3ea-4d6f-b547-2EXAMPLE8796" } ], "destinationInfo": { "id": "arn:aws:cloudformation:us-west-2:111122223333:stack/Lightsail-Stack-588a4243-e2d1-490d-8200-3EXAMPLEebdf/063203b0-ba28-11e9-838b-0EXAMPLE8b00", "service": "Aws::CloudFormation::Stack" } } ] }

以下代码示例演示如何使用 get-disk-snapshot

AWS CLI

获取有关磁盘快照的信息

以下get-disk-snapshot示例显示了有关磁盘快照的详细信息Disk-1-1566839161

aws lightsail get-disk-snapshot \ --disk-snapshot-name Disk-1-1566839161

输出:

{ "diskSnapshot": { "name": "Disk-1-1566839161", "arn": "arn:aws:lightsail:us-west-2:111122223333:DiskSnapshot/e2d0fa53-8ee0-41a0-8e56-0EXAMPLE1051", "supportCode": "6EXAMPLE3362/snap-0EXAMPLE06100d09", "createdAt": 1566839163.749, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "DiskSnapshot", "tags": [], "sizeInGb": 8, "state": "completed", "progress": "100%", "fromDiskName": "Disk-1", "fromDiskArn": "arn:aws:lightsail:us-west-2:111122223333:Disk/c21cfb0a-07f2-44ae-9a23-bEXAMPLE8096", "isFromAutoSnapshot": false } }

有关更多信息,请参阅指南中的标题。

以下代码示例演示如何使用 get-disk-snapshots

AWS CLI

获取有关所有磁盘快照的信息

以下get-disk-snapshots示例显示了有关已配置 AWS 区域中所有磁盘快照的详细信息。

aws lightsail get-disk-snapshots

输出:

{ "diskSnapshots": [ { "name": "Disk-2-1571090588", "arn": "arn:aws:lightsail:us-west-2:111122223333:DiskSnapshot/32e889a9-38d4-4687-9f21-eEXAMPLE7839", "supportCode": "6EXAMPLE3362/snap-0EXAMPLE1ca192a4", "createdAt": 1571090591.226, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "DiskSnapshot", "tags": [], "sizeInGb": 8, "state": "completed", "progress": "100%", "fromDiskName": "Disk-2", "fromDiskArn": "arn:aws:lightsail:us-west-2:111122223333:Disk/6a343ff8-6341-422d-86e2-bEXAMPLE16c2", "isFromAutoSnapshot": false }, { "name": "Disk-1-1566839161", "arn": "arn:aws:lightsail:us-west-2:111122223333:DiskSnapshot/e2d0fa53-8ee0-41a0-8e56-0EXAMPLE1051", "supportCode": "6EXAMPLE3362/snap-0EXAMPLEe06100d09", "createdAt": 1566839163.749, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "DiskSnapshot", "tags": [], "sizeInGb": 8, "state": "completed", "progress": "100%", "fromDiskName": "Disk-1", "fromDiskArn": "arn:aws:lightsail:us-west-2:111122223333:Disk/c21cfb0a-07f2-44ae-9a23-bEXAMPLE8096", "isFromAutoSnapshot": false } ] }

以下代码示例演示如何使用 get-disk

AWS CLI

获取有关块存储磁盘的信息

以下get-disk示例显示了有关磁盘的详细信息Disk-1

aws lightsail get-disk \ --disk-name Disk-1

输出:

{ "disk": { "name": "Disk-1", "arn": "arn:aws:lightsail:us-west-2:111122223333:Disk/c21cfb0a-07f2-44ae-9a23-bEXAMPLE8096", "supportCode": "6EXAMPLE3362/vol-0EXAMPLEf2f88b32f", "createdAt": 1566585439.587, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "resourceType": "Disk", "tags": [], "sizeInGb": 8, "isSystemDisk": false, "iops": 100, "path": "/dev/xvdf", "state": "in-use", "attachedTo": "WordPress_Multisite-1", "isAttached": true, "attachmentState": "attached" } }

有关更多信息,请参阅指南中的标题。

以下代码示例演示如何使用 get-disks

AWS CLI

获取有关所有块存储磁盘的信息

以下get-disks示例显示了有关已配置 AWS 区域中所有磁盘的详细信息。

aws lightsail get-disks

输出:

{ "disks": [ { "name": "Disk-2", "arn": "arn:aws:lightsail:us-west-2:111122223333:Disk/6a343ff8-6341-422d-86e2-bEXAMPLE16c2", "supportCode": "6EXAMPLE3362/vol-0EXAMPLE929602087", "createdAt": 1571090461.634, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "resourceType": "Disk", "tags": [], "sizeInGb": 8, "isSystemDisk": false, "iops": 100, "state": "available", "isAttached": false, "attachmentState": "detached" }, { "name": "Disk-1", "arn": "arn:aws:lightsail:us-west-2:111122223333:Disk/c21cfb0a-07f2-44ae-9a23-bEXAMPLE8096", "supportCode": "6EXAMPLE3362/vol-0EXAMPLEf2f88b32f", "createdAt": 1566585439.587, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "resourceType": "Disk", "tags": [], "sizeInGb": 8, "isSystemDisk": false, "iops": 100, "path": "/dev/xvdf", "state": "in-use", "attachedTo": "WordPress_Multisite-1", "isAttached": true, "attachmentState": "attached" } ] }

以下代码示例演示如何使用 get-domain

AWS CLI

获取有关域名的信息

以下get-domain示例显示有关该域的详细信息example.com

注意:Lightsail 的域名相关API操作仅在该地区可用。us-east-1 AWS 如果您的配置CLI文件配置为使用其他区域,则必须包含``--region us-east-1`参数,否则命令将失败。

aws lightsail get-domain \ --domain-name example.com \ --region us-east-1

输出:

{ "domain": { "name": "example.com", "arn": "arn:aws:lightsail:global:111122223333:Domain/28cda903-3f15-44b2-9baf-3EXAMPLEb304", "supportCode": "6EXAMPLE3362//hostedzone/ZEXAMPLEONGSC1", "createdAt": 1570728588.6, "location": { "availabilityZone": "all", "regionName": "global" }, "resourceType": "Domain", "tags": [], "domainEntries": [ { "id": "-1682899164", "name": "example.com", "target": "192.0.2.0", "isAlias": false, "type": "A" }, { "id": "1703104243", "name": "example.com", "target": "ns-137.awsdns-17.com", "isAlias": false, "type": "NS" }, { "id": "-1038331153", "name": "example.com", "target": "ns-1710.awsdns-21.co.uk", "isAlias": false, "type": "NS" }, { "id": "-2107289565", "name": "example.com", "target": "ns-692.awsdns-22.net", "isAlias": false, "type": "NS" }, { "id": "1582095705", "name": "example.com", "target": "ns-1436.awsdns-51.org", "isAlias": false, "type": "NS" }, { "id": "-1769796132", "name": "example.com", "target": "ns-1710.awsdns-21.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400", "isAlias": false, "type": "SOA" } ] } }

以下代码示例演示如何使用 get-domains

AWS CLI

获取有关所有域名的信息

以下get-domains示例显示了有关已配置 AWS 区域中所有域的详细信息。

注意:Lightsail 的域名相关API操作仅在该地区可用。us-east-1 AWS 如果您的CLI配置文件配置为使用其他区域,则必须包含该--region us-east-1参数,否则命令将失败。

aws lightsail get-domains \ --region us-east-1

输出:

{ "domains": [ { "name": "example.com", "arn": "arn:aws:lightsail:global:111122223333:Domain/28cda903-3f15-44b2-9baf-3EXAMPLEb304", "supportCode": "6EXAMPLE3362//hostedzone/ZEXAMPLEONGSC1", "createdAt": 1570728588.6, "location": { "availabilityZone": "all", "regionName": "global" }, "resourceType": "Domain", "tags": [], "domainEntries": [ { "id": "-1682899164", "name": "example.com", "target": "192.0.2.0", "isAlias": false, "type": "A" }, { "id": "1703104243", "name": "example.com", "target": "ns-137.awsdns-17.com", "isAlias": false, "type": "NS" }, { "id": "-1038331153", "name": "example.com", "target": "ns-4567.awsdns-21.co.uk", "isAlias": false, "type": "NS" }, { "id": "-2107289565", "name": "example.com", "target": "ns-333.awsdns-22.net", "isAlias": false, "type": "NS" }, { "id": "1582095705", "name": "example.com", "target": "ns-1111.awsdns-51.org", "isAlias": false, "type": "NS" }, { "id": "-1769796132", "name": "example.com", "target": "ns-1234.awsdns-21.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400", "isAlias": false, "type": "SOA" }, { "id": "1029454894", "name": "_dead6a124ede046a0319eb44a4eb3cbc.example.com", "target": "_be133b0a0899fb7b6bf79d9741d1a383.hkvuiqjoua.acm-validations.aws", "isAlias": false, "type": "CNAME" } ] }, { "name": "example.net", "arn": "arn:aws:lightsail:global:111122223333:Domain/9c9f0d70-c92e-4753-86c2-6EXAMPLE029d", "supportCode": "6EXAMPLE3362//hostedzone/ZEXAMPLE5TPKMV", "createdAt": 1556661071.384, "location": { "availabilityZone": "all", "regionName": "global" }, "resourceType": "Domain", "tags": [], "domainEntries": [ { "id": "-766320943", "name": "example.net", "target": "192.0.2.2", "isAlias": false, "type": "A" }, { "id": "-453913825", "name": "example.net", "target": "ns-123.awsdns-10.net", "isAlias": false, "type": "NS" }, { "id": "1553601564", "name": "example.net", "target": "ns-4444.awsdns-47.co.uk", "isAlias": false, "type": "NS" }, { "id": "1653797661", "name": "example.net", "target": "ns-7890.awsdns-61.org", "isAlias": false, "type": "NS" }, { "id": "706414698", "name": "example.net", "target": "ns-123.awsdns-44.com", "isAlias": false, "type": "NS" }, { "id": "337271745", "name": "example.net", "target": "ns-4444.awsdns-47.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400", "isAlias": false, "type": "SOA" }, { "id": "-1785431096", "name": "www.example.net", "target": "192.0.2.2", "isAlias": false, "type": "A" } ] }, { "name": "example.org", "arn": "arn:aws:lightsail:global:111122223333:Domain/f0f13ba3-3df0-4fdc-8ebb-1EXAMPLEf26e", "supportCode": "6EXAMPLE3362//hostedzone/ZEXAMPLEAFO38", "createdAt": 1556661199.106, "location": { "availabilityZone": "all", "regionName": "global" }, "resourceType": "Domain", "tags": [], "domainEntries": [ { "id": "2065301345", "name": "example.org", "target": "192.0.2.4", "isAlias": false, "type": "A" }, { "id": "-447198516", "name": "example.org", "target": "ns-123.awsdns-45.com", "isAlias": false, "type": "NS" }, { "id": "136463022", "name": "example.org", "target": "ns-9999.awsdns-15.co.uk", "isAlias": false, "type": "NS" }, { "id": "1395941679", "name": "example.org", "target": "ns-555.awsdns-01.net", "isAlias": false, "type": "NS" }, { "id": "872052569", "name": "example.org", "target": "ns-6543.awsdns-38.org", "isAlias": false, "type": "NS" }, { "id": "1001949377", "name": "example.org", "target": "ns-1234.awsdns-15.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400", "isAlias": false, "type": "SOA" }, { "id": "1046191192", "name": "www.example.org", "target": "192.0.2.4", "isAlias": false, "type": "A" } ] } ] }

以下代码示例演示如何使用 get-export-snapshot-record

AWS CLI

获取导出到 Amazon 的快照记录 EC2

以下get-export-snapshot-record示例显示了有关导出到亚马逊的 Amazon Lightsail 实例或磁盘快照的详细信息。EC2

aws lightsail get-export-snapshot-records

输出:

{ "exportSnapshotRecords": [ { "name": "ExportSnapshotRecord-d2da10ce-0b3c-4ae1-ab3a-2EXAMPLEa586", "arn": "arn:aws:lightsail:us-west-2:111122223333:ExportSnapshotRecord/076c7060-b0cc-4162-98f0-2EXAMPLEe28e", "createdAt": 1543534665.678, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "ExportSnapshotRecord", "state": "Succeeded", "sourceInfo": { "resourceType": "InstanceSnapshot", "createdAt": 1540339310.706, "name": "WordPress-512MB-Oregon-1-1540339219", "arn": "arn:aws:lightsail:us-west-2:111122223333:InstanceSnapshot/5446f534-ed60-4c17-b4a5-bEXAMPLEf8b7", "fromResourceName": "WordPress-512MB-Oregon-1", "fromResourceArn": "arn:aws:lightsail:us-west-2:111122223333:Instance/4b8f1f24-e4d1-4cf3-88ff-cEXAMPLEa397", "instanceSnapshotInfo": { "fromBundleId": "nano_2_0", "fromBlueprintId": "wordpress_4_9_8", "fromDiskInfo": [ { "path": "/dev/sda1", "sizeInGb": 20, "isSystemDisk": true } ] } }, "destinationInfo": { "id": "ami-0EXAMPLEc0d65058e", "service": "Aws::EC2::Image" } }, { "name": "ExportSnapshotRecord-1c94e884-40ff-4fe1-9302-0EXAMPLE14c2", "arn": "arn:aws:lightsail:us-west-2:111122223333:ExportSnapshotRecord/fb392ce8-6567-4013-9bfd-3EXAMPLE5b4c", "createdAt": 1543432110.2, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "ExportSnapshotRecord", "state": "Succeeded", "sourceInfo": { "resourceType": "InstanceSnapshot", "createdAt": 1540833603.545, "name": "LAMP_PHP_5-512MB-Oregon-1-1540833565", "arn": "arn:aws:lightsail:us-west-2:111122223333:InstanceSnapshot/82334399-b5f2-49ec-8382-0EXAMPLEe45f", "fromResourceName": "LAMP_PHP_5-512MB-Oregon-1", "fromResourceArn": "arn:aws:lightsail:us-west-2:111122223333:Instance/863b9f35-ab1e-4418-bdd2-1EXAMPLEbab2", "instanceSnapshotInfo": { "fromBundleId": "nano_2_0", "fromBlueprintId": "lamp_5_6_37_2", "fromDiskInfo": [ { "path": "/dev/sda1", "sizeInGb": 20, "isSystemDisk": true } ] } }, "destinationInfo": { "id": "ami-0EXAMPLE7c5ec84e2", "service": "Aws::EC2::Image" } } ] }

以下代码示例演示如何使用 get-instance-access-details

AWS CLI

获取实例的主机密钥信息

例如,以下get-instance-access-details示例显示了主机密钥信息WordPress_Multisite-1

aws lightsail get-instance-access-details \ --instance-name WordPress_Multisite-1

输出:

{ "accessDetails": { "certKey": "ssh-rsa-cert-v01@openssh.com AEXAMPLEaC1yc2EtY2VydC12MDFAb3BlbnNzaC5jb20AAAAgNf076Dt3ppmPd0fPxZVMmS491aEAYYH9cHqAJ3fNML8AAAADAQABAAABAQD4APep5Ta2gHLk7m/vEXAMPLE2eBWJyQvn7ol/i0+s966h5sx8qUD79lPB7q5UESd5VZGFtytrykfQJnjiwqe7EV5agzvjblLj26Fb37EKda9HVfCOu8pWbvky7Tyn9w299a6CsG5o8HrkOymDE2c59lYxXGkilKo5I9aZLBAdXn3t3oKtq9zsjYGjyEmarPYoVDT1ft8HaUGu4aCv1peI0+ZEXAMPLEAWaucW9Huh0WYN5yrmL252c4v13JTVmytaEZvLvt5itVoWXQY0ZDyrLUcZSKxyq5n00Mgvj2fiZdt+xMfQM9xVz0rXZmqx8uJidJpRgLCMTviofwQJU/K1EXAMPLEAAAAAAAABAAAALS00MzMzMDU4MzA4ODg1MTY2NjM4Onp6UWlndHk4UElRSG9STitOTG5QSEE9PQAAAAsAAAAHYml0bmFtaQAAAABdpPL7AAEXAMPLEgcAAAAAAAAAggAAABVwZXJtaXQtWDExLWZvcndhcmRpbmcAAAAAAAAAF3Blcm1pdC1hZ2VudC1mb3J3YXJkaW5nAAAAAAAAABZwZXJtaXQtEXAMPLEmb3J3YXJkaW5nAAAAAAAAAApwZXJtaXQtcHR5AAAAAAAAAA5wZXJtaXQtdXNlci1yYwAAAAAAAAAAAAACFwAAAAdzc2gtcnNhAAAAAwEAAQEXAMPLECqCbiK9b450HtRD1ZpiksT6oxc8U7nLNkVFC1j7JqZvP9ee3ux+LiB+ozNbUA0cdNL9Y67x7qPv/R7XhTc21+2A+8+GuVpK/Kz9dqDMKNAEXAMPLE+YYN+tiXm7Y8OgziK+7iDB7xUuQ4vghmn4+qgz9mKwYgWvVe2+0XLuV7cnWPB7iUlHQg+E3LUKrV4ZFw9pj7X2dFdNKfMxwWgI1ISWKimEXAMPLEeHjrf1Rqc/QH6TpWCvPfcx8uvwVqdwTfkE/SfA5BCzbGGI1UmIUadh8nHcb5FamQ1hK7kECy47K/x9FMn/KwmM7pCwJbSLDMO7n9bnbvck6m8ZoB2N2YLMG5dW7BerEXAMPLEobqfdtyYJHHel1EyyEJs1fWNU3D5JIGlgzcPAV+ZlbQyUCZXf0oslSa+HE85fO/FRq9SVSBSHrmbeb0frlPhgMzgSmqLeyhlbr6wwWIDbREXAMPLEJZ49H7RdQxdKyYrZPWvRgcr0qI2EL0tAajnpQQ8UZqeO9/Aqter0xN5PhFL0J49OWTacwCGRAjLhibAx7K1t/1ZXWo6c+ijq8clll327EXAMPLE/e89GC89KcmKCxfGQniDAUgF8UqofIbq3ZOUgiAAYCVXclI4L68NhVXyoWuQXPBRQSEXAMPLEWm74tDL9tFN3c7tSe/Oz0cTR+4sAAAIPAAAAB3NzaC1yc2EAAAIAQnG/L0DqiSnLrWhEox4aHqMgd0m0oLLAYx6OQH9F0TM9EXAMPLE961rzSCMon7ZgsWNnL0OwZQgDG+rtJ4N0B7HOVwns4ynUFbzNQ3qFGGeE3lKwX1L41vV1iSy7sDk8aI0LmrKJi1LE1Qc1l8uboRlwoXOYEXAMPLEaUCeX+10+WEXAMPLEg6Y4U4ZvE2B3xyRdpvysb5TGFNtk5qPslacnVkoLOGsZZXMpLGJnG4OBpQLLtpj9sNMxAgZPCAUjhkqkQWYJxJzvFN7sUMOArUwKPFJE2kaEXAMPLEOUrVGBbCTioRztlPsxY7hoXm73N929eZpNhxP3U+nxO9O4NUZ2pTWbVSUaV1gm6pug9xbwNO1Im21t34JeLlKTqxcJ6zzS8W0c0KKpAm5c4hWkseMbyutS2jav/4hiS+BhrYgptzfwe5qRXEXAMPLEHZQr3YfGzYoBJ/lLK3NHhxOihhsfAYwMei0BFZT1F/7CT3IH4iitEkIgodi06/Mw6UDqMPozyQCK1lEA6LFhYCOZG9drWcoRa74lM4kY9TP028Za8gDMh1WpkXLq9Gixon5OHP8aM/sEXAMPLEr2+fnkw+1BtoO5L6+VKoPlXaGqZ/fBYEXAMPLEAMQHjnLM1JYNvtEEPhp+TNzXHzuixWf/Ht04m0AVpXrzIDXaS1O2tXY=", "ipAddress": "192.0.2.0", "privateKey": "-----BEGIN RSA PRIVATE KEY-----\nEXAMPLEBAAKCAQEA+AD3qeU2toBy5O5v7wnRLVo/tngVickL5+6Jf4tPrPeuoebM\nfKlA+/ZTwe6uVBEneVWRhbcra8pH0CZ44sKnuxFeWoM7425S49uhW9+xCnWvR1Xw\njrvKVm75Mu08p/cNvfWugrBuaPB65DspgxNnOfZWMVxpIpSqOSPWmSwQHV597d6C\nrEXAMPLEo8hJmqz2KFQ09X7fB2lBruGgr9aXiNPmWmovYKqwFmrnFvR7odFmDecq\n5EXAMPLE9dyU1ZsrWhGby77eYrVaFl0GNGQ8qy1HGUiscquZ9NDIL49n4mXbfsTH\n0EXAMPLE12ZqsfLiYnSaUYCwjE74qH8ECVPytQIDAQABAoIBAHeZV9Z58JHAjifz\nCEXAMPLEEqC3doOVDgXSlkKI92qNo4z2VcUEho878paCuVVXVHcCGgSnGeyIh2tN\nMEXAMPLESohR427BhH3YLA+3Z5SIvnejbTgYPfLC37B8khTaYqkqMvdZiFVZK5qn\nIEXAMPLEM93oF9eSZCjcLKB/jGHsfb0eCDMP8BshHE2beuqzVMoK1DxOnvoP3+Fp\nAEXAMPLESq6pDpCo9YVUX8g1u3Ro9cPl2LXHDy+oVEY5KhbZQJ7VU1I72WOvppWW\nOEXAMPLEkgYlq7p6qYtYcSgTEjz14gDiMfQ7SyHB3alkIoNONQ9ZPaWHyJvymeud\noQTNuz0CgYEA/LFWNTEZrzdzdR1kJmyNRmAermU0B6utyNENChAlHGSHkB+1lVSh\nbEXAMPLEQo9ooUeW5UxO3YwacZLoDT1mwxw1Ptc1+PNycZoLe1fE9UdARrdmGTob\n8l7CPLSXp3xuR8VqSp2fnIc7hfiQs/NrPX9gm/EOrB0we0RKyDSzWScCgYEA+z/r\niob+nJZq0YbnOSuP6oMULP4vnWniWj8MIhUJU53LwSAM8DeJdONKDdkuiOd52aAL\nVgn7nLo88rVWKhJwVc4tu/rNgZLcR3bP4+kL6zand0KQnMLyOzNA2Ys26aa5udH1\nqWl0WTt9WEm/h10ndC1knOMectrvsG17b38y5sMCgYEA54NiRGGz8oCPW6GN/FZA\nKEXAMPLE5tw34GEH3Uxlc9n3CejDaQmczOATwX4nIwRZDEqWyYZcS0btg1jhGiBD\nYEXAMPLEkc8Z71L/agZEAaVCEog9FqfSqwB+XTfoKh8qur74X1yCu9p6gof1q6k9\neEXAMPLEchJcNNOg4ETIfMkCgYBdVORRhE4mqvWpOdzA7v66FdEz2YSkjAXKkmsW\naEXAMPLE8Z/8yBSmuBv1Qv03XA12my462uB92uzzGAuW+1yBc2Kn1sXqYTy0y1z0\ngEXAMPLEBogjw4MqHKL1bPKMHyQU8/q24PaYgzHPzy13wlH6pTYf1XqlHdE2D6Vv\nyEXAMPLEgQC3i/kVVhky/2XRwRVlC7JO2Bg3QGTx38hpmDa5IuofKANjA+Wa3/zy\nbEXAMPLE6ytQgD9GN/YtBq+uhO+2ZkvXPL+CWRi0ZRXpPwYDBBFU9Cw0AuWWGlL8\nwEXAMPLExMlcysRgcWB9RNgf3AuOpFd2i6XT/riNsvvkpmJ+VooU8g==\n-----END RSA PRIVATE KEY-----\n", "protocol": "ssh", "instanceName": "WordPress_Multisite-1", "username": "bitnami", "hostKeys": [ { "algorithm": "ssh-rsa", "publicKey": "AEXAMPLEaC1yc2EAAAADAQABAAABAQCoeR9ieZTjQ3pXCHczuAYZFjlF7t+uBkXuqeGMRex78pCvmS+DiEXAMPLEuJ1Q8dcKhrQL4HpXbD9dosVCTaJnJwb4MQqsuSVFdHFzy3guP+BKclWqtxJEXAMPLEsBGqZZlrIv6a9bTA0TCplZ8AD+hSRTaSXXqg6FT+Qf16IktH0XlMs7xIEXAMPLEmNtjCpzZiGXDHzytoMvUgwa8uHPp44Og36EUu4VqQxoUHPJKoXvcQizyk3K8ym0hP0TpDZhD8cqwRfd6EHp4Q1br/Ot6y9HwvykEXAMPLEAfbKjbR42+u6+OSlkr4d339q2U1sTDytJhhs8HUel1wTfGRfp", "witnessedAt": 1570744377.699, "fingerprintSHA1": "SHA1:GEXAMPLEMoYgUg0ucadqU9Bt3Lk", "fingerprintSHA256": "SHA256:IEXAMPLEcB5vgxnAUoJawbdZ+MwELhIp6FUxuwq/LIU" }, { "algorithm": "ssh-ed25519", "publicKey": "AEXAMPLEaC1lZDI1NTE5AAAAIC1gwGPDfGaONxEXAMPLEJX3UNap781QxHQmn8nzlrUv", "witnessedAt": 1570744377.697, "fingerprintSHA1": "SHA1:VEXAMPLE5ReqSmTgv03sSUw9toU", "fingerprintSHA256": "SHA256:0EXAMPLEdE6tI95k3TJpG+qhJbAoknB0yz9nAEaDt3A" }, { "algorithm": "ecdsa-sha2-nistp256", "publicKey": "AEXAMPLEZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABEXAMPLE9B4mZy8YSsZW7cixCDq5yHSAAxjJkDo54C+EnKlDCsYtUkxxEXAMPLE6VOWL2z63RTKa2AUPgd8irjxWI=", "witnessedAt": 1570744377.707, "fingerprintSHA1": "SHA1:UEXAMPLEOYCfXsCf2G6tDg+7YG0", "fingerprintSHA256": "SHA256:wEXAMPLEQ9a/iEXAMPLEhRufm6U9vFU4cpkMPHnBsNA" } ] } }

以下代码示例演示如何使用 get-instance-metric-data

AWS CLI

获取实例的指标数据

例如,以下get-instance-metric-data示例返回与之间CPUUtilization7200秒(2 小时)15713424001571428800的平均百分比MEAN-1

我们建议您使用 unix 时间转换器来识别开始和结束时间。

aws lightsail get-instance-metric-data \ --instance-name MEAN-1 \ --metric-name CPUUtilization \ --period 7200 \ --start-time 1571342400 \ --end-time 1571428800 \ --unit Percent \ --statistics Average

输出:

{ "metricName": "CPUUtilization", "metricData": [ { "average": 0.26113718770120725, "timestamp": 1571342400.0, "unit": "Percent" }, { "average": 0.26861268928111953, "timestamp": 1571392800.0, "unit": "Percent" }, { "average": 0.28187475104748777, "timestamp": 1571378400.0, "unit": "Percent" }, { "average": 0.2651936960458352, "timestamp": 1571421600.0, "unit": "Percent" }, { "average": 0.2561856213712188, "timestamp": 1571371200.0, "unit": "Percent" }, { "average": 0.3021383254607764, "timestamp": 1571356800.0, "unit": "Percent" }, { "average": 0.2618381649223539, "timestamp": 1571407200.0, "unit": "Percent" }, { "average": 0.26331929394825787, "timestamp": 1571400000.0, "unit": "Percent" }, { "average": 0.2576348407007818, "timestamp": 1571385600.0, "unit": "Percent" }, { "average": 0.2513008454658378, "timestamp": 1571364000.0, "unit": "Percent" }, { "average": 0.26329974562758346, "timestamp": 1571414400.0, "unit": "Percent" }, { "average": 0.2667092536656445, "timestamp": 1571349600.0, "unit": "Percent" } ] }

以下代码示例演示如何使用 get-instance-port-states

AWS CLI

获取实例的防火墙信息

例如,以下get-instance-port-states示例返回配置的防火墙端口MEAN-1

aws lightsail get-instance-port-states \ --instance-name MEAN-1

输出:

{ "portStates": [ { "fromPort": 80, "toPort": 80, "protocol": "tcp", "state": "open" }, { "fromPort": 22, "toPort": 22, "protocol": "tcp", "state": "open" }, { "fromPort": 443, "toPort": 443, "protocol": "tcp", "state": "open" } ] }

以下代码示例演示如何使用 get-instance-snapshot

AWS CLI

获取有关指定实例快照的信息

以下get-instance-snapshot示例显示有关指定实例快照的详细信息。

aws lightsail get-instance-snapshot \ --instance-snapshot-name MEAN-1-1571419854

输出:

{ "instanceSnapshot": { "name": "MEAN-1-1571419854", "arn": "arn:aws:lightsail:us-west-2:111122223333:InstanceSnapshot/ac54700c-48a8-40fd-b065-2EXAMPLEac8f", "supportCode": "6EXAMPLE3362/ami-0EXAMPLE67a73020d", "createdAt": 1571419891.927, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "InstanceSnapshot", "tags": [], "state": "available", "fromAttachedDisks": [], "fromInstanceName": "MEAN-1", "fromInstanceArn": "arn:aws:lightsail:us-west-2:111122223333:Instance/bd470fc5-a68b-44c5-8dbc-8EXAMPLEbada", "fromBlueprintId": "mean", "fromBundleId": "medium_3_0", "isFromAutoSnapshot": false, "sizeInGb": 80 } }

以下代码示例演示如何使用 get-instance-snapshots

AWS CLI

获取有关您的所有实例快照的信息

以下get-instance-snapshots示例显示了有关已配置 AWS 区域中所有实例快照的详细信息。

aws lightsail get-instance-snapshots

输出:

{ "instanceSnapshots": [ { "name": "MEAN-1-1571421498", "arn": "arn:aws:lightsail:us-west-2:111122223333:InstanceSnapshot/a20e6ebe-b0ee-4ae4-a750-3EXAMPLEcb0c", "supportCode": "6EXAMPLE3362/ami-0EXAMPLEe33cabfa1", "createdAt": 1571421527.755, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "InstanceSnapshot", "tags": [ { "key": "no_delete" } ], "state": "available", "fromAttachedDisks": [], "fromInstanceName": "MEAN-1", "fromInstanceArn": "arn:aws:lightsail:us-west-2:111122223333:Instance/1761aa0a-6038-4f25-8b94-2EXAMPLE19fd", "fromBlueprintId": "wordpress", "fromBundleId": "micro_3_0", "isFromAutoSnapshot": false, "sizeInGb": 40 }, { "name": "MEAN-1-1571419854", "arn": "arn:aws:lightsail:us-west-2:111122223333:InstanceSnapshot/ac54700c-48a8-40fd-b065-2EXAMPLEac8f", "supportCode": "6EXAMPLE3362/ami-0EXAMPLE67a73020d", "createdAt": 1571419891.927, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "InstanceSnapshot", "tags": [], "state": "available", "fromAttachedDisks": [], "fromInstanceName": "MEAN-1", "fromInstanceArn": "arn:aws:lightsail:us-west-2:111122223333:Instance/bd470fc5-a68b-44c5-8dbc-8EXAMPLEbada", "fromBlueprintId": "mean", "fromBundleId": "medium_3_0", "isFromAutoSnapshot": false, "sizeInGb": 80 } ] }

以下代码示例演示如何使用 get-instance-state

AWS CLI

获取有关实例状态的信息

以下get-instance-state示例返回指定实例的状态。

aws lightsail get-instance-state \ --instance-name MEAN-1

输出:

{ "state": { "code": 16, "name": "running" } }

以下代码示例演示如何使用 get-instance

AWS CLI

获取有关实例的信息

以下get-instance示例显示了有关该实例的详细信息MEAN-1

aws lightsail get-instance \ --instance-name MEAN-1

输出:

{ "instance": { "name": "MEAN-1", "arn": "arn:aws:lightsail:us-west-2:111122223333:Instance/bd470fc5-a68b-44c5-8dbc-EXAMPLE4bada", "supportCode": "6EXAMPLE3362/i-05EXAMPLE407c97d3", "createdAt": 1570635023.124, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "resourceType": "Instance", "tags": [], "blueprintId": "mean", "blueprintName": "MEAN", "bundleId": "medium_3_0", "isStaticIp": false, "privateIpAddress": "192.0.2.0", "publicIpAddress": "192.0.2.0", "hardware": { "cpuCount": 2, "disks": [ { "createdAt": 1570635023.124, "sizeInGb": 80, "isSystemDisk": true, "iops": 240, "path": "/dev/xvda", "attachedTo": "MEAN-1", "attachmentState": "attached" } ], "ramSizeInGb": 4.0 }, "networking": { "monthlyTransfer": { "gbPerMonthAllocated": 4096 }, "ports": [ { "fromPort": 80, "toPort": 80, "protocol": "tcp", "accessFrom": "Anywhere (0.0.0.0/0)", "accessType": "public", "commonName": "", "accessDirection": "inbound" }, { "fromPort": 22, "toPort": 22, "protocol": "tcp", "accessFrom": "Anywhere (0.0.0.0/0)", "accessType": "public", "commonName": "", "accessDirection": "inbound" }, { "fromPort": 443, "toPort": 443, "protocol": "tcp", "accessFrom": "Anywhere (0.0.0.0/0)", "accessType": "public", "commonName": "", "accessDirection": "inbound" } ] }, "state": { "code": 16, "name": "running" }, "username": "bitnami", "sshKeyName": "MyKey" } }

以下代码示例演示如何使用 get-instances

AWS CLI

获取有关所有实例的信息

以下get-instances示例显示了有关已配置 AWS 区域中所有实例的详细信息。

aws lightsail get-instances

输出:

{ "instances": [ { "name": "Windows_Server_2022-1", "arn": "arn:aws:lightsail:us-west-2:111122223333:Instance/0f44fbb9-8f55-4e47-a25e-EXAMPLE04763", "supportCode": "62EXAMPLE362/i-0bEXAMPLE71a686b9", "createdAt": 1571332358.665, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "resourceType": "Instance", "tags": [], "blueprintId": "windows_server_2022", "blueprintName": "Windows Server 2022", "bundleId": "large_win_3_0", "isStaticIp": false, "privateIpAddress": "192.0.2.0", "publicIpAddress": "192.0.2.0", "hardware": { "cpuCount": 1, "disks": [ { "createdAt": 1571332358.665, "sizeInGb": 160, "isSystemDisk": true, "iops": 180, "path": "/dev/sda1", "attachedTo": "Windows_Server_2022-1", "attachmentState": "attached" }, { "name": "my-disk-for-windows-server", "arn": "arn:aws:lightsail:us-west-2:111122223333:Disk/4123a81c-484c-49ea-afea-5EXAMPLEda87", "supportCode": "6EXAMPLE3362/vol-0EXAMPLEb2b99ca3d", "createdAt": 1571355063.494, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "resourceType": "Disk", "tags": [], "sizeInGb": 128, "isSystemDisk": false, "iops": 384, "path": "/dev/xvdf", "state": "in-use", "attachedTo": "Windows_Server_2022-1", "isAttached": true, "attachmentState": "attached" } ], "ramSizeInGb": 8.0 }, "networking": { "monthlyTransfer": { "gbPerMonthAllocated": 3072 }, "ports": [ { "fromPort": 80, "toPort": 80, "protocol": "tcp", "accessFrom": "Anywhere (0.0.0.0/0)", "accessType": "public", "commonName": "", "accessDirection": "inbound" }, { "fromPort": 22, "toPort": 22, "protocol": "tcp", "accessFrom": "Anywhere (0.0.0.0/0)", "accessType": "public", "commonName": "", "accessDirection": "inbound" }, { "fromPort": 3389, "toPort": 3389, "protocol": "tcp", "accessFrom": "Anywhere (0.0.0.0/0)", "accessType": "public", "commonName": "", "accessDirection": "inbound" } ] }, "state": { "code": 16, "name": "running" }, "username": "Administrator", "sshKeyName": "LightsailDefaultKeyPair" }, { "name": "MEAN-1", "arn": "arn:aws:lightsail:us-west-2:111122223333:Instance/bd470fc5-a68b-44c5-8dbc-8EXAMPLEbada", "supportCode": "6EXAMPLE3362/i-0EXAMPLEa407c97d3", "createdAt": 1570635023.124, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "resourceType": "Instance", "tags": [], "blueprintId": "mean", "blueprintName": "MEAN", "bundleId": "medium_3_0", "isStaticIp": false, "privateIpAddress": "192.0.2.0", "publicIpAddress": "192.0.2.0", "hardware": { "cpuCount": 2, "disks": [ { "name": "Disk-1", "arn": "arn:aws:lightsail:us-west-2:111122223333:Disk/c21cfb0a-07f2-44ae-9a23-bEXAMPLE8096", "supportCode": "6EXAMPLE3362/vol-0EXAMPLEf2f88b32f", "createdAt": 1566585439.587, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "resourceType": "Disk", "tags": [ { "key": "test" } ], "sizeInGb": 8, "isSystemDisk": false, "iops": 240, "path": "/dev/xvdf", "state": "in-use", "attachedTo": "MEAN-1", "isAttached": true, "attachmentState": "attached" }, { "createdAt": 1570635023.124, "sizeInGb": 80, "isSystemDisk": true, "iops": 240, "path": "/dev/sda1", "attachedTo": "MEAN-1", "attachmentState": "attached" } ], "ramSizeInGb": 4.0 }, "networking": { "monthlyTransfer": { "gbPerMonthAllocated": 4096 }, "ports": [ { "fromPort": 80, "toPort": 80, "protocol": "tcp", "accessFrom": "Anywhere (0.0.0.0/0)", "accessType": "public", "commonName": "", "accessDirection": "inbound" }, { "fromPort": 22, "toPort": 22, "protocol": "tcp", "accessFrom": "Anywhere (0.0.0.0/0)", "accessType": "public", "commonName": "", "accessDirection": "inbound" }, { "fromPort": 443, "toPort": 443, "protocol": "tcp", "accessFrom": "Anywhere (0.0.0.0/0)", "accessType": "public", "commonName": "", "accessDirection": "inbound" } ] }, "state": { "code": 16, "name": "running" }, "username": "bitnami", "sshKeyName": "MyTestKey" } ] }

以下代码示例演示如何使用 get-key-pair

AWS CLI

获取有关 key pair 的信息

以下get-key-pair示例显示有关指定 key pair 的详细信息。

aws lightsail get-key-pair \ --key-pair-name MyKey1

输出:

{ "keyPair": { "name": "MyKey1", "arn": "arn:aws:lightsail:us-west-2:111122223333:KeyPair/19a4efdf-3054-43d6-91fd-eEXAMPLE21bf", "supportCode": "6EXAMPLE3362/MyKey1", "createdAt": 1571255026.975, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "KeyPair", "tags": [], "fingerprint": "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:gg:hh:ii:jj" } }

以下代码示例演示如何使用 get-key-pairs

AWS CLI

获取有关所有密钥对的信息

以下get-key-pairs示例显示了有关已配置 AWS 区域中所有密钥对的详细信息。

aws lightsail get-key-pairs

输出:

{ "keyPairs": [ { "name": "MyKey1", "arn": "arn:aws:lightsail:us-west-2:111122223333:KeyPair/19a4efdf-3054-43d6-91fd-eEXAMPLE21bf", "supportCode": "6EXAMPLE3362/MyKey1", "createdAt": 1571255026.975, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "KeyPair", "tags": [], "fingerprint": "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:gg:hh:ii:jj" } ] }

以下代码示例演示如何使用 get-load-balancer-tls-certificates

AWS CLI

获取有关负载均衡器TLS证书的信息

以下get-load-balancer-tls-certificates示例显示了有关指定负载均衡器的TLS证书的详细信息。

aws lightsail get-load-balancer-tls-certificates \ --load-balancer-name LoadBalancer-1

输出:

{ "tlsCertificates": [ { "name": "example-com", "arn": "arn:aws:lightsail:us-west-2:111122223333:LoadBalancerTlsCertificate/d7bf4643-6a02-4cd4-b3c4-fEXAMPLE9b4d", "supportCode": "6EXAMPLE3362/arn:aws:acm:us-west-2:333322221111:certificate/9af8e32c-a54e-4a67-8c63-cEXAMPLEb314", "createdAt": 1571678025.3, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "LoadBalancerTlsCertificate", "loadBalancerName": "LoadBalancer-1", "isAttached": false, "status": "ISSUED", "domainName": "example.com", "domainValidationRecords": [ { "name": "_dEXAMPLE4ede046a0319eb44a4eb3cbc.example.com.", "type": "CNAME", "value": "_bEXAMPLE0899fb7b6bf79d9741d1a383.hkvuiqjoua.acm-validations.aws.", "validationStatus": "SUCCESS", "domainName": "example.com" } ], "issuedAt": 1571678070.0, "issuer": "Amazon", "keyAlgorithm": "RSA-2048", "notAfter": 1605960000.0, "notBefore": 1571616000.0, "serial": "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff", "signatureAlgorithm": "SHA256WITHRSA", "subject": "CN=example.com", "subjectAlternativeNames": [ "example.com" ] } ] }

以下代码示例演示如何使用 get-load-balancer

AWS CLI

获取有关负载均衡器的信息

以下get-load-balancer示例显示了有关指定负载均衡器的详细信息。

aws lightsail get-load-balancer \ --load-balancer-name LoadBalancer-1

输出:

{ "loadBalancer": { "name": "LoadBalancer-1", "arn": "arn:aws:lightsail:us-west-2:111122223333:LoadBalancer/40486b2b-1ad0-4152-83e4-cEXAMPLE6f4b", "supportCode": "6EXAMPLE3362/arn:aws:elasticloadbalancing:us-west-2:333322221111:loadbalancer/app/bEXAMPLE128cb59d86f946a9395dd304/1EXAMPLE8dd9d77e", "createdAt": 1571677906.723, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "LoadBalancer", "tags": [], "dnsName": "bEXAMPLE128cb59d86f946a9395dd304-1486911371.us-west-2.elb.amazonaws.com", "state": "active", "protocol": "HTTP", "publicPorts": [ 80 ], "healthCheckPath": "/", "instancePort": 80, "instanceHealthSummary": [ { "instanceName": "MEAN-3", "instanceHealth": "healthy" }, { "instanceName": "MEAN-1", "instanceHealth": "healthy" }, { "instanceName": "MEAN-2", "instanceHealth": "healthy" } ], "tlsCertificateSummaries": [ { "name": "example-com", "isAttached": false } ], "configurationOptions": { "SessionStickinessEnabled": "false", "SessionStickiness_LB_CookieDurationSeconds": "86400" } } }

以下代码示例演示如何使用 get-load-balancers

AWS CLI

获取有关所有负载均衡器的信息

以下get-load-balancers示例显示了有关已配置 AWS 区域中所有负载均衡器的详细信息。

aws lightsail get-load-balancers

输出:

{ "loadBalancers": [ { "name": "LoadBalancer-1", "arn": "arn:aws:lightsail:us-west-2:111122223333:LoadBalancer/40486b2b-1ad0-4152-83e4-cEXAMPLE6f4b", "supportCode": "6EXAMPLE3362/arn:aws:elasticloadbalancing:us-west-2:333322221111:loadbalancer/app/bEXAMPLE128cb59d86f946a9395dd304/1EXAMPLE8dd9d77e", "createdAt": 1571677906.723, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "LoadBalancer", "tags": [], "dnsName": "bEXAMPLE128cb59d86f946a9395dd304-1486911371.us-west-2.elb.amazonaws.com", "state": "active", "protocol": "HTTP", "publicPorts": [ 80 ], "healthCheckPath": "/", "instancePort": 80, "instanceHealthSummary": [ { "instanceName": "MEAN-3", "instanceHealth": "healthy" }, { "instanceName": "MEAN-1", "instanceHealth": "healthy" }, { "instanceName": "MEAN-2", "instanceHealth": "healthy" } ], "tlsCertificateSummaries": [ { "name": "example-com", "isAttached": false } ], "configurationOptions": { "SessionStickinessEnabled": "false", "SessionStickiness_LB_CookieDurationSeconds": "86400" } } ] }

以下代码示例演示如何使用 get-operation

AWS CLI

获取有关单个操作的信息

以下get-operation示例显示有关指定操作的详细信息。

aws lightsail get-operation \ --operation-id e5700e8a-daf2-4b49-bc01-3EXAMPLE910a

输出:

{ "operation": { "id": "e5700e8a-daf2-4b49-bc01-3EXAMPLE910a", "resourceName": "Instance-1", "resourceType": "Instance", "createdAt": 1571679872.404, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "CreateInstance", "status": "Succeeded", "statusChangedAt": 1571679890.304 } }

以下代码示例演示如何使用 get-operations-for-resource

AWS CLI

获取资源的所有操作

以下get-operations-for-resource示例显示有关指定资源的所有操作的详细信息。

aws lightsail get-operations-for-resource \ --resource-name LoadBalancer-1

输出:

{ "operations": [ { "id": "e2973046-43f8-4252-a4b4-9EXAMPLE69ce", "resourceName": "LoadBalancer-1", "resourceType": "LoadBalancer", "createdAt": 1571678786.071, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "MEAN-1", "operationType": "DetachInstancesFromLoadBalancer", "status": "Succeeded", "statusChangedAt": 1571679087.57 }, { "id": "2d742a18-0e7f-48c8-9705-3EXAMPLEf98a", "resourceName": "LoadBalancer-1", "resourceType": "LoadBalancer", "createdAt": 1571678782.784, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "MEAN-1", "operationType": "AttachInstancesToLoadBalancer", "status": "Succeeded", "statusChangedAt": 1571678798.465 }, { "id": "6c700fcc-4246-40ab-952b-1EXAMPLEdac2", "resourceName": "LoadBalancer-1", "resourceType": "LoadBalancer", "createdAt": 1571678775.297, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "MEAN-3", "operationType": "AttachInstancesToLoadBalancer", "status": "Succeeded", "statusChangedAt": 1571678842.806 }, ... } ] }

以下代码示例演示如何使用 get-operations

AWS CLI

获取有关所有操作的信息

以下get-operations示例显示了有关已配置 AWS 区域中所有操作的详细信息。

aws lightsail get-operations

输出:

{ "operations": [ { "id": "e5700e8a-daf2-4b49-bc01-3EXAMPLE910a", "resourceName": "Instance-1", "resourceType": "Instance", "createdAt": 1571679872.404, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "CreateInstance", "status": "Succeeded", "statusChangedAt": 1571679890.304 }, { "id": "701a3339-930e-4914-a9f9-7EXAMPLE68d7", "resourceName": "WordPress-1", "resourceType": "Instance", "createdAt": 1571678786.072, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "LoadBalancer-1", "operationType": "DetachInstancesFromLoadBalancer", "status": "Succeeded", "statusChangedAt": 1571679086.399 }, { "id": "e2973046-43f8-4252-a4b4-9EXAMPLE69ce", "resourceName": "LoadBalancer-1", "resourceType": "LoadBalancer", "createdAt": 1571678786.071, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "WordPress-1", "operationType": "DetachInstancesFromLoadBalancer", "status": "Succeeded", "statusChangedAt": 1571679087.57 }, ... } ] }

以下代码示例演示如何使用 get-regions

AWS CLI

要获取亚马逊 Lightsail 的所有 AWS 区域

以下get-regions示例显示了有关亚马逊 Lightsail 所有 AWS 区域的详细信息。

aws lightsail get-regions

输出:

{ "regions": [ { "continentCode": "NA", "description": "This region is recommended to serve users in the eastern United States", "displayName": "Virginia", "name": "us-east-1", "availabilityZones": [], "relationalDatabaseAvailabilityZones": [] }, { "continentCode": "NA", "description": "This region is recommended to serve users in the eastern United States", "displayName": "Ohio", "name": "us-east-2", "availabilityZones": [], "relationalDatabaseAvailabilityZones": [] }, { "continentCode": "NA", "description": "This region is recommended to serve users in the northwestern United States, Alaska, and western Canada", "displayName": "Oregon", "name": "us-west-2", "availabilityZones": [], "relationalDatabaseAvailabilityZones": [] }, ... } ] }

以下代码示例演示如何使用 get-relational-database-blueprints

AWS CLI

获取新关系数据库的蓝图

以下get-relational-database-blueprints示例显示了有关所有可用关系数据库蓝图的详细信息,这些蓝图可用于在 Amazon Lightsail 中创建新的关系数据库。

aws lightsail get-relational-database-blueprints

输出:

{ "blueprints": [ { "blueprintId": "mysql_5_6", "engine": "mysql", "engineVersion": "5.6.44", "engineDescription": "MySQL Community Edition", "engineVersionDescription": "MySQL 5.6.44", "isEngineDefault": false }, { "blueprintId": "mysql_5_7", "engine": "mysql", "engineVersion": "5.7.26", "engineDescription": "MySQL Community Edition", "engineVersionDescription": "MySQL 5.7.26", "isEngineDefault": true }, { "blueprintId": "mysql_8_0", "engine": "mysql", "engineVersion": "8.0.16", "engineDescription": "MySQL Community Edition", "engineVersionDescription": "MySQL 8.0.16", "isEngineDefault": false }, { "blueprintId": "postgres_9_6", "engine": "postgres", "engineVersion": "9.6.15", "engineDescription": "PostgreSQL", "engineVersionDescription": "PostgreSQL 9.6.15-R1", "isEngineDefault": false }, { "blueprintId": "postgres_10", "engine": "postgres", "engineVersion": "10.10", "engineDescription": "PostgreSQL", "engineVersionDescription": "PostgreSQL 10.10-R1", "isEngineDefault": false }, { "blueprintId": "postgres_11", "engine": "postgres", "engineVersion": "11.5", "engineDescription": "PostgreSQL", "engineVersionDescription": "PostgreSQL 11.5-R1", "isEngineDefault": true } ] }

以下代码示例演示如何使用 get-relational-database-bundles

AWS CLI

获取新关系数据库的捆绑包

以下get-relational-database-bundles示例显示了有关所有可用关系数据库捆绑包的详细信息,这些捆绑包可用于在 Amazon Lightsail 中创建新的关系数据库。请注意,响应中不包括非活动捆绑包,因为命令中未指定该--include-inactive标志。您不能使用非活动分发包来创建新的关系数据库。

aws lightsail get-relational-database-bundles

输出:

{ "bundles": [ { "bundleId": "micro_2_0", "name": "Micro", "price": 15.0, "ramSizeInGb": 1.0, "diskSizeInGb": 40, "transferPerMonthInGb": 100, "cpuCount": 2, "isEncrypted": true, "isActive": true }, { "bundleId": "micro_ha_2_0", "name": "Micro with High Availability", "price": 30.0, "ramSizeInGb": 1.0, "diskSizeInGb": 40, "transferPerMonthInGb": 100, "cpuCount": 2, "isEncrypted": true, "isActive": true }, { "bundleId": "small_2_0", "name": "Small", "price": 30.0, "ramSizeInGb": 2.0, "diskSizeInGb": 80, "transferPerMonthInGb": 100, "cpuCount": 2, "isEncrypted": true, "isActive": true }, { "bundleId": "small_ha_2_0", "name": "Small with High Availability", "price": 60.0, "ramSizeInGb": 2.0, "diskSizeInGb": 80, "transferPerMonthInGb": 100, "cpuCount": 2, "isEncrypted": true, "isActive": true }, { "bundleId": "medium_2_0", "name": "Medium", "price": 60.0, "ramSizeInGb": 4.0, "diskSizeInGb": 120, "transferPerMonthInGb": 100, "cpuCount": 2, "isEncrypted": true, "isActive": true }, { "bundleId": "medium_ha_2_0", "name": "Medium with High Availability", "price": 120.0, "ramSizeInGb": 4.0, "diskSizeInGb": 120, "transferPerMonthInGb": 100, "cpuCount": 2, "isEncrypted": true, "isActive": true }, { "bundleId": "large_2_0", "name": "Large", "price": 115.0, "ramSizeInGb": 8.0, "diskSizeInGb": 240, "transferPerMonthInGb": 200, "cpuCount": 2, "isEncrypted": true, "isActive": true }, { "bundleId": "large_ha_2_0", "name": "Large with High Availability", "price": 230.0, "ramSizeInGb": 8.0, "diskSizeInGb": 240, "transferPerMonthInGb": 200, "cpuCount": 2, "isEncrypted": true, "isActive": true } ] }

有关更多信息,请参阅《亚马逊 Light sail 开发者指南》中的在 Amazon Light sail 中创建数据库

以下代码示例演示如何使用 get-relational-database-events

AWS CLI

获取关系数据库的事件

以下get-relational-database-events示例显示有关指定关系数据库在过去 17 小时(1020 分钟)内发生的事件的详细信息。

aws lightsail get-relational-database-events \ --relational-database-name Database-1 \ --duration-in-minutes 1020

输出:

{ "relationalDatabaseEvents": [ { "resource": "Database-1", "createdAt": 1571654146.553, "message": "Backing up Relational Database", "eventCategories": [ "backup" ] }, { "resource": "Database-1", "createdAt": 1571654249.98, "message": "Finished Relational Database backup", "eventCategories": [ "backup" ] } ] }

以下代码示例演示如何使用 get-relational-database-log-events

AWS CLI

获取关系数据库的日志事件

以下get-relational-database-log-events示例显示了有关介于1570733176和之间的关系数据库1571597176的指定日志的详细信息Database1。返回的信息配置为从开始head

我们建议您使用 unix 时间转换器来识别开始和结束时间。

aws lightsail get-relational-database-log-events \ --relational-database-name Database1 \ --log-stream-name error \ --start-from-head \ --start-time 1570733176 \ --end-time 1571597176

输出:

{ "resourceLogEvents": [ { "createdAt": 1570820267.0, "message": "2019-10-11 18:57:47 20969 [Warning] IP address '192.0.2.0' could not be resolved: Name or service not known" }, { "createdAt": 1570860974.0, "message": "2019-10-12 06:16:14 20969 [Warning] IP address '8192.0.2.0' could not be resolved: Temporary failure in name resolution" }, { "createdAt": 1570860977.0, "message": "2019-10-12 06:16:17 20969 [Warning] IP address '192.0.2.0' could not be resolved: Temporary failure in name resolution" }, { "createdAt": 1570860979.0, "message": "2019-10-12 06:16:19 20969 [Warning] IP address '192.0.2.0' could not be resolved: Temporary failure in name resolution" }, { "createdAt": 1570860981.0, "message": "2019-10-12 06:16:21 20969 [Warning] IP address '192.0.2.0' could not be resolved: Temporary failure in name resolution" }, { "createdAt": 1570860982.0, "message": "2019-10-12 06:16:22 20969 [Warning] IP address '192.0.2.0' could not be resolved: Temporary failure in name resolution" }, { "createdAt": 1570860984.0, "message": "2019-10-12 06:16:24 20969 [Warning] IP address '192.0.2.0' could not be resolved: Temporary failure in name resolution" }, { "createdAt": 1570860986.0, "message": "2019-10-12 06:16:26 20969 [Warning] IP address '192.0.2.0' could not be resolved: Temporary failure in name resolution" }, ... } ], "nextBackwardToken": "eEXAMPLEZXJUZXh0IjoiZnRWb3F3cUpRSlQ5NndMYThxelRUZlFhR3J6c2dKWEEvM2kvajZMZzVVVWpqRDN0YjFXTjNrak5pRk9iVFRZdjkwVGlpZGw5NFJGSFRQTEdJSjdpQnFCRk5CZFJlYTZaSXpScStuZjJEYXhqM2grUFVJOEpIYlU5YWJ2QitvQWN5cEFyVUo3VDk1QWY3bVF6MEwvcVovVldZdGc9Iiwibm9uY2UiOiJBNHpzdWMvUkZZKzRvUzhEIiwiY2lwaGVyIjoiQUVTL0dDTS9Ob1BhZGEXAMPLEQ==", "nextForwardToken": "eEXAMPLEZXJUZXh0IjoiT09Lb0Z6ZFRJbHhaNEQ5N2tPbkkwRmwwNUxPZjFTbFFwUklQbzlSaWgvMWVXbEk4aG56VHg4bW1Gb3grbDVodUVNZEdiZXN0TzVYcjlLK1FUdFB2RlJLS2FMcU05WkN3Rm1uVzBkOFpDR2g0b1BBVlg2NVFGNDNPazZzRXJieHRuU0xzdkRNTkFUMTZibU9HM2YyaGxiS0hUUDA9Iiwibm9uY2UiOiJFQmI4STQ3cU5aWXNXZ0g4IiwiY2lwaGVyIjoiQUVTL0dDTS9Ob1BhZGEXAMPLEQ==" }

以下代码示例演示如何使用 get-relational-database-log-streams

AWS CLI

获取关系数据库的日志流

以下get-relational-database-log-streams示例返回指定关系数据库的所有可用日志流。

aws lightsail get-relational-database-log-streams \ --relational-database-name Database1

输出:

{ "logStreams": [ "audit", "error", "general", "slowquery" ] }

以下代码示例演示如何使用 get-relational-database-master-user-password

AWS CLI

获取关系数据库的主用户密码

以下get-relational-database-master-user-password示例返回有关指定关系数据库的主用户密码的信息。

aws lightsail get-relational-database-master-user-password \ --relational-database-name Database-1

输出:

{ "masterUserPassword": "VEXAMPLEec.9qvx,_t<)Wkf)kwboM,>2", "createdAt": 1571259453.959 }

以下代码示例演示如何使用 get-relational-database-metric-data

AWS CLI

获取关系数据库的指标数据

以下get-relational-database-metric-data示例返回关系数据库之间的 24 小时(86400秒)内指标DatabaseConnections的计数总15707331761571597176Database1

我们建议您使用 unix 时间转换器来识别开始和结束时间。

aws lightsail get-relational-database-metric-data \ --relational-database-name Database1 \ --metric-name DatabaseConnections \ --period 86400 \ --start-time 1570733176 \ --end-time 1571597176 \ --unit Count \ --statistics Sum

输出:

{ "metricName": "DatabaseConnections", "metricData": [ { "sum": 1.0, "timestamp": 1571510760.0, "unit": "Count" }, { "sum": 1.0, "timestamp": 1570733160.0, "unit": "Count" }, { "sum": 1.0, "timestamp": 1570992360.0, "unit": "Count" }, { "sum": 0.0, "timestamp": 1571251560.0, "unit": "Count" }, { "sum": 721.0, "timestamp": 1570819560.0, "unit": "Count" }, { "sum": 1.0, "timestamp": 1571078760.0, "unit": "Count" }, { "sum": 2.0, "timestamp": 1571337960.0, "unit": "Count" }, { "sum": 684.0, "timestamp": 1570905960.0, "unit": "Count" }, { "sum": 0.0, "timestamp": 1571165160.0, "unit": "Count" }, { "sum": 1.0, "timestamp": 1571424360.0, "unit": "Count" } ] }

以下代码示例演示如何使用 get-relational-database-parameters

AWS CLI

获取关系数据库的参数

以下get-relational-database-parameters示例返回有关指定关系数据库的所有可用参数的信息。

aws lightsail get-relational-database-parameters \ --relational-database-name Database-1

输出:

{ "parameters": [ { "allowedValues": "0,1", "applyMethod": "pending-reboot", "applyType": "dynamic", "dataType": "boolean", "description": "Automatically set all granted roles as active after the user has authenticated successfully.", "isModifiable": true, "parameterName": "activate_all_roles_on_login", "parameterValue": "0" }, { "allowedValues": "0,1", "applyMethod": "pending-reboot", "applyType": "static", "dataType": "boolean", "description": "Controls whether user-defined functions that have only an xxx symbol for the main function can be loaded", "isModifiable": false, "parameterName": "allow-suspicious-udfs" }, { "allowedValues": "0,1", "applyMethod": "pending-reboot", "applyType": "dynamic", "dataType": "boolean", "description": "Sets the autocommit mode", "isModifiable": true, "parameterName": "autocommit" }, { "allowedValues": "0,1", "applyMethod": "pending-reboot", "applyType": "static", "dataType": "boolean", "description": "Controls whether the server autogenerates SSL key and certificate files in the data directory, if they do not already exist.", "isModifiable": false, "parameterName": "auto_generate_certs" }, ... } ] }

有关更多信息,请参阅 Lightsail 开发者指南中的更新 Amazon Lightsail 中的数据库参数

以下代码示例演示如何使用 get-relational-database-snapshot

AWS CLI

获取有关关系数据库快照的信息

以下get-relational-database-snapshot示例显示了有关指定关系数据库快照的详细信息。

aws lightsail get-relational-database-snapshot \ --relational-database-snapshot-name Database-1-1571350042

输出:

{ "relationalDatabaseSnapshot": { "name": "Database-1-1571350042", "arn": "arn:aws:lightsail:us-west-2:111122223333:RelationalDatabaseSnapshot/0389bbad-4b85-4c3d-9EXAMPLEaee3643d2", "supportCode": "6EXAMPLE3362/ls-8EXAMPLE2ba7ad041451946fafc2ad19cfbd9eb2", "createdAt": 1571350046.238, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "RelationalDatabaseSnapshot", "tags": [], "engine": "mysql", "engineVersion": "8.0.16", "sizeInGb": 40, "state": "available", "fromRelationalDatabaseName": "Database-1", "fromRelationalDatabaseArn": "arn:aws:lightsail:us-west-2:111122223333:RelationalDatabase/7ea932b1-b85a-4bd5-9b3e-bEXAMPLE8cc4", "fromRelationalDatabaseBundleId": "micro_1_0", "fromRelationalDatabaseBlueprintId": "mysql_8_0" } }

以下代码示例演示如何使用 get-relational-database-snapshots

AWS CLI

获取有关所有关系数据库快照的信息

以下get-relational-database-snapshots示例显示了有关已配置 AWS 区域中所有关系数据库快照的详细信息。

aws lightsail get-relational-database-snapshots

输出:

{ "relationalDatabaseSnapshots": [ { "name": "Database-1-1571350042", "arn": "arn:aws:lightsail:us-west-2:111122223333:RelationalDatabaseSnapshot/0389bbad-4b85-4c3d-9861-6EXAMPLE43d2", "supportCode": "6EXAMPLE3362/ls-8EXAMPLE2ba7ad041451946fafc2ad19cfbd9eb2", "createdAt": 1571350046.238, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "RelationalDatabaseSnapshot", "tags": [], "engine": "mysql", "engineVersion": "8.0.16", "sizeInGb": 40, "state": "available", "fromRelationalDatabaseName": "Database-1", "fromRelationalDatabaseArn": "arn:aws:lightsail:us-west-2:111122223333:RelationalDatabase/7ea932b1-b85a-4bd5-9b3e-bEXAMPLE8cc4", "fromRelationalDatabaseBundleId": "micro_1_0", "fromRelationalDatabaseBlueprintId": "mysql_8_0" }, { "name": "Database1-Console", "arn": "arn:aws:lightsail:us-west-2:111122223333:RelationalDatabaseSnapshot/8b94136e-06ec-4b1a-a3fb-5EXAMPLEe1e9", "supportCode": "6EXAMPLE3362/ls-9EXAMPLE14b000d34c8d1c432734e137612d5b5c", "createdAt": 1571249981.025, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "RelationalDatabaseSnapshot", "tags": [ { "key": "test" } ], "engine": "mysql", "engineVersion": "5.6.44", "sizeInGb": 40, "state": "available", "fromRelationalDatabaseName": "Database1", "fromRelationalDatabaseArn": "arn:aws:lightsail:us-west-2:111122223333:RelationalDatabase/a6161cb7-4535-4f16-9dcf-8EXAMPLE3d4e", "fromRelationalDatabaseBundleId": "micro_1_0", "fromRelationalDatabaseBlueprintId": "mysql_5_6" } ] }

以下代码示例演示如何使用 get-relational-database

AWS CLI

获取有关关系数据库的信息

以下get-relational-database示例显示有关指定关系数据库的详细信息。

aws lightsail get-relational-database \ --relational-database-name Database-1

输出:

{ "relationalDatabase": { "name": "Database-1", "arn": "arn:aws:lightsail:us-west-2:111122223333:RelationalDatabase/7ea932b1-b85a-4bd5-9b3e-bEXAMPLE8cc4", "supportCode": "6EXAMPLE3362/ls-9EXAMPLE8ad863723b62cc8901a8aa6e794ae0d2", "createdAt": 1571259453.795, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "resourceType": "RelationalDatabase", "tags": [], "relationalDatabaseBlueprintId": "mysql_8_0", "relationalDatabaseBundleId": "micro_1_0", "masterDatabaseName": "dbmaster", "hardware": { "cpuCount": 1, "diskSizeInGb": 40, "ramSizeInGb": 1.0 }, "state": "available", "backupRetentionEnabled": false, "pendingModifiedValues": {}, "engine": "mysql", "engineVersion": "8.0.16", "masterUsername": "dbmasteruser", "parameterApplyStatus": "in-sync", "preferredBackupWindow": "10:01-10:31", "preferredMaintenanceWindow": "sat:11:14-sat:11:44", "publiclyAccessible": true, "masterEndpoint": { "port": 3306, "address": "ls-9EXAMPLE8ad863723b62ccEXAMPLEa6e794ae0d2.czowadgeezqi.us-west-2.rds.amazonaws.com" }, "pendingMaintenanceActions": [] } }

以下代码示例演示如何使用 get-relational-databases

AWS CLI

获取有关所有关系数据库的信息

以下get-relational-databases示例显示了有关已配置 AWS 区域中所有关系数据库的详细信息。

aws lightsail get-relational-databases

输出:

{ "relationalDatabases": [ { "name": "MySQL", "arn": "arn:aws:lightsail:us-west-2:111122223333:RelationalDatabase/8529020c-3ab9-4d51-92af-5EXAMPLE8979", "supportCode": "6EXAMPLE3362/ls-3EXAMPLEa995d8c3b06b4501356e5f2f28e1aeba", "createdAt": 1554306019.155, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "resourceType": "RelationalDatabase", "tags": [], "relationalDatabaseBlueprintId": "mysql_8_0", "relationalDatabaseBundleId": "micro_1_0", "masterDatabaseName": "dbmaster", "hardware": { "cpuCount": 1, "diskSizeInGb": 40, "ramSizeInGb": 1.0 }, "state": "available", "backupRetentionEnabled": true, "pendingModifiedValues": {}, "engine": "mysql", "engineVersion": "8.0.15", "latestRestorableTime": 1571686200.0, "masterUsername": "dbmasteruser", "parameterApplyStatus": "in-sync", "preferredBackupWindow": "07:51-08:21", "preferredMaintenanceWindow": "tue:12:18-tue:12:48", "publiclyAccessible": true, "masterEndpoint": { "port": 3306, "address": "ls-3EXAMPLEa995d8c3b06b4501356e5f2fEXAMPLEa.czowadgeezqi.us-west-2.rds.amazonaws.com" }, "pendingMaintenanceActions": [] }, { "name": "Postgres", "arn": "arn:aws:lightsail:us-west-2:111122223333:RelationalDatabase/e9780b6b-d0ab-4af2-85f1-1EXAMPLEac68", "supportCode": "6EXAMPLE3362/ls-3EXAMPLEb4fffb5cec056220c734713e14bd5fcd", "createdAt": 1554306000.814, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "resourceType": "RelationalDatabase", "tags": [], "relationalDatabaseBlueprintId": "postgres_11", "relationalDatabaseBundleId": "micro_1_0", "masterDatabaseName": "dbmaster", "hardware": { "cpuCount": 1, "diskSizeInGb": 40, "ramSizeInGb": 1.0 }, "state": "available", "backupRetentionEnabled": true, "pendingModifiedValues": {}, "engine": "postgres", "engineVersion": "11.1", "latestRestorableTime": 1571686339.0, "masterUsername": "dbmasteruser", "parameterApplyStatus": "in-sync", "preferredBackupWindow": "06:19-06:49", "preferredMaintenanceWindow": "sun:10:19-sun:10:49", "publiclyAccessible": false, "masterEndpoint": { "port": 5432, "address": "ls-3EXAMPLEb4fffb5cec056220c734713eEXAMPLEd.czowadgeezqi.us-west-2.rds.amazonaws.com" }, "pendingMaintenanceActions": [] } ] }

以下代码示例演示如何使用 get-static-ip

AWS CLI

获取有关静态 IP 的信息

以下get-static-ip示例显示有关指定静态 IP 的详细信息。

aws lightsail get-static-ip \ --static-ip-name StaticIp-1

输出:

{ "staticIp": { "name": "StaticIp-1", "arn": "arn:aws:lightsail:us-west-2:111122223333:StaticIp/2257cd76-1f0e-4ac0-82e2-2EXAMPLE23ad", "supportCode": "6EXAMPLE3362/192.0.2.0", "createdAt": 1571071325.076, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "StaticIp", "ipAddress": "192.0.2.0", "isAttached": false } }

以下代码示例演示如何使用 get-static-ips

AWS CLI

获取有关所有静态的信息 IPs

以下get-static-ips示例显示了有关已配置 AWS 区域IPs中所有静态的详细信息。

aws lightsail get-static-ips

输出:

{ "staticIps": [ { "name": "StaticIp-1", "arn": "arn:aws:lightsail:us-west-2:111122223333:StaticIp/2257cd76-1f0e-4ac0-8EXAMPLE16f9423ad", "supportCode": "6EXAMPLE3362/192.0.2.0", "createdAt": 1571071325.076, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "StaticIp", "ipAddress": "192.0.2.0", "isAttached": false }, { "name": "StaticIP-2", "arn": "arn:aws:lightsail:us-west-2:111122223333:StaticIp/c61edb40-e5f0-4fd6-ae7c-8EXAMPLE19f8", "supportCode": "6EXAMPLE3362/192.0.2.2", "createdAt": 1568305385.681, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "StaticIp", "ipAddress": "192.0.2.2", "attachedTo": "WordPress-1", "isAttached": true } ] }

以下代码示例演示如何使用 is-vpc-peered

AWS CLI

识别您的 Amazon Lightsail 虚拟私有云是否处于对等状态

以下is-vpc-peered示例返回指定区域的 Amazon Lightsail 虚拟私有云 VPC () 的对 AWS 等状态。

aws lightsail is-vpc-peered \ --region us-west-2

输出:

{ "isPeered": true }

以下代码示例演示如何使用 open-instance-public-ports

AWS CLI

为实例打开防火墙端口

以下open-instance-public-ports示例在指定实例上打开TCP端口 22。

aws lightsail open-instance-public-ports \ --instance-name MEAN-2 \ --port-info fromPort=22,protocol=TCP,toPort=22

输出:

{ "operation": { "id": "719744f0-a022-46f2-9f11-6EXAMPLE4642", "resourceName": "MEAN-2", "resourceType": "Instance", "createdAt": 1571072906.849, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "22/tcp", "operationType": "OpenInstancePublicPorts", "status": "Succeeded", "statusChangedAt": 1571072906.849 } }

以下代码示例演示如何使用 peer-vpc

AWS CLI

对等亚马逊 Lightsail 虚拟私有云

以下peer-vpc示例对指定 AWS 区域的 Amazon Lightsail 虚拟私有云 (VPC) 进行对等。

aws lightsail peer-vpc \ --region us-west-2

输出:

{ "operation": { "id": "787e846a-54ac-497f-bce2-9EXAMPLE5d91", "resourceName": "vpc-0EXAMPLEa5261efb3", "resourceType": "PeeredVpc", "createdAt": 1571694233.104, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "vpc-e2b3eb9b", "operationType": "PeeredVpc", "status": "Succeeded", "statusChangedAt": 1571694233.104 } }

以下代码示例演示如何使用 reboot-instance

AWS CLI

重启实例

以下reboot-instance示例重新启动指定的实例。

aws lightsail reboot-instance \ --instance-name MEAN-1

输出:

{ "operations": [ { "id": "2b679f1c-8b71-4bb4-8e97-8EXAMPLEed93", "resourceName": "MEAN-1", "resourceType": "Instance", "createdAt": 1571694445.49, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "", "operationType": "RebootInstance", "status": "Succeeded", "statusChangedAt": 1571694445.49 } ] }

以下代码示例演示如何使用 reboot-relational-database

AWS CLI

重新启动关系数据库

以下reboot-relational-database示例重新启动指定的关系数据库。

aws lightsail reboot-relational-database \ --relational-database-name Database-1

输出:

{ "operations": [ { "id": "e4c980c0-3137-496c-9c91-1EXAMPLEdec2", "resourceName": "Database-1", "resourceType": "RelationalDatabase", "createdAt": 1571694532.91, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationDetails": "", "operationType": "RebootRelationalDatabase", "status": "Started", "statusChangedAt": 1571694532.91 } ] }

以下代码示例演示如何使用 release-static-ip

AWS CLI

删除静态 IP

以下release-static-ip示例删除了指定的静态 IP。

aws lightsail release-static-ip \ --static-ip-name StaticIp-1

输出:

{ "operations": [ { "id": "e374c002-dc6d-4c7f-919f-2EXAMPLE13ce", "resourceName": "StaticIp-1", "resourceType": "StaticIp", "createdAt": 1571694962.003, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationType": "ReleaseStaticIp", "status": "Succeeded", "statusChangedAt": 1571694962.003 } ] }

以下代码示例演示如何使用 start-instance

AWS CLI

启动实例

以下start-instance示例启动指定的实例。

aws lightsail start-instance \ --instance-name WordPress-1

输出:

{ "operations": [ { "id": "f88d2a93-7cea-4165-afce-2d688cb18f23", "resourceName": "WordPress-1", "resourceType": "Instance", "createdAt": 1571695583.463, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "StartInstance", "status": "Started", "statusChangedAt": 1571695583.463 } ] }

以下代码示例演示如何使用 start-relational-database

AWS CLI

启动关系数据库

以下start-relational-database示例启动指定的关系数据库。

aws lightsail start-relational-database \ --relational-database-name Database-1

输出:

{ "operations": [ { "id": "4d5294ec-a38a-4fda-9e37-aEXAMPLE0d24", "resourceName": "Database-1", "resourceType": "RelationalDatabase", "createdAt": 1571695998.822, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "StartRelationalDatabase", "status": "Started", "statusChangedAt": 1571695998.822 } ] }

以下代码示例演示如何使用 stop-instance

AWS CLI

停止实例

以下stop-instance示例停止指定的实例。

aws lightsail stop-instance \ --instance-name WordPress-1

输出:

{ "operations": [ { "id": "265357e2-2943-4d51-888a-1EXAMPLE7585", "resourceName": "WordPress-1", "resourceType": "Instance", "createdAt": 1571695471.134, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "StopInstance", "status": "Started", "statusChangedAt": 1571695471.134 } ] }

以下代码示例演示如何使用 stop-relational-database

AWS CLI

停止关系数据库

以下stop-relational-database示例停止指定的关系数据库。

aws lightsail stop-relational-database \ --relational-database-name Database-1

输出:

{ "operations": [ { "id": "cc559c19-4adb-41e4-b75b-5EXAMPLE4e61", "resourceName": "Database-1", "resourceType": "RelationalDatabase", "createdAt": 1571695526.29, "location": { "availabilityZone": "us-west-2a", "regionName": "us-west-2" }, "isTerminal": false, "operationType": "StopRelationalDatabase", "status": "Started", "statusChangedAt": 1571695526.29 } ] }

以下代码示例演示如何使用 unpeer-vpc

AWS CLI

取消对等 Amazon Lightsail 虚拟私有云

以下unpeer-vpc示例取消了指定区域的 Amazon Lightsail 虚拟私有云 VPC () 的 AWS 同步。

aws lightsail unpeer-vpc \ --region us-west-2

输出:

{ "operation": { "id": "531aca64-7157-47ab-84c6-eEXAMPLEd898", "resourceName": "vpc-0EXAMPLEa5261efb3", "resourceType": "PeeredVpc", "createdAt": 1571694109.945, "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "isTerminal": true, "operationDetails": "vpc-e2b3eb9b", "operationType": "UnpeeredVpc", "status": "Succeeded", "statusChangedAt": 1571694109.945 } }