Role Data
    • PDF

    Role Data

    • PDF

    Article summary

    Available in VPC

    View information regarding the role assigned to a server instance.

    A role must be assigned to the server instance through Sub Account to use the query features related to roles. For more information about assigning roles, see Manage role in the Sub Account user guide.
    Role ID query and temporary access key issuance features are available in the ncloud-sdk and Object Storage CLI when no access key is set in both the environment variable and the configure file.

    Note

    For the list of ncloud-sdks by language and installation instructions, and for more information about using the Ncloud CLI and Object Storage CLI, see the following.

    Request

    The following describes the request format for the endpoint. The request format is as follows:

    Call pathDescription
    /{version}/meta-data/iam/View the list of the role-related metadata items provided in the applicable version
    /{version}/meta-data/iam/infoView details of the role assigned to the server instance
    /{version}/meta-data/iam/security-credentialsView the ID of the role assigned to the server instance
    • No newline character (\n) at the end of the output result
    • It can be used internally by ncloud-sdk and Object Storage CLI to obtain role IDs
    /{version}/meta-data/iam/security-credentials/{roleId}Issue a temporary access key (STS) for the role assigned to the server instance
    • The issued temporary access key gains permissions according to the policy set in the role
    • It is available in API, CLI, SDK, just like access keys for sub accounts
    • No newline character (\n) at the end of the output result
    • It can be used internally by ncloud-sdk and Object Storage CLI to obtain temporary access keys

    Examples

    See below for an example.

    Metadata v1

    The following is an example of Metadata v1.

    # View item
    [root@test-server ~]# curl http://169.254.169.254/latest/meta-data/iam/
    info
    security-credentials
    
    # View role details
    [root@test-server ~]# curl http://169.254.169.254/latest/meta-data/iam/info
    {
      "roleId" : "***-***-***-***-***ec4",
      "roleName" : "test-role",
      "roleType" : "Server",
      "createTime" : "2024-05-04T08:24:35Z"
    }
    
    # View role ID
    [root@test-server ~]# curl http://169.254.169.254/latest/meta-data/iam/security-credentials
    ***-***-***-***-***ec4[root@test-server ~]#
    
    # Issue temporary access key ID
    [root@test-server ~]# curl http://169.254.169.254/latest/meta-data/iam/security-credentials/***-***-***-***-***ec4
    {
      "Type" : "NCP-HMAC",
      "AccessKeyId" : "s_***976",
      "SecretAccessKey" : "***6ab",
      "Expiration" : "2024-05-22T11:50:45Z",
      "Token" : "",
      "LastUpdated" : "2024-04-21T23:50:45Z",
      "Code" : "Success"
    }[root@test-server ~]#
    

    Metadata v2

    The following is an example of Metadata v2.
    The second and subsequent requests in the example use the token generated by the first request, assuming it hasn't expired.

    # View item
    [root@test-server ~]# TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-NCP-METADATA-TOKEN-TTL-SECONDS: 21600"` \
    && curl -H "X-NCP-METADATA-TOKEN: $TOKEN" http://169.254.169.254/latest/meta-data/iam/
    info
    security-credentials
    
    # View role details
    [root@test-server ~]# curl -H "X-NCP-METADATA-TOKEN: $TOKEN" http://169.254.169.254/latest/meta-data/iam/info
    {
      "roleId" : "***-***-***-***-***ec4",
      "roleName" : "test-role",
      "roleType" : "Server",
      "createTime" : "2024-05-04T08:24:35Z"
    }
    
    # View role ID
    [root@test-server ~]# curl -H "X-NCP-METADATA-TOKEN: $TOKEN" http://169.254.169.254/latest/meta-data/iam/security-credentials
    ***-***-***-***-***ec4[root@test-server ~]#
    
    # Issue temporary access key ID
    [root@test-server ~]# curl -H "X-NCP-METADATA-TOKEN: $TOKEN" http://169.254.169.254/latest/meta-data/iam/security-credentials/***-***-***-***-***ec4
    {
      "Type" : "NCP-HMAC",
      "AccessKeyId" : "s_***976",
      "SecretAccessKey" : "***6ab",
      "Expiration" : "2024-05-22T11:50:45Z",
      "Token" : "",
      "LastUpdated" : "2024-04-21T23:50:45Z",
      "Code" : "Success"
    }[root@test-server ~]#
    

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.