# hkb-pipeline-self

Self-update action role. Makes change sets on the hkb-pipeline stack and passes hkb-pipeline-cfn-self to CloudFormation. Changes nothing itself.

- **Lives in:** [Shared Services](/architecture/shared-services/). **Trusted by:** `hkb-pipeline-orchestrator`.
- **Boundary:** `hkb-pipeline-boundary`.
- **Reach:** 16 named actions across 5 services (cloudformation, iam, kms, s3, ssm); 1 statement on all resources.
- **Source:** `pipeline/hkb-pipeline-foundation.yaml`, resource `SelfRole`.

## Trust policy

```yaml
AssumeRolePolicyDocument:
  Version: "2012-10-17"
  Statement:
    - Effect: Allow
      Principal:
        AWS: !GetAtt OrchestratorRole.Arn
      Action: sts:AssumeRole
```

## Permissions

```yaml
Policies:
  - PolicyName: hkb-pipeline-self
    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-pipeline/*
        - Sid: PassOnlyItsCloudFormationRole
          Effect: Allow
          Action: iam:PassRole
          Resource: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/hkb-pipeline-cfn-self
          Condition:
            StringEquals:
              iam:PassedToService: cloudformation.amazonaws.com
        - Sid: ValidateTemplates
          Effect: Allow
          Action: cloudformation:ValidateTemplate
          Resource: "*"
        - Sid: ReadTemplateArtifact
          Effect: Allow
          Action:
            - s3:GetObject
            - s3:GetObjectVersion
          Resource: !Sub ${ArtifactBucket.Arn}/*
        - Sid: ArtifactKey
          Effect: Allow
          Action:
            - kms:Decrypt
            - kms:DescribeKey
          Resource: !GetAtt PipelineKey.Arn
        - Sid: ResolveIdParameters
          Effect: Allow
          Action: ssm:GetParameters
          Resource: !Sub arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/hkb/aws/*
```
