0
我得到以下錯誤,執行AWS CLI命令時:aws ec2 describe-instances --filters "Name=instance-type,Values=m1.small"
:(使用CLI)AWS是無法驗證所提供的訪問憑據
A client error (AuthFailure) occurred when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials
的憑據與下面的腳本:
import boto3
sts_client = boto3.client('sts')
assumedRoleObject = sts_client.assume_role(
RoleArn="arn:aws:iam::<>:role/service-role/Test-Project",
RoleSessionName="AssumeRoleSession2"
)
credentials = assumedRoleObject['Credentials']
print credentials['AccessKeyId']
print "#"*100
print credentials['SecretAccessKey']
print "#"*100
print credentials['SessionToken']
print "#"*100
我已經測試了在角色上啓用管理員訪問權限。還是行不通。
角色的信任關係如下:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": [
"*",
"arn:aws:iam::<>:user/<username>"
],
"Service": [
"lambda.amazonaws.com",
"ec2.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}
]
}
你從'AWS IAM GET-user'得到什麼? –
@AdamOwczarczyk我得到了同樣的錯誤:調用GetUser操作時出現客戶端錯誤(InvalidClientTokenId):請求中包含的安全令牌無效。' – Dawny33
因此,您的'aws configure'出錯了,您提供的憑證是無效的,或者,或者,您的會話令牌超時,因爲您將其設置爲非常短的時間段。 Manish的答案有更多細節。 –