# hkb-pipeline-site

Site deploy action role. Makes change sets on the hkb-site and hkb-dns stacks and passes hkb-pipeline-cfn-site. Content goes through hkb-pipeline-site-sync.

- **Lives in:** [Sandbox](/architecture/sandbox/), [Dev](/architecture/dev/), [Prod](/architecture/prod/). **Trusted by:** `hkb-pipeline-site-orchestrator`.
- **Boundary:** `hkb-pipeline-boundary`.
- **Reach:** 17 named actions across 5 services (cloudformation, iam, kms, s3, ssm); 1 statement on all resources.
- **Source:** `baseline/hkb-baseline-iam.yaml`, resource `SiteDeployRole`.

## Trust policy

```yaml
AssumeRolePolicyDocument:
  Version: "2012-10-17"
  Statement:
    # Only hkb-pipeline-site-orchestrator, which runs hkb-pipeline-site (step 3.14, DQ-82, DQ-103).
    - Effect: Allow
      Principal:
        AWS: !Sub arn:${AWS::Partition}:iam::${SharedServicesAccountId}:role/hkb-pipeline-site-orchestrator
      Action: sts:AssumeRole
```

## Permissions

```yaml
Policies:
  - PolicyName: hkb-pipeline-site
    PolicyDocument:
      Version: "2012-10-17"
      Statement:
        - Sid: ChangeSets
          Effect: Allow
          Action:
            - cloudformation:CreateChangeSet
            - cloudformation:DescribeChangeSet
            - cloudformation:ExecuteChangeSet
            - cloudformation:DeleteChangeSet
            - cloudformation:DescribeStacks
            - cloudformation:DescribeStackEvents
            - cloudformation:GetTemplate
            - cloudformation:GetTemplateSummary
            - cloudformation:TagResource
          Resource:
            - !Sub arn:${AWS::Partition}:cloudformation:*:${AWS::AccountId}:stack/hkb-site/*
            - !Sub arn:${AWS::Partition}:cloudformation:*:${AWS::AccountId}:stack/hkb-dns/*
        - Sid: ValidateTemplates
          Effect: Allow
          Action: cloudformation:ValidateTemplate
          Resource: "*"
        - Sid: PassOnlyItsCloudFormationRole
          Effect: Allow
          Action: iam:PassRole
          Resource: !GetAtt SiteCfnRole.Arn
          Condition:
            StringEquals:
              iam:PassedToService: cloudformation.amazonaws.com
        # The Log Archive account ID (catalog, DQ-81) reaches hkb-site as an SSM-typed
        # parameter for Prod's access-log delivery (DQ-132).
        - Sid: ResolveCatalogParameters
          Effect: Allow
          Action: ssm:GetParameters
          Resource: !Sub arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/hkb/aws/*
        - Sid: ReadPipelineArtifacts
          Effect: Allow
          Action:
            - s3:GetObject
            - s3:GetObjectVersion
          Resource: !Sub arn:${AWS::Partition}:s3:::hkb-pipeline-artifacts-${SharedServicesAccountId}/*
        - Sid: PipelineArtifactKey
          Effect: Allow
          Action:
            - kms:Decrypt
            - kms:DescribeKey
            - kms:GenerateDataKey
          Resource: !Ref ArtifactKeyArn
```
