# hkb-net-nat-scheduler

EventBridge Scheduler. Starts and stops the NAT instance on the weekday window (D19).

- **Lives in:** [Sandbox](/architecture/sandbox/), [Dev](/architecture/dev/), [Prod](/architecture/prod/). **Trusted by:** `scheduler.amazonaws.com`.
- **Boundary:** `hkb-workload-boundary`.
- **Reach:** 3 named actions across 2 services (ec2, kms); 0 statements on all resources.
- **Source:** `network/hkb-network.yaml`, resource `SchedulerRole`.

## Trust policy

```yaml
AssumeRolePolicyDocument:
  Version: "2012-10-17"
  Statement:
    - Effect: Allow
      Principal:
        Service: scheduler.amazonaws.com
      Action: sts:AssumeRole
      Condition:
        StringEquals:
          aws:SourceAccount: !Ref AWS::AccountId
```

## Permissions

```yaml
Policies:
  - PolicyName: hkb-net-nat-scheduler
    PolicyDocument:
      Version: "2012-10-17"
      Statement:
        - Sid: StartAndStopTheNatInstance
          Effect: Allow
          Action:
            - ec2:StartInstances
            - ec2:StopInstances
          Resource: !Sub arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:instance/${NatInstance}
        # Starting an instance with an encrypted root volume makes an EBS grant.
        - Sid: EbsGrants
          Effect: Allow
          Action: kms:CreateGrant
          Resource: !Sub arn:${AWS::Partition}:kms:${AWS::Region}:${AWS::AccountId}:key/*
          Condition:
            Bool:
              kms:GrantIsForAWSResource: "true"
```
