调用 AssumeRole 操作时发生错误 (AccessDenied)
An error occurred (AccessDenied) when calling the AssumeRole operation
我有一个 lambda 函数 (lambda-get-details) 在 [ 中使用以下 IAM 角色创建=26=]账户-A
角色名: lambdarole
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*",
"Effect": "Allow"
},
{
"Action": [
"config:PutEvaluations",
"ec2:DescribeImages",
"sts:AssumeRole"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
相同的IAM角色名称(lambdarole)在不同的账户中创建以及账号-B
现在 Account-A 的 lambda 函数需要从 Account- 获取详细信息B 例如(AMI 列表),我们得到以下错误
"errorMessage": "An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:sts::Account-A:assumed-role/lambdarole/lambda-get-details is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::Account-B:role/lambdarole
谁能帮我解决上面的问题。
如有任何帮助,我们将不胜感激
谢谢
在 Account-A 中,lambdarole
的策略允许角色代入任何角色 ARN(包括 Account-B[=35 中的角色) =]).此语句已解决此问题
{
"Action": [
"sts:AssumeRole"
],
"Resource": "*",
"Effect": "Allow"
}
与 Account-B 类似,角色 lambdarole
应该包含一个信任策略,允许从 Account-A.
将账户A的AccountID
或lambdarole
角色ARN添加为账户B[=中的委托人35=] 的 lambdarole
的 AssumeRolePolicyDocument。
AssumeRolePolicyDocument
看起来像这样(如果帐户 ID 用作委托人),
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect" : "Allow",
"Action": "sts:AssumeRole",
"Principal": {
"AWS" : "<Account-ID-of-Account-A>"
}
}
]
}
您可以参考 here 了解如何使用 IAM 角色建立跨账户访问。
我有一个 lambda 函数 (lambda-get-details) 在 [ 中使用以下 IAM 角色创建=26=]账户-A
角色名: lambdarole
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*",
"Effect": "Allow"
},
{
"Action": [
"config:PutEvaluations",
"ec2:DescribeImages",
"sts:AssumeRole"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
相同的IAM角色名称(lambdarole)在不同的账户中创建以及账号-B
现在 Account-A 的 lambda 函数需要从 Account- 获取详细信息B 例如(AMI 列表),我们得到以下错误
"errorMessage": "An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:sts::Account-A:assumed-role/lambdarole/lambda-get-details is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::Account-B:role/lambdarole
谁能帮我解决上面的问题。
如有任何帮助,我们将不胜感激
谢谢
在 Account-A 中,lambdarole
的策略允许角色代入任何角色 ARN(包括 Account-B[=35 中的角色) =]).此语句已解决此问题
{
"Action": [
"sts:AssumeRole"
],
"Resource": "*",
"Effect": "Allow"
}
与 Account-B 类似,角色 lambdarole
应该包含一个信任策略,允许从 Account-A.
将账户A的AccountID
或lambdarole
角色ARN添加为账户B[=中的委托人35=] 的 lambdarole
的 AssumeRolePolicyDocument。
AssumeRolePolicyDocument
看起来像这样(如果帐户 ID 用作委托人),
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect" : "Allow",
"Action": "sts:AssumeRole",
"Principal": {
"AWS" : "<Account-ID-of-Account-A>"
}
}
]
}
您可以参考 here 了解如何使用 IAM 角色建立跨账户访问。