【发布时间】:2018-02-16 00:16:32
【问题描述】:
我已阅读“Specifying Principals in a Policy”文档:https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-bucket-user-policy-specifying-principal-intro.html,并从中推断出一些行为以及其他未专门处理 Cloudformation 的 SO(如 aws lambda function getting access denied when getObject from s3)问题。
当我尝试创建一个授予外部角色访问本地存储桶的策略时,我仍然对此错误感到困惑。 Cloudformation 的错误是:Policy document should not specify a principal.
情况细分
我有两个 AWS 账户。账户 A 创建了一个存储桶,我想授予账户 B 对其的写入权限。
在账户 A Cloudformation 中我创建了一个策略,授予账户 B 角色访问所述存储桶的权限。来自https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html 的指南。该角色存在于帐户 B。
AccountBWriteToS3Policy:
Type: 'AWS::IAM::Policy'
Properties:
PolicyName: AccountBWriteToS3Policy
PolicyDocument:
Version: 2012-10-17
Statement:
- Principal:
AWS: 'arn:aws:iam::123456789876:role/AccountBRole'
Effect: Allow
Action:
- 's3:PutObject'
- 's3:ListBucket'
Resource: !Sub
- '${bucketArn}/*'
- bucketArn: !GetAtt
- AccountABucket
- Arn
Roles:
- AccountARole
但是,cloudformation 无法执行,并回滚并出现错误
Policy document should not specify a principal.
我很困惑。
谁能解释这个错误?
谁能指明前进的道路?
这似乎是一个简单而常见的需求,在许多示例中都有介绍。也许我应该在存储桶声明本身中指定策略,而不是创建帐户范围的策略?
【问题讨论】:
标签: amazon-web-services amazon-s3 amazon-cloudformation amazon-iam