不能承担查找角色
Cannot assume lookup role
我正在尝试将 AWS CDK 管道从账户 A(部署账户)部署到账户 B(工作负载账户)。作为我的 CDK 代码的一部分,我正在执行 VPC ID 查找:
var lambdaVpc = Vpc.FromLookup(this, "VPC", new VpcLookupOptions{
VpcId = Vpc.id
});
但是,当我的管道运行时出现以下错误:
Could not assume role in target account using current credentials (which are for account ${DeploymentAccount})
User: arn:aws:sts::${DeploymentAccount}:assumed-role/te-cdk-pipeline-mis-servi-tecdkpipelinemisservicej-UPT0J1RO1RFR/AWSCodeBuild-7bcbd3a0-8159-454b-a886-18f8dd1df58c is not authorized to perform: sts:AssumeRole on resource:
arn:aws:iam::${WorkloadAccount}:role/cdk-hnb659fds-lookup-role-${WorkloadAccount}-ap-southeast-2 .
Please make sure that this role exists in the account. If it doesn't exist, (re)-bootstrap the environment with the right '--trust', using the latest version of the CDK CLI.
我的工作负载帐户角色具有以下策略:
{
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::${WorkloadAccount}:root"
},
"Action": "sts:AssumeRole"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::${DeploymentAccount}:root"
},
"Action": "sts:AssumeRole"
}
]
}
据我所知,这应该允许部署帐户承担并使用此角色。所有这些 Roles/Permissions 都是由 CDK/the 引导过程创建的。
我已经尝试删除我的管道并重新部署(以便 CDK 重新创建所有 IAM Roles/Policies)但到目前为止没有成功。
有人遇到过这个吗?
推荐的做法是在具有执行查找所需权限的本地计算机上合成一次应用程序,然后将 cdk.context.json
提交到 git,这将使管道使用缓存的值并且不需要执行任何查找。
这是使您的 CDK 代码具有确定性的最佳实践 - 它应该始终合成相同的模板,并确保您只在实现此目的后才进行网络调用。
我正在尝试将 AWS CDK 管道从账户 A(部署账户)部署到账户 B(工作负载账户)。作为我的 CDK 代码的一部分,我正在执行 VPC ID 查找:
var lambdaVpc = Vpc.FromLookup(this, "VPC", new VpcLookupOptions{
VpcId = Vpc.id
});
但是,当我的管道运行时出现以下错误:
Could not assume role in target account using current credentials (which are for account ${DeploymentAccount})
User: arn:aws:sts::${DeploymentAccount}:assumed-role/te-cdk-pipeline-mis-servi-tecdkpipelinemisservicej-UPT0J1RO1RFR/AWSCodeBuild-7bcbd3a0-8159-454b-a886-18f8dd1df58c is not authorized to perform: sts:AssumeRole on resource:
arn:aws:iam::${WorkloadAccount}:role/cdk-hnb659fds-lookup-role-${WorkloadAccount}-ap-southeast-2 .
Please make sure that this role exists in the account. If it doesn't exist, (re)-bootstrap the environment with the right '--trust', using the latest version of the CDK CLI.
我的工作负载帐户角色具有以下策略:
{
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::${WorkloadAccount}:root"
},
"Action": "sts:AssumeRole"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::${DeploymentAccount}:root"
},
"Action": "sts:AssumeRole"
}
]
}
据我所知,这应该允许部署帐户承担并使用此角色。所有这些 Roles/Permissions 都是由 CDK/the 引导过程创建的。
我已经尝试删除我的管道并重新部署(以便 CDK 重新创建所有 IAM Roles/Policies)但到目前为止没有成功。
有人遇到过这个吗?
推荐的做法是在具有执行查找所需权限的本地计算机上合成一次应用程序,然后将 cdk.context.json
提交到 git,这将使管道使用缓存的值并且不需要执行任何查找。
这是使您的 CDK 代码具有确定性的最佳实践 - 它应该始终合成相同的模板,并确保您只在实现此目的后才进行网络调用。