代码之家  ›  专栏  ›  技术社区  ›  Nirojan Selvanathan

安全凭据的AWS EC2元数据提供空响应

  •  1
  • Nirojan Selvanathan  · 技术社区  · 8 年前

    enter image description here

    当我试图通过元数据im检索aws安全凭据时,得到一个空响应。

    curl http://169.254.169.254/latest/meta-data/iam/security-credentials
    

    但当我试图调用该信息时,它会提供以下响应。

    curl http://169.254.169.254/latest/meta-data/iam/info
    {
      "Code" : "Success",
      "LastUpdated" : "2018-08-20T07:03:12Z",
      "InstanceProfileArn" : "arn:aws:iam::accountID:instance-profile/ec2-full-access-role",
      "InstanceProfileId" : "Instance profile ID"
    }
    

    其他人是否也遇到过相同的问题,或者是否有任何解决方法来获取安全凭据?

    1 回复  |  直到 8 年前
        1
  •  5
  •   John Rotenstein    8 年前

    你需要在结尾加上斜线:

    curl http://169.254.169.254/latest/meta-data/iam/security-credentials/
    

    然后它将返回角色的名称。

    ec2-full-access-role 您可以使用:

    curl http://169.254.169.254/latest/meta-data/iam/security-credentials/ec2-full-access-role/