【问题标题】:give public read and view access to s3 bucket objects using cloudformation template使用 cloudformation 模板授予对 s3 存储桶对象的公共读取和查看访问权限
【发布时间】:2022-02-24 00:14:38
【问题描述】:

我正在编写一个 AWS cloudformation 模板来接收来自 Kinesis Firehose 的 s3 存储桶中的文件。我已授予对存储桶的公共读取访问权限(存储桶是公共的),但是当我使用对象 URL 访问存储桶内的文件时,我收到“XML 文件似乎没有与之关联的任何样式”错误,它说访问被拒绝.但是该对象(JSON 文件)是可下载的。

我已授予对 s3 存储桶的完全访问权限

Resources:

# Create s3 bucket
MyS3Bucket:
 Type: AWS::S3::Bucket
 Properties:
    BucketName: health-app-buckett
    AccessControl: PublicRead

# Create Role
S3BucketRole:
 Type: 'AWS::IAM::Role'
 Properties:
  AssumeRolePolicyDocument:
    Statement:
      - Effect: Allow
        Principal:
          Service:
            - s3.amazonaws.com
        Action:
          - 'sts:AssumeRole'

#Create policy for bucket
S3BucketPolicies:
 Type: 'AWS::IAM::Policy'
 Properties:
  PolicyName: S3BucketPolicy
  PolicyDocument:
    Statement:
      - Sid: PublicReadForGetBucketObjects
        Effect: Allow
        Action: 's3:GetObject'
        Resource: !Join
          - ''
          - - 'arn:aws:s3:::'
            - !Ref MyS3Bucket
            - /*
  Roles:
    - !Ref S3BucketRole

我希望能够使用对象 URL 查看文件

【问题讨论】:

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


【解决方案1】:

您需要将 PublicAccessBlockConfiguration 添加到您的模板中

MyS3Bucket:
 Type: AWS::S3::Bucket
 Properties:
    BucketName: health-app-buckett
    AccessControl: PublicRead
    PublicAccessBlockConfiguration:
            BlockPublicAcls : false
            BlockPublicPolicy : false
            IgnorePublicAcls : false
            RestrictPublicBuckets : false

【讨论】:

    猜你喜欢
    • 2020-04-22
    • 1970-01-01
    • 2016-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-31
    • 2020-08-22
    • 1970-01-01
    相关资源
    最近更新 更多