I am trying to create a CloudFormation Stack using the AWS CLI by running the following command:
aws cloudformation create-stack --debug --stack-name ${stackName} --template-url ${s3TemplatePath} --parameters '${parameters}' --region eu-west-1
The template resides in an S3 bucket in the another account, lets call this account 456. The bucket policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Example permissions",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::123:root"
]
},
"Action": [
"s3:*"
],
"Resource": "arn:aws:s3:::cloudformation.template.eberry.digital/*"
}
]
}
("Action: * " is for debugging).
Now for a twist. I am logged into account 456 and I run
aws sts assume-role --role-arn arn:aws:iam::123:role/delegate-access-to-infrastructure-account-role --role-session-name jenkins
and the set the correct environment variables to access 123. The policy attached to the role that I assume allow the user Administrator access while I debug - which still doesn't work.
aws s3api list-buckets
then display the buckets in account 123.
To summarize:
- Specifying a template in an S3 bucket owned by account 456, into CloufFormation in the console, while logged into account 123 works.
- Specifying a template in an S3 bucket owned by account 123, using the CLI, works.
- Specifying a template in an S3 bucket owned by account 456, using the CLI, doesn't work.
The error:
An error occurred (ValidationError) when calling the CreateStack operation: S3 error: Access Denied For more information check http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html
I don't understand what I am doing wrong and would by thankful for any ideas. In the meantime I will upload the template to all accounts that will use it.
aws sts assume-role ...
and setting environment. Can you callaws sts get-caller-identity
to prove that you really using temp permissions? – Michał Zaborowskiaws s3 ls
/aws s3 ls bucket_name
- maybe that way something pop up... – Michał Zaborowskiaws s3api head --bucket --key
from the and was able to get the details of the file from the CLI. Still, referencing it in --template-url doesn't work. – Jonatanaws s3 ls
is more convenient from command line. Well it complains about S3 permissions, and you clearly provided admin access. Looks like the bug. Please report a bug - forums.aws.amazon.com - looked there, but no luck... – Michał Zaborowski