如何修正状态代码:400;错误代码:格式错误的策略

huangapple go评论144阅读模式
英文:

How to correct Status Code:400; Error code: Malformed Policy

问题

Unknown field version (Service: Amazon S3;
Status Code: 400; Error Code: MalformedPolicy;
Request ID: VKA1M3MNY37B2DGN; S3 Extended
Request ID: UItdX5yp9vy6KB19HQVjBdkW1fyGh2EvZ+47
Y1KcQ03WExKAqRVJivrw+4cQns6OXo7ax8lwO2Y=; Proxy:
null)

BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
PolicyDocument:
Id: MyPolicy
Version: '2012-10-17'
Statement:
- Sid: PublicReadForGetBucketObject
Effect: Allow
Principal: ''
Action: "s3:GetObject"
Resource: !Join
- ""
- - "arn:aws:s3:::"
- !Ref MyWebsite
- /

Bucket: !Ref MyWebsite

I receive the error message above when I deploy my bucket policy.

When I use the yaml lint site it says format is fine but when I use the CLI sam validate --lint command I get this message:

/Users/travissalmon/Desktop/Web Development/Resume Challenge/cloud-resume-challenge/template.yaml is a valid SAM Template

Not sure what to do.

英文:
Unknown field version (Service: Amazon S3;       
Status Code: 400; Error Code: MalformedPolicy;   
Request ID: VKA1M3MNY37B2DGN; S3 Extended        
Request ID: UItdX5yp9vy6KB19HQVjBdkW1fyGh2EvZ+47 
Y1KcQ03WExKAqRVJivrw+4cQns6OXo7ax8lwO2Y=; Proxy:                                                                                                                                                         null)                                     
BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
  PolicyDocument:
    Id: MyPolicy
    Version: '2012-10-17'
    Statement:
      - Sid: PublicReadForGetBucketObject
        Effect: Allow
        Principal: '*'
        Action: "s3:GetObject"
        Resource: !Join
          - ""
          - - "arn:aws:s3:::"
            - !Ref MyWebsite
            - /*
  Bucket: !Ref MyWebsite

I receive the error message above when I deploy my bucket policy.

When I use the yaml lint site it says format is fine but when I use the CLI sam validate --lint command I get this message:

>/Users/travissalmon/Desktop/Web Development/Resume Challenge/cloud-resume-challenge/template.yaml is a valid SAM Template

Not sure what to do.

答案1

得分: 1

I tried this template and it worked with no issues for me.


sam deploy -g: success

This is the script I used.

AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: Test Code

Resources:
  BucketPolicy:
    Type: AWS::S3::BucketPolicy
    Properties:
      PolicyDocument:
        Id: MyPolicy
        Version: "2012-10-17"
        Statement:
          - Sid: PublicReadForGetBucketObject
            Effect: Allow
            Principal: "*"
            Action: "s3:GetObject"
            Resource: !Join
              - ""
              - - "arn:aws:s3:::"
                - !Ref MyWebsite
                - /*
      Bucket: !Ref MyWebsite

  MyWebsite:
    Type: AWS::S3::Bucket
英文:

I tried this template and it worked with no issues for me.

sam validate: success

sam deploy -g: success

This is the script I used.

AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: Test Code

Resources:
  BucketPolicy:
    Type: AWS::S3::BucketPolicy
    Properties:
      PolicyDocument:
        Id: MyPolicy
        Version: "2012-10-17"
        Statement:
          - Sid: PublicReadForGetBucketObject
            Effect: Allow
            Principal: "*"
            Action: "s3:GetObject"
            Resource: !Join
              - ""
              - - "arn:aws:s3:::"
                - !Ref MyWebsite
                - /*
      Bucket: !Ref MyWebsite

  MyWebsite:
    Type: AWS::S3::Bucket

huangapple
  • 本文由 发表于 2023年3月7日 22:42:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75663412.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定