• Elastic Cloud Server

ecs
  1. Help Center
  2. Elastic Cloud Server
  3. User Guide
  4. ECS Instances
  5. Managing User Data and Metadata
  6. Managing ECS Metadata

Managing ECS Metadata

ECS metadata is used to configure or manage running ECSs. Table 1 lists the two sets of APIs that ECS metadata supports.

Table 1 ECS metadata types

API Type

Metadata Type

Description

Compatibility

OpenStack metadata API

Metadata

Displays ECS metadata.

Compatible. For details, see Table 2.

Password

Displays the password for logging in to an ECS.

Compatible. This metadata is used by Cloud-Init to store ciphertext passwords during initialization of key-pair-authenticated Windows ECSs.

User data

Displays ECS user data.

Compatible. This metadata allows you to specify scripts and configuration files for initializing ECSs. For details, see section Injecting User Data into ECSs.

For password-authenticated Linux ECSs, save the password injection script.

Network data

Displays ECS network information.

Compatible.

Vendor data

Displays ECS initialization configuration.

This metadata can be viewed only when the target ECS initialization configuration is available. Otherwise, this metadata is left blank by default.

Security Key

Obtains temporary AKs and SKs.

Compatible.

Before obtaining a temporary AK and SK on an ECS, make sure that the op_svc_ecs account has been authorized on IAM and that the desired ECS resources have been authorized for management.

EC2 compatible API

hostname

Displays the name of the host accommodating an ECS.

Compatible.

To remove the suffix .novalocal from an ECS, see:

Is the ECS Hostname with Suffix novalocal Normal?

instance-type

Displays an ECS flavor.

Compatible.

local-ipv4

Displays the fixed IP address of an ECS. If there are multiple NICs, only the IP address of the primary NIC is displayed.

Compatible.

availability-zone

Displays the AZ accommodating an ECS.

Compatible.

public-ipv4

Displays the floating IP address of an ECS. If there are multiple NICs, only the floating IP address of the primary NIC is displayed.

Compatible.

public_keys

Displays the public key of an ECS.

Compatible.

user-data

Displays ECS user data.

Compatible.

security-groups

Displays the security group to which an ECS belongs.

Compatible.

Table 2 metadata field description

Parameter

Mandatory

Type

Description

uuid

Yes

String

Identifies an ECS.

availability-zone

Yes

String

Specifies the AZ where an ECS locates.

image_name

Yes

String

Specifies the image name.

image_id

No

String

Specifies the image ID.

hostname

Yes

String

Specifies the name of the host accommodating an ECS.

To remove the suffix .novalocal from an ECS, see:

Is the ECS Hostname with Suffix novalocal Normal?

vpc_id

Yes

String

Specifies the ID of the VPC for an ECS.

The following describes the URI and methods of using the supported ECS metadata.

Prerequisites

Security group rules in the outbound direction meet the following requirements:

  • ProtocolTCP
  • Port Range80
  • Remote End169.254.0.0/16
NOTE:

If you use the default security group rules in the outbound direction, the preceding requirements are met, and the metadata can be accessed. Default security group rules in the outbound direction are as follows:

  • ProtocolANY
  • Port RangeANY
  • Remote End0.0.0.0/16

Metadata (OpenStack Metadata API)

Displays ECS metadata.

  • URI

    /169.254.169.254/openstack/{version}/meta_data.json

  • Usage method

    Supports GET requests.

  • Example

    The following section describes how to use the tool cURL to view ECS metadata.

    curl http://169.254.169.254/openstack/latest/meta_data.json

    {
        "admin_pass": "sWs9YVAiytTs",
        "availability_zone": "manage-az",
        "files": [
            {
                "content_path": "/content/0000",
                "path": "/etc/litao.ini"
            }
        ],
        "hostname": "lt-test-01.novalocal",
        "launch_index": 0,
        "meta": {
            "test_key": "test_vaule"
        },
        "name": "lt-test-01",
        "public_keys": {
            "novakey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCr4Mk6fRqbPRXE3lq9NivYvrysz0/D+gAWCgKCG46lU+x3aLRRtUwpSoX4W7FtRegHAp7EpIhmW40vM+9HrKEZbQsaiyfe0VP/cHZFKJLU9cnDJNMIb0WoIjLWDORnUnsfZL1tFaYyIcAdIl6TuB92sj4Bg8xrYCn3nfNtSSfHHszvHIc0kys7AC+ellL4NWlyeGDSkmsHS0vnIP0mpRgpB2QShmx/ZEIQQ+YxMoL8z+A44+v/V+/R8K7aJK3LbQ8Yu8vwky9M1OLG176s9pQnTmdlrKNWc4dYC8zNRxaFvyuUO9FD71OSEkmoZwkbhYHmIVIw49d0OIr63ok8mMij root@6B1AA2D2-3B57-11DA-8567-000000821800\n"
        },
        "random_seed": "ptvKzBu5SNFrWKAiar62VT7KOGZS38T3VdpEjRDmBOwF0RGKvjNGXasAXZo8KfzBPCq+MupA4Ig9mUyHWJiAcI7IvOQV7EWubJ4pxQn2tNxrwRR7VdSR8WJUqeZV1FjxxgxjJkQtnWmrT57J+SEaqzRP64ONYdikPnBlOIpnsj+gKMXxDmFL3tQ0ljC2vKdZdbjc8QkT84/dnbJpx/DaatkiLWVVTmlGhP72j/0NH1JbAnv5EECS5z51h2YFnRxJOJFlSCwnl5UuFRjsO82T+7usRjK0IXAvDIKcqQlzrV5WWXrWc1e+yejIjjVvAGad5PcjLeaGaEEBNo5eBJ9e4FZHLkkUV7naYGsLiOLjO3qZjvFM1gcaKsrv92/Ys2DbwHFfV0Xo/uNA9Jx7MFIXELdNOfDP8nS4fVp52w6KOUvQ1iEhEBaOlQVKENJ6jfbSYCoYe4JGK/UeGCaVhjZPpe8L9nVjn2QYfe6e/p1TxRk1MFe6LgrpQXR8SzEJ71+X6j+pRvP8Ui8W1M88esq+ZqbjjIpAxR9ISmd/aTM7WGa7OLOXxDsWQDBAH7J/86u4P1Zebs6vFgORM+RUc2PFAOMSEQ2Ak0UlhX9FrqoK9plol7x9m8aQAj0Sd89lMiCDTgVbk8DSZA4qT5lnYzqZYAvg9XWItCLkeM+C05P7748=",
        "uuid": "32274de3-6efe-45b3-86a8-46c4335ffeb7"
    }

