我希望允许帐户中具有共享前缀的角色能够从 S3 存储桶中读取。例如,我们有多个名为RolePrefix1、RolePrefix2等的角色,将来可能会创建更多这样的角色。我们希望账户中的所有角色RolePrefix都能够访问 S3 存储桶,而无需在将来更改策略文档。
我的存储桶策略文档的 terraform 如下:
data "aws_iam_policy_document" "bucket_policy_document" {
statement {
effect = "Allow"
actions = ["s3:GetObject"]
principals = {
type = "AWS"
identifiers = ["arn:aws:iam::111122223333:role/RolePrefix*"]
}
resources = ["${aws_s3_bucket.bucket.arn}/*"]
}
}
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
Error putting S3 policy: MalformedPolicy: Invalid principal in policy.
是否可以通过其他方式实现此功能?