# hkb-pipeline-validate

CodeBuild role for the Validate stage. Reads artifacts and validates policies. Cannot assume any deployer role.

- **Lives in:** [Shared Services](/architecture/shared-services/). **Trusted by:** `codebuild.amazonaws.com`.
- **Boundary:** `hkb-pipeline-boundary`.
- **Reach:** 12 named actions across 4 services (access-analyzer, kms, logs, s3); 1 statement on all resources.
- **Source:** `pipeline/hkb-pipeline-foundation.yaml`, resource `ValidateRole`.

## 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-validate
    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: Artifacts
          Effect: Allow
          Action:
            - s3:GetObject
            - s3:GetObjectVersion
            - s3:PutObject
            - s3:GetBucketLocation
          Resource: !Sub ${ArtifactBucket.Arn}/*
        - Sid: ArtifactKey
          Effect: Allow
          Action:
            - kms:Decrypt
            - kms:Encrypt
            - kms:GenerateDataKey*
            - kms:DescribeKey
          Resource: !GetAtt PipelineKey.Arn
        - Sid: ValidatePolicies
          Effect: Allow
          Action: access-analyzer:ValidatePolicy
          Resource: "*"
```