User data (OpenStack Metadata API)

Displays ECS user data. The value is configured only when you create an ECS. It cannot be changed after the configuration.

  • URI

    /169.254.169.254/openstack/{version}/user_data

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/openstack/latest/user_data

    ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==

Security Key (OpenStack Metadata API)

Obtains temporary AKs and SKs.

NOTE:
  • Before obtaining a temporary AK and SK on an ECS, make sure that the op_svc_ecs account has been authorized on IAM and that the desired ECS resources have been authorized for management.
  • Temporary AKs and SKs expire an hour later.
  • When using temporary AKs and SKs, add 'X-Security-Token':securitytoken in the message header. securitytoken is the value returned when a call is made to the API.
  • URI

    /openstack/{version}/securitykey

  • Usage method

    Supports GET requests.

  • Examples

    curl http://169.254.169.254/openstack/latest/securitykey

User Data (EC2 Compatible API)

Displays ECS user data. The value is configured only when you create an ECS. It cannot be changed after the configuration.

  • URI

    /169.254.169.254/{version}/user-data

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/user-data

    ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==

Hostname (EC2 Compatible API)

Displays the name of the host accommodating an ECS. The .novalocal suffix will be added later.

  • URI

    /169.254.169.254/{version}/meta-data/hostname

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/hostname

    vm-test.novalocal

Instance Type (EC2 Compatible API)

Displays an ECS flavor.

  • URI

    /169.254.169.254/{version}/meta-data/instance-type

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/instance-type

    s3.samll.1

Local IPv4 (EC2 Compatible API)

Displays the fixed IP address of an ECS. If there are multiple NICs, only the IP address of the primary NIC is displayed.

  • URI

    /169.254.169.254/{version}/meta-data/local-ipv4

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/local-ipv4

    192.1.1.2

Availability Zone (EC2 Compatible API)

Displays the AZ accommodating an ECS.

  • URI

    /169.254.169.254/{version}/meta-data/placement/availability-zone

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/placement/availability-zone

    az1.dc1

Public IPv4 (EC2 Compatible API)

Displays the floating IP address of an ECS. If there are multiple NICs, only the floating IP address of the primary NIC is displayed.

  • URI

    /169.254.169.254/{version}/meta-data/public-ipv4

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/public-ipv4

    46.1.1.2

Public Keys (EC2 Compatible API)

Displays the public key of an ECS.

  • URI

    /169.254.169.254/latest/meta-data/public-keys/0/openssh-key

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key

    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDI5Fw5k8Fgzajn1zJwLoV3+wMP+6CyvsSiIc/hioggSnYu/AD0Yqm8vVO0kWlun1rFbdO+QUZKyVr/OPUjQSw4SRh4qsTKf/+eFoWTjplFvd1WCBZzS/WRenxIwR00KkczHSJro763+wYcwKieb4eKRxaQoQvoFgVjLBULXAjH4eKoKTVNtMXAvPP9aMy2SLgsJNtMb9ArfziAiblQynq7UIfLnN3VclzPeiWrqtzjyOp6CPUXnL0lVPTvbLe8sUteBsJZwlL6K4i+Y0lf3ryqnmQgC21yW4Dzu+kwk8FVT2MgWkCwiZd8gQ/+uJzrJFyMfUOBIklOBfuUENIJUhAB Generated-by-Nova

Reservation ID (EC2 Compatible API)

Displays an ECS reservation ID.

  • URI

    /169.254.169.254/{version}/meta-data/reservation-id

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/reservation-id

    r-kso0e196