我正在尝试在我的 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 实例查询?
如果您将角色附加到给定的 ec2 实例,则以下元数据 URI 将返回一些内容:
http://169.254.169.254/latest/meta-data/iam/security-credentials/
所以您似乎没有附加 IAM 角色。请核实。
我昨天遇到了这个问题。我的自动化创建了一个实例配置文件,但它没有承担角色。
{
"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"
}
]
}
}
]
}
}
我在使用 Terraform 更改 IAM 角色后遇到了这个问题。 我仍然不知道为什么会发生这种情况,但通过 aws 控制台将 IAM 角色分离并重新附加到实例解决了该问题。