Lightsail 示例使用 AWS CLI - AWS Command Line Interface

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

Lightsail 示例使用 AWS CLI

下列程式碼範例說明如何使用 Lightsail 來執行動作及實作常見案例。 AWS Command Line Interface

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境和跨服務範例中查看內容中的動作。

Scenarios (案例) 是向您展示如何呼叫相同服務中的多個函數來完成特定任務的程式碼範例。

每個範例都包含一個連結 GitHub,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

下列程式碼範例會示範如何使用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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考AllocateStaticIp中的。

下列程式碼範例會示範如何使用attach-disk

AWS CLI

將區塊儲存磁碟附加至執行個體

下列attach-disk範例會將磁碟附加Disk-1WordPress_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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考AttachDisk中的。

下列程式碼範例會示範如何使用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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考AttachStaticIp中的。

下列程式碼範例會示範如何使用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 Region 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從 Re AWS gion 複製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 中保留執行個體或磁碟的自動快照

  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考CopySnapshot中的。

下列程式碼範例會示範如何使用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 } ] }

如需詳細資訊,請參閱 Li ghtsail 開發人員指南中的從快照建立區塊儲存磁碟

下列程式碼範例會示範如何使用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 } ] }

如需詳細資訊,請參閱 Amazon Lightsail 中的快照和 Lightsail 開發人員指南中的建立執行個體根磁碟區的快照。

下列程式碼範例會示範如何使用create-disk

AWS CLI

建立區塊儲存磁碟

下列create-disk範例會在具有 32 GB 儲存空Disk-1間的指定 AWS 區域和可用區域中建立區塊儲存磁碟。

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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考CreateDisk中的。

下列程式碼範例會示範如何使用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 } }

如需詳細資訊,請參閱 Lightsail 開發人員指南中的 DNS 和在 Amazon 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 } }

如需詳細資訊,請參閱 Lightsail 開發人員指南中的 DNS 和在 Amazon Lightsail 中建立 DNS 區域以管理您網域的 DNS 記錄。

  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考CreateDomain中的。

下列程式碼範例會示範如何使用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範例使用 $10 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 medium_2_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 藍圖和 $3.50 USD 服務包在指定的區域和可用區 AWS 域中建立執行個體。

aws lightsail create-instances \ --instance-names Instance-1 \ --availability-zone us-west-2a \ --blueprint-id wordpress_5_1_1_2 \ --bundle-id nano_2_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 藍圖和 $3.50 USD 服務包,在指定的區 AWS 域和可用區域中建立三個執行個體。

aws lightsail create-instances \ --instance-names {"Instance1","Instance2","Instance3"} \ --availability-zone us-west-2a \ --blueprint-id wordpress_5_1_1_2 \ --bundle-id nano_2_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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考CreateInstances中的。

下列程式碼範例會示範如何使用create-key-pair

AWS CLI

建立一組金鑰對

下列create-key-pair範例會建立 key pair,供您用來驗證並連線至執行個體。

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

輸出提供私密金鑰 base64 值,您可以使用此值向使用建立 key pair 的執行個體進行驗證。注意:將私鑰 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 } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考CreateKeyPair中的。

下列程式碼範例會示範如何使用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範例會使用 MySQL 5.6 資料庫引擎 (mysql_5_6) 和 15 美元的標準資料庫服務包 (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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考DeleteDisk中的。

下列程式碼範例會示範如何使用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 } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考DeleteDomain中的。

下列程式碼範例會示範如何使用delete-instance-snapshot

AWS CLI

標題

下列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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考DeleteInstance中的。

下列程式碼範例會示範如何使用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 } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考DeleteKeyPair中的。

下列程式碼範例會示範如何使用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 開發人員指南中的疑難排解使用 Amazon 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範例會StaticIp-1從任何連接的執行個體卸離靜態 IP。

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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考DetachStaticIp中的。

下列程式碼範例會示範如何使用get-active-names

AWS CLI

若要取得使用中資源名稱

下列get-active-names範例會傳回已設定之 AWS Region 中的作用中資源名稱。

aws lightsail get-active-names

輸出:

