AWS:找不到 iam 的实例元数据

问题描述 投票:0回答:3

我正在尝试在我的 ec2 实例上设置 elasticsearch s3 快照。它失败并出现以下错误:

nested: NotSerializableExceptionWrapper[sdk_client_exception: The requested metadata is not found at http://169.254.169.254/latest/meta-data/iam/security-credentials/

如果我从该 ec2 实例查询元数据服务器,它会响应以下内容:

$ curl http://169.254.169.254/latest/meta-data/
ami-id
ami-launch-index
ami-manifest-path
block-device-mapping/
events/
hostname
identity-credentials/
instance-action
instance-id
instance-type
local-hostname
local-ipv4
mac
metrics/
network/
placement/
profile
public-keys/
reservation-id
security-groups
services/

所以没有iam部分。

如何使 iam 部分可用于从 ec2 实例查询?

amazon-web-services amazon-s3 amazon-ec2
3个回答
10
投票

如果您将角色附加到给定的 ec2 实例,则以下元数据 URI 将返回一些内容:

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

所以您似乎没有附加 IAM 角色。请核实。


1
投票

我昨天遇到了这个问题。我的自动化创建了一个实例配置文件,但它没有承担角色。

{
    "InstanceProfile": {
        "Path": "/",
        "InstanceProfileName": "example_instance_profile",
        "InstanceProfileId": "<id>",
        "Arn": "<arn>",
        "CreateDate": "«date_time>",
        "Roles": []
    }
}

我删除了此实例配置文件并通过自动化再次创建。

{
    "InstanceProfile": {
        "Path": "/",
        "InstanceProfileName": "<profile_name>",
        "InstanceProfileId": "<profile_id>",
        "Arn": "<arn>",
        "CreateDate": "«date_time>",
        "Roles": [
            {
                "Path": "/",
                "RoleName": "<role_name>",
                "RoleId": "<role_id>",
                "Arn": "<arn>",
                "CreateDate": "<date>",
                "AssumeRolePolicyDocument": {
                    "Version": "<date>",
                    "Statement": [
                        {
                            "Sid": "",
                            "Effect": "Allow",
                            "Principal": {
                                "Service": "ec2.amazonaws.com"
                            },
                            "Action": "sts:AssumeRole"
                        }
                    ]
                }
            }
        ]
    }
}

0
投票

我在使用 Terraform 更改 IAM 角色后遇到了这个问题。 我仍然不知道为什么会发生这种情况,但通过 aws 控制台将 IAM 角色分离并重新附加到实例解决了该问题。

© www.soinside.com 2019 - 2024. All rights reserved.