# hkb-pipeline-tools

Tools pipeline action role in Security (TL.1, DQ-127). Makes change sets on the hkb-tool-* stacks and passes hkb-pipeline-cfn-tools. Changes nothing itself.

- **Lives in:** [Security](/architecture/security/). **Trusted by:** `arn:${AWS::Partition}:iam::${SharedServicesAccountId}:root`.
- **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 `ToolsDeployRole`.

## Trust policy

```yaml
AssumeRolePolicyDocument:
  Version: "2012-10-17"
  Statement:
    # Only hkb-pipeline-tools-orchestrator, which runs hkb-pipeline-tools (TL.2). Named by
    # condition: IAM refuses a role principal that does not exist yet (rebuild note 5).
    - Effect: Allow
      Principal:
        AWS: !Sub arn:${AWS::Partition}:iam::${SharedServicesAccountId}:root
      Action: sts:AssumeRole
      Condition:
        ArnEquals:
          aws:PrincipalArn: !Sub arn:${AWS::Partition}:iam::${SharedServicesAccountId}:role/hkb-pipeline-tools-orchestrator
```

## Permissions

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