CloudFormationの「バケットは ObjectOwnership の BucketOwnerEnforced 設定で ACL を設定できません」というエラーを修正する方法を教えてください。

所要時間1分
0

AWS CloudFormation スタックを通じて Amazon Simple Storage Service (Amazon S3) バケットをデプロイしようとすると、エラーが表示されます。

簡単な説明

新しく作成されたバケットの場合、Amazon S3 は ObjectOwnership を有効にし、デフォルトで BucketOwnerEnforced に設定します。この設定ではアクセスコントロールリスト (ACL) がオフになり、バケット所有者はバケット内のすべてのオブジェクトを自動的に所有し、完全に制御できるようになります。そのため、この設定で ACL を呼び出そうとするデプロイでは、次のエラーが発生します。

Bucket cannot have ACLs set with ObjectOwnership's BucketOwnerEnforced setting (Service: Amazon S3; Status Code: 400; Error Code: InvalidBucketAclWithObjectOwnership; Request ID: VCC82DDB; S3 Extended Request ID: itIVupTUTYxdhtOqXHTRxiwthYK4I/AvFqgNCWSqs8=; Proxy: null)

たとえば、次の展開テンプレートではこのエラーが発生します。

AWSTemplateFormatVersion: "2010-09-09"

Resources:
  PortalBucket:
    Type: AWS::S3::Bucket
    Properties:
      AccessControl: LogDeliveryWrite
      VersioningConfiguration:
        Status: Enabled
      WebsiteConfiguration:
        IndexDocument: 'index.html'
        ErrorDocument: 'error.html'
      BucketEncryption:
        ServerSideEncryptionConfiguration:
          - ServerSideEncryptionByDefault:
              SSEAlgorithm: AES256

この問題を解決するには、バケットの ObjectOwnership の値を変更してACLを許可するようにします。

**重要:**Amazon S3 に ACL を使用することはベストプラクティスではありません。ユースケースで ACL が必要な場合は、次のトラブルシューティング手順を参照して ACL を許可してください。

解決策

  1. ObjectOwnership の値を ObjectWriter または BucketOwnerPreferred に設定します。
  2. S3 バケットをデプロイするには、次のテンプレートを使用します。
AWSTemplateFormatVersion: "2010-09-09"

Resources:
  PortalBucket:
    Type: AWS::S3::Bucket
    Properties:
      AccessControl: LogDeliveryWrite
      VersioningConfiguration:
        Status: Enabled
      WebsiteConfiguration:
        IndexDocument: 'index.html'
        ErrorDocument: 'error.html'
      BucketEncryption:
        ServerSideEncryptionConfiguration:
          - ServerSideEncryptionByDefault:
              SSEAlgorithm: AES256
      OwnershipControls:
        Rules:
          - ObjectOwnership: ObjectWriter

これにより、バケットの ACL をアクティブ化できます。

Amazon S3 の ACL に関するデフォルトの動作の詳細については、「お知らせ: Amazon S3 のセキュリティ変更は 2023 年 4 月に予定されています」を参照してください。

AWS公式
AWS公式更新しました 10ヶ月前
コメントはありません

関連するコンテンツ