AWS CLI 명령을 사용하여 Lightsail 인스턴스에서 고정 IP 주소를 관리하려면 어떻게 해야 하나요?

3분 분량
0

Amazon Lightsail 인스턴스에서 고정 IP 주소를 분리하여 새 Lightsail 인스턴스에 연결하려 합니다. AWS 명령줄 인터페이스(AWS CLI) 명령을 사용하여 이 작업을 수행하려면 어떻게 해야 하나요?

간략한 설명

Amazon Lightsail AWS CLI 명령 목록은 AWS CLI 명령 참조Amazon Lightsail API 참조를 참조하세요.

중요: AWS CLI 명령을 사용할 때는 다음 사항에 유의하세요.

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.com과 같은 변환기를 사용하여 타임스탬프를 변환합니다.

해결 방법

기존 Lightsail 인스턴스에서 고정 IP 주소 분리

detach-static-ip 명령을 실행하여 인스턴스에서 정적 IP 주소를 분리합니다. 다음 예제에서는 eu-west-1 리전의 인스턴스에서 고정 IP 주소를 분리합니다. --static-ip-name--region을 요청에 적절한 값으로 바꿉니다.

# 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
        }
    ]
}

새 Lightsail 인스턴스에 고정 IP 주소 연결

1.    attach-static-ip 명령을 실행하여 고정 IP 주소를 백업의 새 인스턴스에 연결합니다. --static-ip-name, --instance-name, --region을 요청에 적절한 값으로 바꿉니다.

# 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
        }
    ]
}

2.    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 인스턴스에 대한 스냅샷을 관리하고 백업을 생성하려면 어떻게 해야 하나요?

Amazon Lightsail에서 인스턴스 또는 디스크의 자동 스냅샷 활성화 또는 비활성화

Lightsail 문서

AWS 공식
AWS 공식업데이트됨 3년 전