Ongoing service disruptions
For the most recent update on ongoing service disruptions affecting the AWS Middle East (UAE) Region (ME-CENTRAL-1), refer to the AWS Health Dashboard. For information on AWS Service migration, see How do I migrate my services to another region?
AWS CLI を使用して Lightsail インスタンスの静的 IP アドレスを管理するにはどうすればよいですか?
AWS CLI を使用して静的 IP アドレスを今の Amazon Lightsail インスタンスからデタッチして新しい Lightsail インスタンスにアタッチしたいと考えています。
簡単な説明
Lightsail AWS コマンドラインインターフェイス (AWS CLI) コマンドのリストについては、「AWS CLI コマンドリファレンス」と「Amazon Lightsail API リファレンス」を参照してください。
重要:
- AWS CLI のコマンドの実行時にエラーが表示される場合は、「AWS CLI エラーのトラブルシューティング」を参照してください。また、AWS CLI の最新バージョンを使用していることを確認してください。
- JSON は AWS CLI のデフォルト出力です。出力を受け取るためには、デフォルトを使用することも、コマンドの後に --output json を追加することもできます。詳細については、「AWS CLI からのコマンド出力を制御する」を参照してください。
- AWS CLI エラーの解決方法に関する一般情報については、「AWS CLI コマンドを実行するとエラーが表示されるのはなぜですか?」を参照してください。
AWS CLI の出力には、Unix エポック時間のタイムスタンプが表示されます。タイムスタンプを UTC に変換するには、次のいずれかの方法を使用します。
macOS の場合:
タイムスタンプから小数点を削除し、小数点の右に数字があればそれもすべて削除してから、次のコマンドを実行します。
# date -r 1602175741 -u Thu Oct 8 16:49:01 UTC 2020
Linux の場合:
次のコマンドを実行します。
# date -d @1602175741.603 -u Thu Oct 8 16:49:01 UTC 2020
Windows の場合:
タイムスタンプを変更するには変換ツール (EpochConverter ウェブサイトの Epoch および Unix のタイムスタンプ変換ツールなど) を使用します。
解決方法
静的 IP アドレスを既存の Lightsail インスタンスからデタッチする
detach-static-ip コマンドを実行して、静的 IP アドレスをインスタンスからデタッチします。
# aws lightsail detach-static-ip --static-ip-name StaticIpForTestLightsailInstance1 --region eu-west-1 { "operations": [ { "id": "c86e552e-c21a-4cdf-aa68-05fb20574e8b", "resourceName": "StaticIpForTestLightsailInstance1", "resourceType": "StaticIp", "createdAt": 1602182597.168, "location": { "availabilityZone": "all", "regionName": "eu-west-1" }, "isTerminal": true, "operationDetails": "TestLightsailInstance1", "operationType": "DetachStaticIp", "status": "Succeeded", "statusChangedAt": 1602182597.168 }, { "id": "4b9dcaa7-be3a-4dfd-8ac0-32f0238c0833", "resourceName": "TestLightsailInstance1", "resourceType": "Instance", "createdAt": 1602182597.17, "location": { "availabilityZone": "eu-west-1a", "regionName": "eu-west-1" }, "isTerminal": true, "operationDetails": "StaticIpForTestLightsailInstance1", "operationType": "DetachStaticIp", "status": "Succeeded", "statusChangedAt": 1602182597.17 } ] }
注: 前述の例で、--static-ip-name と**--region** は、該当する値に置き換えてください。この例では、静的 IP アドレスを eu-west-1 AWS リージョンのインスタンスからデタッチします。
静的 IP アドレスを新しい Lightsail インスタンスにアタッチする
静的 IP アドレスを Lightsail インスタンスにアタッチするには、次の手順を実行します。
- attach-static-ip コマンドを次のように実行します。
注: 前述のコマンドで、--static-ip-name、--instance-name、--region は、該当する値に置き換えてください。このコマンドではバックアップを使用して、静的 IP アドレスを新しいインスタンスにアタッチします。# aws lightsail attach-static-ip --static-ip-name StaticIpForTestLightsailInstance1 --instance-name RestoredTestLightsailInstance1-New --region eu-west-1 { "operations": [ { "id": "192c4917-c332-49c8-88ab-60484a42c98f", "resourceName": "StaticIpForTestLightsailInstance1", "resourceType": "StaticIp", "createdAt": 1602182686.46, "location": { "availabilityZone": "all", "regionName": "eu-west-1" }, "isTerminal": true, "operationDetails": "RestoredTestLightsailInstance1-New", "operationType": "AttachStaticIp", "status": "Succeeded", "statusChangedAt": 1602182686.46 }, { "id": "fb93c012-e3a2-4908-8746-01a4ae018440", "resourceName": "RestoredTestLightsailInstance1-New", "resourceType": "Instance", "createdAt": 1602182686.463, "location": { "availabilityZone": "eu-west-1a", "regionName": "eu-west-1" }, "isTerminal": true, "operationDetails": "StaticIpForTestLightsailInstance1", "operationType": "AttachStaticIp", "status": "Succeeded", "statusChangedAt": 1602182686.463 } ] - get-instances コマンドを実行して、静的 IP アドレスがインスタンスに割り当てられていることを確認します。
# aws lightsail get-instances --region eu-west-1 --query 'instances[].{name:name,createdAt:createdAt,blueprintId:blueprintId,bundleid:bundleId,blueprintName:blueprintName,publicIpAddress:publicIpAddress,InstanceID:supportCode}' --output table ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | GetInstances | +----------------------------------+------------------+----------------+------------+-----------------+------------------------------------------+-------------------+ | InstanceID | blueprintId | blueprintName | bundleid | createdAt | name | publicIpAddress | +----------------------------------+------------------+----------------+------------+-----------------+------------------------------------------+-------------------+ | 11178xxxxxxx/i-09f6xxxx| wordpress | WordPress | large_2_0 | 1602182374.625 | RestoredTestLightsailInstance1-New | 52.210.xx.xx | +----------------------------------+------------------+----------------+------------+-----------------+------------------------------------------+-------------------+
関連情報
AWS CLI のコマンドを使用して Lightsail インスタンスを管理する方法を教えてください。
AWS CLI コマンドを使用してスナップショットを管理したり Lightsail インスタンスのバックアップを作成したりするにはどうすればよいですか?
