2017-10-19 22 views
1

J'ai ce compartiment S3 et cette stratégie que je déploie sur CloudFormation.Stratégie de compartiment Cloudformation - "L'élément requis manquant dans l'instruction"

Resources: 
    ReportsBucket: 
    Type: AWS::S3::Bucket 

    BucketPolicy: 
    Type: AWS::S3::BucketPolicy 
    Properties: 
     Bucket: !Ref ReportsBucket 
     PolicyDocument: 
     Id: ReportPolicy 
     Version: "2012-10-17" 
     Statement: 
      - Sid: ReportBucketPolicyDoc 
      Effect: Allow 
      Action: "s3:*" 
      Principal: 
       AWS: !Join ['', ["arn:aws:iam::", !Ref "AWS::AccountId", ":root"]] 
      Resource: !Join ['', ['arn:aws:s3:::', !Ref S3Bucket, '/*']] 

Il échoue avec,

UPDATE_ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack {my stack name} The following resource(s) failed to create: [BucketPolicy]. 
CREATE_FAILED AWS::S3::BucketPolicy BucketPolicy Statement is missing required element 

Quel est le problème avec ma politique?

Répondre

2

Il a deux problèmes:

  • manquant AWSTemplateFormatVersion sur la première ligne (l'élément nécessaire)
  • de référence à S3Bucket qui devrait être ReportsBucket

Version mise à jour:

AWSTemplateFormatVersion: 2010-09-09 
Resources: 
    ReportsBucket: 
    Type: AWS::S3::Bucket 

    BucketPolicy: 
    Type: AWS::S3::BucketPolicy 
    Properties: 
     Bucket: !Ref ReportsBucket 
     PolicyDocument: 
     Id: ReportPolicy 
     Version: "2012-10-17" 
     Statement: 
      - Sid: ReportBucketPolicyDoc 
      Effect: Allow 
      Action: "s3:*" 
      Principal: 
       AWS: !Join ['', ["arn:aws:iam::", !Ref "AWS::AccountId", ":root"]] 
      Resource: !Join ['', ['arn:aws:s3:::', !Ref ReportsBucket, '/*']]