# hkb-log-archive-replication

S3 replication from the Control Tower trail bucket to the Object Lock replica (D72).

- **Lives in:** [Log Archive](/architecture/log-archive/). **Trusted by:** `s3.amazonaws.com`.
- **Boundary:** `hkb-workload-boundary`.
- **Reach:** 18 named actions across 2 services (kms, s3); 0 statements on all resources.
- **Source:** `security/hkb-log-archive-protection.yaml`, resource `ReplicationRole`.

## Trust policy

```yaml
AssumeRolePolicyDocument:
  Version: "2012-10-17"
  Statement:
    - Effect: Allow
      Principal:
        Service: s3.amazonaws.com
      Action: sts:AssumeRole
      Condition:
        StringEquals:
          aws:SourceAccount: !Ref AWS::AccountId
```

## Permissions

```yaml
Policies:
  - PolicyName: hkb-log-archive-replication
    PolicyDocument:
      Version: "2012-10-17"
      Statement:
        - Sid: SourceBucket
          Effect: Allow
          Action:
            - s3:GetReplicationConfiguration
            - s3:ListBucket
            - s3:GetBucketLocation
          Resource: !Sub arn:${AWS::Partition}:s3:::${ControlTowerBucket}
        - Sid: SourceObjects
          Effect: Allow
          Action:
            - s3:GetObjectVersionForReplication
            - s3:GetObjectVersionAcl
            - s3:GetObjectVersionTagging
            - s3:GetObjectRetention
            - s3:GetObjectLegalHold
            - s3:GetObject
            - s3:GetObjectVersion
            - s3:GetObjectTagging
          Resource: !Sub arn:${AWS::Partition}:s3:::${ControlTowerBucket}/*
        - Sid: ReplicaObjects
          Effect: Allow
          Action:
            - s3:ReplicateObject
            - s3:ReplicateTags
            - s3:PutObject
            - s3:PutObjectTagging
          Resource: !Sub ${ReplicaBucket.Arn}/*
        - Sid: ReplicaBucket
          Effect: Allow
          Action:
            - s3:ListBucket
            - s3:GetBucketLocation
          Resource: !GetAtt ReplicaBucket.Arn
        - Sid: DecryptSourceThroughS3
          Effect: Allow
          Action: kms:Decrypt
          Resource: !Ref ControlTowerKeyArn
          Condition:
            StringEquals:
              kms:ViaService: !Sub s3.${AWS::Region}.amazonaws.com
        - Sid: EncryptReplica
          Effect: Allow
          Action:
            - kms:Encrypt
            - kms:Decrypt
            - kms:GenerateDataKey
          Resource: !GetAtt ReplicaKey.Arn
```
