maestro
maestro

Reputation: 1

Incorrect S3 bucket policy is detected for bucket at Cloud Trail

Receveing this error Incorrect S3 bucket policy is detected for bucket:

(Service: AWSCloudTrail; Status Code: 400; Error Code: InsufficientS3BucketPolicyException; Request ID: ebaf35b8-a38e-4357-a742-af5fa92bbc43)

Parameters:
    trailname:
      Type: String
    s3bucketname:
      Type: String
Resources:
    myvpctrail:
      DependsOn:
        - s3bucketpolicy
        - creates3bucket
      Type: AWS::CloudTrail::Trail
      Properties:
        IsLogging: true
        IsMultiRegionTrail: true
        IncludeGlobalServiceEvents: true
        S3BucketName: !Ref creates3bucket
    creates3bucket:
      Type: AWS::S3::Bucket
      Properties: 
        BucketName: !Sub ${s3bucketname}
    s3bucketpolicy:
      Type: AWS::S3::BucketPolicy
      Properties:
        Bucket: !Sub ${s3bucketname}
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
            - Sid: 'AWSCloudTrailAclCheck20150319'
              Effect: 'Allow'
              Principal: 
                  Service: 'cloudtrail.amazonaws.com'
              Action: 's3:GetBucketAcl'
              Resource: 
                !Sub 'arn:aws:s3:::${s3bucketname}'
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
            - Sid: AWSCloudTrailWrite20150319
              Effect: 'Allow'
              Principal: 
                  Service: 'cloudtrail.amazonaws.com'
              Action: 's3:PutObject'
              Resource: 
                !Sub 'arn:aws:s3:::${s3bucketname}/AWSLogs/${AWS::AccountId}/*'
              Condition:
                StringEquals: 
                    s3:x-amz-acl: 'bucket-owner-full-control'

Incorrect S3 bucket policy is detected for bucket: (Service: AWSCloudTrail; Status Code: 400; Error Code: InsufficientS3BucketPolicyException; Request ID: ebaf35b8-a38e-4357-a742-af5fa92bbc43)enter code here

Upvotes: 0

Views: 2615

Answers (2)

John Rotenstein
John Rotenstein

Reputation: 269340

The problem lies with these lines:

          Statement:
            - Sid: 'AWSCloudTrailAclCheck20150319'

should be:

          Statement:
            - 
              Sid: 'AWSCloudTrailAclCheck20150319'

And:

          Statement:
            - Sid: AWSCloudTrailWrite20150319

should be:

          Statement:
            - 
              Sid: AWSCloudTrailWrite20150319

This is because they are dictionary values, not a list.

Upvotes: 0

lexicore
lexicore

Reputation: 43661

You should be extremely careful with indentation and property names in YAML. I believe the problem is in Condition which should be something like:

        Condition:
          StringEquals:
            's3:x-amz-acl': bucket-owner-full-control

Compare this to your:

      Condition:
        StringEquals: 
            s3:x-amz-acl: 'bucket-owner-full-control'

Upvotes: 1

Related Questions