I have my codebuild build sitting on Account A and s3 buckets on Account B. I tried to set up a trusted IAM STS role on Account B and policy on Account A to include the Account B IAM role, attached this policy to my codebuild service role. But still, my codebuild shows buckets on s3. Am I doing or configuring something wrong here?
Role with trust relation on Account B
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::Account:root"
},
"Action": "sts:AssumeRole",
"Condition": {}
}
]
policy on 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