diff --git a/.github/workflows/semantic-release.yml b/.github/workflows/semantic-release.yml index 805c117..7d0eb45 100644 --- a/.github/workflows/semantic-release.yml +++ b/.github/workflows/semantic-release.yml @@ -29,11 +29,20 @@ jobs: node-version: '16.x' registry-url: 'https://npm.pkg.github.com' - - name: Run semantic release + - name: Build the Lambda functions package + working-directory: ./lambda-functions run: | npm ci npm run build - npx semantic-release + + - name: Build the construct package + run: | + npm ci + npm run build + cp -r lambda-functions/dist dist/constructs/lambda/assets + + - name: Run semantic release + run: npx semantic-release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 52092e9..dabf6c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,10 +25,10 @@ jobs: - name: Check format, lint and build from source run: | - npm ci --ignore-scripts + npm ci npm run format:check npm run lint:check - npx tsc + npm run build # TODO: add test step test-lambda-functions: @@ -50,8 +50,8 @@ jobs: - name: Check format, lint and build from source working-directory: ./lambda-functions run: | - npm ci --ignore-scripts + npm ci npm run format:check npm run lint:check - npx tsc + npm run build # TODO: add test step diff --git a/README.md b/README.md index 8aa3791..ab09d56 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,33 @@ 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): + +``` +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: ``` -echo '@sniptt-official:registry=https://npm.pkg.github.com' >> .npmrc npm i @sniptt-official/ots-aws ``` Add the `ots-aws` construct to your stack: -``` -# ... +```ts +import { Ots } from '@sniptt-official/ots-aws'; +import { Stack, StackProps } from 'aws-cdk-lib'; +import { Construct } from 'constructs'; + +export class DevStack extends Stack { + constructor(scope: Construct, id: string, props?: StackProps) { + super(scope, id, props); + + const ots = new Ots(this, 'Ots'); + } +} ``` Deploy: diff --git a/lib/index.ts b/lib/index.ts index db4267c..b463217 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -21,13 +21,11 @@ export class Ots extends Construct { readonly createSecretFunction: CreateSecretFunction; readonly getSecretFunction: GetSecretFunction; - constructor( - scope: Construct, - id: string, - { tableProps, restApiProps, rateLimitedApiKeyProps, functionProps }: OtsProps - ) { + constructor(scope: Construct, id: string, props: OtsProps = {}) { super(scope, id); + const { tableProps, restApiProps, rateLimitedApiKeyProps, functionProps } = props; + // Create a table for persisting secrets this.table = new Table(this, 'Table', { tableProps }); diff --git a/package.json b/package.json index 704070c..c760a94 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,7 @@ "!dist/*.tsbuildinfo" ], "scripts": { - "postinstall": "cd lambda-functions; npm ci", - "build": "tsc; cd lambda-functions; npm run build", - "postbuild": "cp -r lambda-functions/dist dist/constructs/lambda/assets", + "build": "tsc", "test": "jest", "format": "prettier --write '{.github,lib,test}/**' '*.json'", "format:check": "prettier --check '{.github,lib,test}/**' '*.json'",