看起来我在 Terraform 部署中得到了一个格式错误的策略,并且在查看它时没有看到任何问题,所有这些Principals
似乎都到位并且没有任何异常。有人能找出为什么这个政策被认为是畸形的吗?
这是抛出的 TF 输出
module.s3-bucket.aws_s3_bucket_policy.bucket_policy: Creating...
bucket: "" => "the_s3_bucket"
policy: "" => "{\n \"Version\":\"2012-10-17\",\n \"Statement\":[{\n \"Principal\": \"*\",\n \"Action\":[\n \"s3:GetBucketLocation\",\n \"s3:ListAllMyBuckets\"\n ],\n \"Resource\":[\n \"arn:aws:s3:::*\"\n ],\n \"Effect\":\"Allow\"\n }, {\n \"Principal\": \"*\",\n \"Action\":[\n \"s3:ListBucket\",\n \"s3:ListBucketMultipartUploads\"\n ],\n \"Resource\":[\n \"arn:aws:s3:::the_s3_bucket\"\n ],\n \"Effect\":\"Allow\"\n }, {\n \"Principal\": \"*\",\n \"Action\":[\n \"s3:GetObject\",\n \"s3:AbortMultipartUpload\",\n \"s3:ListMultipartUploadParts\",\n \"s3:DeleteObject\",\n \"s3:PutObject\",\n \"s3:GetObjectAcl\",\n \"s3:PutObjectAcl\"\n ],\n \"Resource\":[\n \"arn:aws:s3:::the_s3_bucket/*\"\n ],\n \"Effect\":\"Allow\"\n }]\n}\n"
(非详细)错误:
Error applying plan:
1 error(s) occurred:
* module.s3-bucket.aws_s3_bucket_policy.bucket_policy: 1 error(s) occurred:
* aws_s3_bucket_policy.bucket_policy: Error putting S3 policy: MalformedPolicy: Policy has invalid action
status code: 400, request id: DCAEB510D9FE431C, host id: FwZ187PM8RKZljAZGo1578UvsgW3kwtZpaI2Mom46lu7Jr+NV9Jum8txjsfwdJw0jm9ct0awRWk=
这是它包含的内容的漂亮打印
{
"Version":"2012-10-17",
"Statement":[{
"Principal": "*",
"Action":[
"s3:GetBucketLocation",
"s3:ListAllMyBuckets"
],
"Resource":[
"arn:aws:s3:::*"
],
"Effect":"Allow"
}, {
"Principal": "*",
"Action":[
"s3:ListBucket",
"s3:ListBucketMultipartUploads"
],
"Resource":[
"arn:aws:s3:::the_s3_bucket"
],
"Effect":"Allow"
}, {
"Principal": "*",
"Action":[
"s3:GetObject",
"s3:AbortMultipartUpload",
"s3:ListMultipartUploadParts",
"s3:DeleteObject",
"s3:PutObject",
"s3:GetObjectAcl",
"s3:PutObjectAcl"
],
"Resource":[
"arn:aws:s3:::the_s3_bucket/*"
],
"Effect":"Allow"
}]
}
更新
很明显,这与该Principal
领域有关,在通过 AWS 控制台运行它后,我得到了错误
This policy contains the following error: Has prohibited field Principal For more information about the IAM policy grammar, see AWS IAM Policies