{ "activeNames": [ "WordPress-1", "StaticIp-1", "MEAN-1", "Plesk_Hosting_Stack_on_Ubuntu-1" ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetActiveNames中的。

下列程式碼範例會示範如何使用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 中保留執行個體或磁碟的自動快照

  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetAutoSnapshots中的。

下列程式碼範例會示範如何使用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": "5.2.2-3", "versionCode": "1", "productUrl": "https://aws.amazon.com/marketplace/pp/B00NN8Y43U", "licenseUrl": "https://d7umqicpi7263.cloudfront.net/eula/product/7d426cb7-9522-4dd7-a56b-55dd8cc1c8d0/588fd495-6492-4610-b3e8-d15ce864454c.txt", "platform": "LINUX_UNIX" }, { "blueprintId": "lamp_7_1_28", "name": "LAMP (PHP 7)", "group": "lamp_7", "type": "app", "description": "LAMP with PHP 7.x certified by Bitnami greatly simplifies the development and deployment of PHP applications. It includes the latest versions of PHP 7.x, Apache and MySQL together with phpMyAdmin and popular PHP frameworks Zend, Symfony, CodeIgniter, CakePHP, Smarty, and Laravel. Other pre-configured components and PHP modules include FastCGI, ModSecurity, SQLite, Varnish, ImageMagick, xDebug, Xcache, OpenLDAP, Memcache, OAuth, PEAR, PECL, APC, GD and cURL. It is secure by default and supports multiple applications, each with its own virtual host and project directory. Let's Encrypt SSL certificates are supported through an auto-configuration script.", "isActive": true, "minPower": 0, "version": "7.1.28", "versionCode": "1", "productUrl": "https://aws.amazon.com/marketplace/pp/B072JNJZ5C", "licenseUrl": "https://d7umqicpi7263.cloudfront.net/eula/product/cb6afd05-a3b2-4916-a3e6-bccd414f5f21/12ab56cc-6a8c-4977-9611-dcd770824aad.txt", "platform": "LINUX_UNIX" }, { "blueprintId": "nodejs", "name": "Node.js", "group": "node", "type": "app", "description": "Node.js certified 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": "12.7.0", "versionCode": "1", "productUrl": "https://aws.amazon.com/marketplace/pp/B00NNZUAKO", "licenseUrl": "https://d7umqicpi7263.cloudfront.net/eula/product/033793fe-951d-47d0-aa94-5fbd0afb3582/25f8fa66-c868-4d80-adf8-4a2b602064ae.txt", "platform": "LINUX_UNIX" }, ... } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetBlueprints中的。

下列程式碼範例會示範如何使用get-bundles

AWS CLI

若要取得新執行個體的套件

下列get-bundles範例顯示可用於在 Amazon Lightsail 中建立新執行個體之所有可用套裝軟體的詳細資訊。

aws lightsail get-bundles

輸出:

{ "bundles": [ { "price": 3.5, "cpuCount": 1, "diskSizeInGb": 20, "bundleId": "nano_2_0", "instanceType": "nano", "isActive": true, "name": "Nano", "power": 300, "ramSizeInGb": 0.5, "transferPerMonthInGb": 1024, "supportedPlatforms": [ "LINUX_UNIX" ] }, { "price": 5.0, "cpuCount": 1, "diskSizeInGb": 40, "bundleId": "micro_2_0", "instanceType": "micro", "isActive": true, "name": "Micro", "power": 500, "ramSizeInGb": 1.0, "transferPerMonthInGb": 2048, "supportedPlatforms": [ "LINUX_UNIX" ] }, { "price": 10.0, "cpuCount": 1, "diskSizeInGb": 60, "bundleId": "small_2_0", "instanceType": "small", "isActive": true, "name": "Small", "power": 1000, "ramSizeInGb": 2.0, "transferPerMonthInGb": 3072, "supportedPlatforms": [ "LINUX_UNIX" ] }, ... } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetBundles中的。

下列程式碼範例會示範如何使用get-cloud-formation-stack-records

AWS CLI

若要取得 CloudFormation 堆疊記錄及其相關的堆疊

下列get-cloud-formation-stack-records範例顯示堆疊記錄及其相關 CloudFormation 堆疊的詳細資料,以及用於從匯出的 Amazon Lightsail 快照建立 Amazon 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 } }

如需詳細資訊,請參閱指南中的標題。

  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetDiskSnapshot中的。

下列程式碼範例會示範如何使用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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetDiskSnapshots中的。

下列程式碼範例會示範如何使用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" } }

如需詳細資訊,請參閱指南中的標題。

  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetDisk中的。

下列程式碼範例會示範如何使用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" } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetDisks中的。

下列程式碼範例會示範如何使用get-domain

AWS CLI

取得網域的相關資訊

下列get-domain範例會顯示有關網域的詳細資料example.com

注意:Lightsail 的網域相關 API 作業僅適用於區域。us-east-1 AWS 如果您的 CLI 設定檔設定為使用不同的區域,則必須包含 ``-區域 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" } ] } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetDomain中的。

下列程式碼範例會示範如何使用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" } ] } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetDomains中的。

下列程式碼範例會示範如何使用get-export-snapshot-record

AWS CLI

取得匯出至 Amazon EC2 的快照記錄

下列get-export-snapshot-record範例顯示有關匯出至 Amazon EC2 的 Amazon Lightsail 執行個體或磁碟快照的詳細資訊。

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範例會傳回1571342400和之間CPUUtilization7200秒 (2 小時) 的平均百1571428800分比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_4_0_9", "fromBundleId": "medium_2_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_5_1_1_2", "fromBundleId": "micro_2_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_4_0_9", "fromBundleId": "medium_2_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" } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetInstanceState中的。

下列程式碼範例會示範如何使用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_4_0_9", "blueprintName": "MEAN", "bundleId": "medium_2_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/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": "MyKey" } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetInstance中的。

下列程式碼範例會示範如何使用get-instances

AWS CLI

取得所有執行處理的相關資訊

下列get-instances範例會顯示已設定之 AWS 區域中所有執行個體的詳細資訊。

aws lightsail get-instances

輸出:

{ "instances": [ { "name": "Windows_Server_2016-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_2016", "blueprintName": "Windows Server 2016", "bundleId": "small_win_2_0", "isStaticIp": false, "privateIpAddress": "192.0.2.0", "publicIpAddress": "192.0.2.0", "hardware": { "cpuCount": 1, "disks": [ { "createdAt": 1571332358.665, "sizeInGb": 60, "isSystemDisk": true, "iops": 180, "path": "/dev/sda1", "attachedTo": "Windows_Server_2016-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_2016-1", "isAttached": true, "attachmentState": "attached" } ], "ramSizeInGb": 2.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_4_0_9", "blueprintName": "MEAN", "bundleId": "medium_2_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": 100, "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" } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetInstances中的。

下列程式碼範例會示範如何使用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" } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetKeyPair中的。

下列程式碼範例會示範如何使用get-key-pairs

AWS CLI

取得有關所有金鑰配對的資訊

下列get-key-pairs範例會顯示已設定之 AWS Region 中所有金鑰配對的詳細資訊。

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" } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetKeyPairs中的。

下列程式碼範例會示範如何使用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" } } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetLoadBalancer中的。

下列程式碼範例會示範如何使用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" } } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetLoadBalancers中的。

下列程式碼範例會示範如何使用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 } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetOperation中的。

下列程式碼範例會示範如何使用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 }, ... } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetOperations中的。

下列程式碼範例會示範如何使用get-regions

AWS CLI

取得 Amazon Light AWS sail 的所有區域

下列get-regions範例顯示有關 Amazon 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": [] }, ... } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetRegions中的。

下列程式碼範例會示範如何使用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 } ] }

