# hkb-pipeline-network

Network deploy action role (DQ-110). Makes change sets on the hkb-vpc, hkb-image and hkb-network stacks and passes hkb-pipeline-cfn-network. Changes nothing itself.

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

## Trust policy

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

## Permissions

```yaml
Policies:
  - PolicyName: hkb-pipeline-network
    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-vpc/*
            - !Sub arn:${AWS::Partition}:cloudformation:*:${AWS::AccountId}:stack/hkb-image/*
            - !Sub arn:${AWS::Partition}:cloudformation:*:${AWS::AccountId}:stack/hkb-network/*
        - Sid: ValidateTemplates
          Effect: Allow
          Action: cloudformation:ValidateTemplate
          Resource: "*"
        - Sid: PassOnlyItsCloudFormationRole
          Effect: Allow
          Action: iam:PassRole
          Resource: !GetAtt NetworkCfnRole.Arn
          Condition:
            StringEquals:
              iam:PassedToService: cloudformation.amazonaws.com
        - 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
```
