我有一个建立在账户A上的代码构建,以及一个存在于账户B上的S3存储桶。我尝试在账户B上设置了一个受信任的IAM STS角色和策略,并在账户A上包含了账户B的IAM角色,将此策略附加到我的codebuild服务角色上。但是,我的codebuild仍然显示s3上的存储桶。我在这里做错或配置了什么吗?
在账户B上拥有信任关系的角色
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::Account:root"
},
"Action": "sts:AssumeRole",
"Condition": {}
}
]
Account A的政策
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::Account B:role/testcli"
}
]
}
CodeBuild BuildSpec.yml
version: 0.2
env:
variables:
TF_VERSION: "0.12.28"
phases:
install:
commands:
# install required binary
- echo test
pre_build:
commands:
- echo print s3 buckets
- aws s3 ls
post_build:
commands:
- echo test1
buildspec.yml
中显式地扮演角色。我可以提供附加细节的答案。 - Marcin