An open API service indexing awesome lists of open source software.

https://github.com/willdady/cdk-aws-app-runner-scheduler

A CDK app for scheduled pausing of AWS App Runner services
https://github.com/willdady/cdk-aws-app-runner-scheduler

app-runner aws cdk typescript

Last synced: about 2 months ago
JSON representation

A CDK app for scheduled pausing of AWS App Runner services

Awesome Lists containing this project

README

        

# CDK AWS App Runner Scheduler

A reference AWS CDK application for scheduling the pausing and resuming of AWS App Runner services.
Useful for dev environments where you want to pause AWS App Runner services out-of-hours to save money.

![](images/app-runner-scheduler.drawio.png)

## Setup

Install dependencies.
Requires Node.js >= v16

```
npm install
```

## Deployment

```
npm run cdk -- deploy AwsAppRunnerScheduler
```

## Usage

This project defines `AwsAppRunnerScheduler`, a custom CDK construct which pauses/resumes any AWS App Runner services matching the provided tag on the provided schedule.

For example, the following will pause ALL AWS App Runner services tagged with key `environment` and value `development` at 02:00 UTC and resume the service at 21:00 UTC daily.

```typescript
new AwsAppRunnerScheduler(this, 'ExampleScheduler', {
serviceTag: {
key: 'environment',
value: 'development',
},
pauseCronOptions: {
hour: '2',
minute: '0',
},
resumeCronOptions: {
hour: '21',
minute: '0',
},
});
```

Note, cron options are in **UTC time** *not* your local time.
Also, `serviceTag.key` and `serviceTag.value` are **case-sensitive**.

### SNS

You may also optionally provide `snsTopic` to the `AwsAppRunnerScheduler` constructor to be notified when a service is paused and resumed.

```typescript
const mySnsTopic = new sns.Topic(this, 'MySnsTopic');

new AwsAppRunnerScheduler(this, 'ExampleScheduler', {
...,
snsTopic: mySnsTopic,
});
```