如需詳細資訊,請參閱 Amazon Lightsail 開發人員指南中的在 Amazon Lightsail 中建立資料庫

下列程式碼範例會示範如何使用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範例會顯示關聯式資料庫之間15707331761571597176之間指定記錄的詳細資料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範例會傳回關聯式資料庫之DatabaseConnections間 24 小時 (86400秒) 期間的測量結果總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" }, ... } ] }

如需詳細資訊,請參閱 Amazon Li ghtsail 開發人員指南中的更新資料庫參數

下列程式碼範例會示範如何使用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 Region 中所有關聯式資料庫的詳細資料。

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 } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetStaticIp中的。

下列程式碼範例會示範如何使用get-static-ips

AWS CLI

取得所有靜態 IP 的相關資訊

下列get-static-ips範例會顯示已設定 AWS 區域中所有靜態 IP 的詳細資料。

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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetStaticIps中的。

下列程式碼範例會示範如何使用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 }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考IsVpcPeered中的。

下列程式碼範例會示範如何使用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

對等 Amazon Lightsail 虛擬私有雲

下列peer-vpc範例會針對指定區域的 Amazon Lightsail 虛擬私有雲端 (VPC) 進行 AWS 對等。

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 } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考PeerVpc中的。

下列程式碼範例會示範如何使用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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考RebootInstance中的。

下列程式碼範例會示範如何使用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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考ReleaseStaticIp中的。

下列程式碼範例會示範如何使用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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考StartInstance中的。

下列程式碼範例會示範如何使用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 } ] }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考StopInstance中的。

下列程式碼範例會示範如何使用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 } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考UnpeerVpc中的。