Error Message :

Variety of distinct vacation spot bucket ARNs can’t exceed 1

Drawback:

I used to be making an attempt to setup Cross Area Replication on my S3 bucket utilizing CloudFormation. I had a use-case the place, replication wanted to occur from one supply bucket to a number of vacation spot buckets.

So far as I knew, AWS supported a number of vacation spot for replication as of Dec 1, 2020 as per this announcement. Nevertheless, once I tried it, my stack creation failed.

For reference, under is the portion of my CloudFormation template, the place I’m setting two guidelines, one for every duplicate bucket-

  PrimaryBucket:
    Kind: AWS::S3::Bucket
    Properties:
      BucketName: !Ref SourceBucketName
      VersioningConfiguration:
        Standing: Enabled
      ReplicationConfiguration:
        Position: !GetAtt S3ReplicationRole.Arn
        Guidelines:
          - Id: Rule1
            Standing: Enabled
            Precedence: 1
            Vacation spot:
              Bucket: !Sub 'arn:aws:s3:::${ReplicaBucket1}'
          - Id: Rule2
            Standing: Enabled
            Precedence: 2
            Vacation spot:
              Bucket: !Sub 'arn:aws:s3:::${ReplicaBucket2}'

My Stack Failed With Under Error !!!

Variety of distinct vacation spot bucket ARNs can’t exceed 1

Number of distinct destination bucket ARNs cannot exceed 1

What is the issue with above template?

Properly, on doing little little bit of analysis I discovered, why it was not working and the way to make it work.

Let’s begin with understanding what’s flawed.

AWS S3 shops Replication configuration as XML. And the newest model of schema is V2. Though, AWS retains supporting V1 for backward compatibility.

I discovered that, to ensure that a number of locations to work, you should power ReplicationRules to make use of V2 schema.

Now, you could be questioning how do I do this –

Properly, AWS has reply to that-

Using the filter subject signifies it is a V2 replication configuration. V1 doesn’t have this subject.

Underneath the hood should you see these are the minimal required subject for a schema to be V2.

...
    <Rule>
        <ID>Rule-1</ID>
        <Standing>Enabled-or-Disabled</Standing>
        <Filter>
            <Prefix></Prefix>   
        </Filter>
        <Precedence>integer</Precedence>
        <DeleteMarkerReplication>
           <Standing>Enabled-or-Disabled</Standing>
        </DeleteMarkerReplication>
        <Vacation spot>        
           <Bucket>arn:aws:s3:::bucket-name</Bucket> 
        </Vacation spot>    
    </Rule>
    <Rule>
         ...
    </Rule>
     ...
...

Due to this fact, ideally the issue with template is we’re utilizing V1 of ReplicationRule schema and we should use V2 of schema to make issues work.

Resolution:

Resolution is strictly what are considering of.

We’ll power Replication Rule to utilize Filter component on every of the rule to make sure that it’s utilizing V2 schema.

Now as per the syntax, “In case you specify Filter components , you should additionally embody Precedence and DeleteMarkerReplication components.

Primarily based on these assumption, I edited my template like under and gave it one other strive. And, as anticipated, this labored completely positive.

AWSTemplateFormatVersion: 2010-09-09
Description: AWS CloudFormation Template to Setup S3 CRR

Parameters:
  SourceBucketName:
    Kind: String
    Description: Major Bucket Identify
    Default: cloudkatha-web-bucket-primary
  ReplicaBucket1:
    Kind: String
    Description: Reproduction Bucket 1
    Default: cloudkatha-web-bucket-replica1
  ReplicaBucket2:
    Kind: String
    Description: Reproduction Bucket 2
    Default: cloudkatha-web-bucket-replica2
Sources:
  PrimaryBucket:
    Kind: AWS::S3::Bucket
    Properties:
      BucketName: !Ref SourceBucketName
      VersioningConfiguration:
        Standing: Enabled
      ReplicationConfiguration:
        Position: !GetAtt S3ReplicationRole.Arn
        Guidelines:
          - Id: Rule1
            Standing: Enabled
            DeleteMarkerReplication:
              Standing: Enabled
            Precedence: 1
            Filter:
              Prefix: ''
            Vacation spot:
              Bucket: !Sub 'arn:aws:s3:::${ReplicaBucket1}'
          - Id: Rule2
            Standing: Enabled
            DeleteMarkerReplication:
              Standing: Enabled
            Precedence: 2
            Filter:
              Prefix: ''
            Vacation spot:
              Bucket: !Sub 'arn:aws:s3:::${ReplicaBucket2}'
  S3ReplicationRole:
    Kind: AWS::IAM::Position
    Properties:
      AssumeRolePolicyDocument:
        Assertion:
          - Motion:
              - 'sts:AssumeRole'
            Impact: Enable
            Principal:
              Service:
                - s3.amazonaws.com

  S3ReplicationPolicy:
    Kind: 'AWS::IAM::Coverage'
    Properties:
      PolicyName: S3BucketReplicationPolicy
      Roles:
        - !Ref S3ReplicationRole
      PolicyDocument:
        Assertion:
          - Motion:
              - 's3:GetReplicationConfiguration'
              - 's3:ListBucket'
            Impact: Enable
            Useful resource: !Sub 'arn:aws:s3:::${SourceBucketName}'
          - Motion:
              - 's3:GetObjectVersion'
              - 's3:GetObjectVersionAcl'
            Impact: Enable
            Useful resource: !Sub 'arn:aws:s3:::${SourceBucketName}'
          - Motion:
              - 's3:ReplicateObject'
              - 's3:ReplicateDelete'
            Impact: Enable
            Useful resource:
              - !Sub 'arn:aws:s3:::${ReplicaBucket1}'
              - !Sub 'arn:aws:s3:::${ReplicaBucket2}'

As soon as replication guidelines was created on the first bucket, that is the way it regarded like console.

Number of distinct destination bucket ARNs cannot exceed 1

Conclusion

On this fast repair publish, we learnt that once you get Variety of distinct vacation spot bucket ARNs can’t exceed 1 error whereas establishing CRR utilizing CloudFormation, it’s the schema model which is offender.

You might be required to make use of V2 of schema and you are able to do that including a Filter property on the rule.

We additionally noticed that even if you would like the rule to use on complete bucket, nonetheless you add a Filter with empty prefix which is equal to making use of on complete bucket.

I hope you have been capable of clear up this challenge. Please let me know in remark part in case you are nonetheless going through a problem.

Loved the content material?

Subscribe to our publication under to get superior AWS studying supplies delivered straight to your inbox.

Don’t overlook to inspire me by-

  • Including a remark under on what you preferred and what will be improved.
  • Observe us on
  • Share this publish with your mates

Prompt Learn:



Source_link

By admin

Leave a Reply

Your email address will not be published.