# hkb-pipeline-security

Pipeline action role in Security (DQ-74). Makes change sets on the hkb-security-events and hkb-security-tools-findings stacks and passes hkb-pipeline-cfn-security. Changes nothing itself.

- **Lives in:** [Security](/architecture/security/). **Trusted by:** `hkb-pipeline-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 `SecurityDeployRole`.

## Trust policy

```yaml
AssumeRolePolicyDocument:
  Version: "2012-10-17"
  Statement:
    - Effect: Allow
      Principal:
        AWS: !Sub arn:${AWS::Partition}:iam::${SharedServicesAccountId}:role/hkb-pipeline-orchestrator
      Action: sts:AssumeRole
```

## Permissions

```yaml
Policies:
  - PolicyName: hkb-pipeline-security
    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-security-events/*
            - !Sub arn:${AWS::Partition}:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/hkb-security-tools-findings/*
        - Sid: ValidateTemplates
          Effect: Allow
          Action: cloudformation:ValidateTemplate
          Resource: "*"
        - Sid: PassOnlyItsCloudFormationRole
          Effect: Allow
          Action: iam:PassRole
          Resource: !GetAtt SecurityCfnRole.Arn
          Condition:
            StringEquals:
              iam:PassedToService: cloudformation.amazonaws.com
        # The org ID (catalog, DQ-81) and the alert email (DQ-80) reach the template as
        # SSM-typed parameters; this role reads them when it makes the change set.
        - 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
```
