我想使用awsssm:描述关于ec2实例(i-0691847a77),方法是假定IAM角色(IAM_ssm_角色),该角色定义了以下策略。在
两个IAM角色位于同一个aws帐户上,并且已在IAM_ssm_角色中将arn添加为受信任策略。在
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"ssm:*",
"ec2:DescribeImages",
"cloudwatch:PutMetricData",
"ec2:DescribeInstances",
"lambda:InvokeFunction",
"ec2:DescribeTags",
"ec2:DescribeVpcs",
"cloudwatch:GetMetricStatistics",
"ec2:DescribeSubnets",
"ec2:DescribeKeyPairs",
"cloudwatch:ListMetrics",
"ec2:DescribeSecurityGroups"
],
"Resource": "*"
}
我在一个具有IAM角色(IAM_base_role)的ec2实例上运行以下代码
^{pr2}$我收到拒绝访问错误,假定的角色显示为“iam_ssm_role”,但看起来ssm正在使用iam_base_role而不是iam_ssm_角色运行
AROAV6BDS6PTVQBU:iam_ssm_role
botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the DescribeInstanceInformation operation: User: arn:aws:sts::000001:assumed-role/iam_base_role/i-0691847a77 is not authorized to perform: ssm:DescribeInstanceInformation on resource: arn:aws:ssm:us-east-1:000001:*
好的,我发现我以前的代码有问题,我没有在boto3.client SSM部分使用假定的iam角色的凭据。在
我现在可以成功运行代码,我正在使用下面的代码。在
相关问题 更多 >
编程相关推荐