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

3분 분량
0

AWS CLI를 사용하여 Amazon Lightsail 인스턴스에서 고정 IP 주소를 분리하고 새 Lightsail 인스턴스에 연결하려고 합니다.

간략한 설명


Lightsail AWS Command Line Interface(AWS CLI) 명령 목록은 AWS CLI Command ReferenceAmazon Lightsail API Reference를 참조하세요.

중요:

AWS CLI 출력에는 타임스탬프가 Unix Epoch 시간으로 표시됩니다. 다음 방법 중 하나를 사용하여 타임스탬프를 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 타임스탬프 변환 도구와 같은 변환 도구를 사용하여 타임스탬프를 변경합니다.

해결 방법

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

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을 자신의 값으로 바꿉니다. 이 예제에서는 eu-west-1 AWS 리전의 인스턴스에서 고정 IP 주소를 분리합니다.

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

고정 IP 주소를 Lightsail 인스턴스에 연결하려면 다음 단계를 완료하세요.

  1. attach-static-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
            }
        ]
    참고: 이전 명령에서 --static-ip-name, --instance-name--region을 자신의 값으로 바꿉니다. 이 명령은 백업을 사용하여 고정 IP 주소를 새 인스턴스에 연결합니다.
  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 인스턴스에 대한 백업을 생성하려면 어떻게 해야 하나요?

Lightsail 인스턴스 및 디스크에 대한 자동 스냅샷 활성화 또는 비활성화

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