Skip to content

Commit

Permalink
fix: add api key id output
Browse files Browse the repository at this point in the history
  • Loading branch information
Slavo Vojacek committed Mar 14, 2022
1 parent 8efd2ea commit 1785eac
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

Initialise a new CDK app if you don't already have one:

```
```sh
mkdir dev; cd dev
cdk init app --language typescript
npx cdk bootstrap --profile dev
```

Make sure you're authenticated with the GitHub registry (GitHub PAT with `registry:read` access is enough):

```
```sh
npm config set @sniptt-official:registry https://npm.pkg.github.com
npm config set -- '//npm.pkg.github.com/:_authToken' $GITHUB_TOKEN
```

Install the `ots-aws` construct:

```
```sh
npm i @sniptt-official/ots-aws
```

Expand All @@ -32,43 +32,46 @@ export class DevStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

const ots = new Ots(this, 'Ots');
// When you run `ots new` the resulting "View URL" will be composed
// using this value. For example:
//
// https://my-ots-web-view.com/burn-secret?id=xxx#xxx
//
// Make sure this web view implements client-side decryption of the secret.
const webViewUrl = 'https://my-ots-web-view.com/burn-secret';
const ots = new Ots(this, 'Ots', { webViewUrl });
}
}
```

Deploy:

```
```sh
npx cdk deploy DevStack --profile dev
```

Grab your API Gateway URL, API key and test:
Grab your new API Gateway URL, API key and configure your local `~/.ots.yaml` config:

```
curl ...
```yaml
apiUrl: https://YOUR_API_ID.execute-api.YOUR_REGION.amazonaws.com/prod/secrets
apiKey: YOUR_API_KEY
```
## Contributing
### Build
### The Construct package
```
npm ci
npm run build
```

### Test

#### The Construct package

```
npm test
```

#### The Lambda functions package
### The Lambda functions package

```
cd lambda-functions
npm ci
npm run build
npm test
```
8 changes: 7 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { aws_apigateway, aws_dynamodb, aws_lambda } from 'aws-cdk-lib';
import { CfnOutput, type aws_apigateway, type aws_dynamodb, type aws_lambda } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { URL } from 'url';

Expand Down Expand Up @@ -54,5 +54,11 @@ export class Ots extends Construct {
webViewUrl: new URL(webViewUrl),
functionProps
});

// Useful outputs
new CfnOutput(this, 'RateLimitedApiKeyId', {
value: this.rateLimitedApiKey.keyId,
description: 'The id of the Api Key used for rate-limiting'
});
}
}

0 comments on commit 1785eac

Please sign in to comment.