# hkb-pipeline-sync

CodeBuild role for the site sync (step 4.4, DQ-59). Reads the built site artifact and assumes hkb-pipeline-site-sync in Sandbox, Dev and Prod. Changes nothing in this account.

- **Lives in:** [Shared Services](/architecture/shared-services/). **Trusted by:** `codebuild.amazonaws.com`.
- **Boundary:** `hkb-pipeline-boundary`.
- **Reach:** 8 named actions across 4 services (kms, logs, s3, sts); 0 statements on all resources.
- **Source:** `pipeline/hkb-pipeline-foundation.yaml`, resource `SyncRole`.

## Trust policy

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

## Permissions

```yaml
Policies:
  - PolicyName: hkb-pipeline-sync
    PolicyDocument:
      Version: "2012-10-17"
      Statement:
        - Sid: Logs
          Effect: Allow
          Action:
            - logs:CreateLogGroup
            - logs:CreateLogStream
            - logs:PutLogEvents
          Resource: !Sub arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/hkb-pipeline-*
        - Sid: ReadSiteArtifact
          Effect: Allow
          Action:
            - s3:GetObject
            - s3:GetObjectVersion
          Resource: !Sub ${ArtifactBucket.Arn}/*
        - Sid: ArtifactKey
          Effect: Allow
          Action:
            - kms:Decrypt
            - kms:DescribeKey
          Resource: !GetAtt PipelineKey.Arn
        - Sid: AssumeSiteSyncRoles
          Effect: Allow
          Action: sts:AssumeRole
          Resource:
            - !Sub arn:${AWS::Partition}:iam::${SandboxAccountId}:role/hkb-pipeline-site-sync
            - !Sub arn:${AWS::Partition}:iam::${DevAccountId}:role/hkb-pipeline-site-sync
            - !Sub arn:${AWS::Partition}:iam::${ProdAccountId}:role/hkb-pipeline-site-sync
```
