amazon-web-services - 在 CloudFormation 中检测到存储桶的 S3 存储桶策略不正确

标签 amazon-web-services amazon-s3 aws-cloudformation

我在通过 Cloudformation 实现 CloudTrail 时遇到问题,当我尝试启动模型时,检测到错误的 S3 存储桶策略,引发存储桶错误。

这是 BucketPolicy 的配置:

"LogBucketPolicy": {
        "Type": "AWS::S3::BucketPolicy",
        "Properties": {
            "Bucket": {
                "Ref": "LogBucket"
            },
            "PolicyDocument": {
                "Version": "2012-10-17",
                "Statement": [
                    {
                        "Sid": "AWSCloudTrailAclCheck",
                        "Effect": "Allow",
                        "Principal": {
                            "Service": "cloudtrail.amazonaws.com"
                        },
                        "Action": "s3:GetBucketAcl",
                        "Resource": {
                            "Fn::Join": [
                                "",
                                [
                                    "arn:aws:s3:::",
                                    {
                                        "Ref": "LogBucket"
                                    }
                                ]
                            ]
                        }
                    },
                    {
                        "Sid": "AWSCloudTrailWrite",
                        "Effect": "Allow",
                        "Principal": {
                            "Service": "cloudtrail.amazonaws.com"
                        },
                        "Action": "s3:PutObject",
                        "Resource": {
                            "Fn::Join": [
                                "",
                                [
                                    "arn:aws:s3:::",
                                    {
                                        "Ref": "LogBucket"
                                    },
                                    "/AWSLogs/139339407673/*"
                                ]
                            ]
                        },
                        "Condition": {
                            "StringEquals": {
                                "s3:x-amz-acl": "bucket-owner-full-control"
                            }
                        }
                    }
                ]
            }
        }
    }

我已从 AWS 示例中复制了模板,但如果我在实现过程中犯了错误,请告诉我。

编辑:该错误不是由存储桶策略引发的,而是由 CloudTrail 引发的。这是存储桶的配置:

"Trail": {
        "Type": "AWS::CloudTrail::Trail",
        "Properties": {
            "SnsTopicName": {
                "Fn::GetAtt": [
                    "Topic",
                    "TopicName"
                ]
            },
            "IsLogging": true,
            "S3BucketName": {
                "Ref": "LogBucket"
            }
        },
        "DependsOn": [
            "LogBucket"
        ]
    }

最佳答案

正如 Krishna 所提到的,错误来自于我没有放置 BucketPolicy 的依赖项。完成此操作后,堆栈就已部署,没有任何问题。

关于amazon-web-services - 在 CloudFormation 中检测到存储桶的 S3 存储桶策略不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49135099/

相关文章:

amazon-web-services - 如何获取 AWS::ApiGateway::Method 的 arn

bash - AWS CloudFormation 模板不接受 bash 脚本

python - 将 Glue Connection 资源的值传递给 Python Job

amazon-web-services - AWS IAM : Allow EC2 instance to stop itself

php - S3 上传后如何返回 Cloudfront url?

bash - 调试我的 cron 应用程序

amazon-web-services - AWS S3 存储桶策略编辑器访问被拒绝

amazon-web-services - AWS Secret Manager 访问拒绝问题

java.io.IOException : Attempted read on closed stream on aws s3 bucket

amazon-web-services - 如何在一个区域的 3 个不同可用区启动三个相同的 EC2 实例而不使用自动扩展