A developer is configuring an AWS CodeBuild project in Account that must retrieve database configuration credentials from AWS Systems Manager Parameter Store in Account . The developer creates an IAM role named CrossAccountParamReaderRole in Account with permission to read the parameters.
The CodeBuild project's service role in Account has permissions to assume CrossAccountParamReaderRole. However, during the build phase, the CodeBuild build fails with an AccessDenied error when executing the assume-role CLI command.
The trust policy for CrossAccountParamReaderRole in Account is configured as follows:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "codebuild.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Which modification to the trust policy in Account will resolve this issue?
- Update the Principal block of the trust policy to reference Account or the specific CodeBuild service role ARN instead of the CodeBuild service principal.Cevap
- BAdd a Statement to the trust policy with the Action ssm:GetParameters and the Resource set to the parameter ARNs.
- CAdd the CodeBuild service role ARN from Account to the Resource element in the statement of the trust policy.
- DConfigure the buildspec.yml file to store the Access Key ID and Secret Access Key of an IAM user from Account directly in plain text environment variables.