Consider central_secrets_account
with AWS account id XXXXXXXXXXXX that holds secrets that need to be shared with a blue_green_account
YYYYYYYYYYYYY. I wish to create a cloudformation stack in blue_green_account
that will access a secret in central_secrets_account
.
My method is based on sts:AssumeRole
chaining as follows. I have created a blue_green_role
in blue_green_account
that can be assumed by the local cloudformation service. The blue_green_role
trust policy is
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "cloudformation.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
and its permissions policy is
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sts:AssumeRole"
],
"Resource": "arn:aws:iam::XXXXXXXXXXXX:role/cross-account-read-secret-role"
}
]
}
which allows it to assume a secret-reading role that resides in the central_secrets_account
.
Similarly, the cross-account-read-secret-role
in central_secrets_account
has a trust policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::YYYYYYYYYYYY:role/blue_green_role",
"arn:aws:sts::YYYYYYYYYYYY:assumed-role/blue_green_role/AWSCloudFormation"
]
},
"Action": "sts:AssumeRole"
}
]
}
and its permissions policy (which is loose, just get this going) is
{
"Action": [
"secretsmanager:*"
],
"Resource": "*",
"Effect": "Allow"
},
However, when I spin up the stack in the blue_green_account
which has a dynamic reference {{resolve:secretsmanager:arn:aws:secretsmanager:eu-west-2:XXXXXXXXXXXX:secret:secret_name_zzzzzz}}
in the cloudformation template, I get the following error
User: arn:aws:sts::YYYYYYYYYYYYYY:assumed-role/blue_green_role/AWSCloudFormation is not authorized to perform: secretsmanager:GetSecretValue on resource: arn:aws:secretsmanager:eu-west-2:XXXXXXXXXXXX:secret:secret_name_zzzzzz because no identity-based policy allows the secretsmanager:GetSecretValue action
I've tried many different adjustments to get this to work, but to no avail. There is another KMS permissions method but I feel the role assuming method is more simple for our use case.