-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from reapit/feat/userpool-domain-crw-docs
add docs
- Loading branch information
Showing
4 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# @reapit-cdk/custom-resource-wrapper | ||
|
||
This module helps write custom resource handlers. It's designed to work with the [Custom Resource Provider Framework](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CustomResource.html). | ||
|
||
It accepts an object which contains event handlers for `onCreate`, and optionally, `onUpdate`, and `onDelete`. | ||
Anything returned from `onCreate` and `onUpdate` is returned as data attributes on the resulting custom resource. | ||
|
||
## npm Package Installation: | ||
```sh | ||
yarn add @reapit-cdk/custom-resource-wrapper | ||
# or | ||
npm install @reapit-cdk/custom-resource-wrapper | ||
``` | ||
|
||
## Usage | ||
```ts | ||
import { customResourceWrapper } from '@reapit-cdk/custom-resource-wrapper' | ||
|
||
export const onEvent = customResourceWrapper({ | ||
onCreate: async ({ aProperty }) => { | ||
const { aDataAttribute } = await createThing(aProperty) | ||
return { | ||
aDataAttribute, | ||
} | ||
}, | ||
onUpdate: async ({ aProperty }, oldProps) => { | ||
if (aProperty !== oldProps.aProperty) { | ||
await deleteThing(oldProps.aProperty) | ||
const { aDataAttribute } = await createThing(aProperty) | ||
return { | ||
aDataAttribute, | ||
} | ||
} | ||
}, | ||
onDelete: async ({ aProperty }) => { | ||
await deleteThing(aProperty) | ||
}, | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# @reapit-cdk/userpool-domain | ||
|
||
This construct returns the given Cognito UserPool's UserPoolDomain, or creates one. | ||
This resolves an issue with [AWS::Cognito::UserPoolDomain](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpooldomain.html), since that will fail if one already exists. | ||
|
||
## npm Package Installation: | ||
```sh | ||
yarn add --dev @reapit-cdk/userpool-domain | ||
# or | ||
npm install @reapit-cdk/userpool-domain --save-dev | ||
``` | ||
|
||
## Usage | ||
```ts | ||
import { CfnOutput, Stack, App } from 'aws-cdk-lib' | ||
import { UserPool } from 'aws-cdk-lib/aws-cognito' | ||
import { UserPoolDomain } from '@reapit-cdk/userpool-domain' | ||
|
||
const app = new App() | ||
const stack = new Stack(app, 'stack-name') | ||
const userPool = UserPool.fromUserPoolId(stack, 'userpool', userPoolId) | ||
const userPoolDomain = new UserPoolDomain(stack, 'domain', { userPool }) | ||
new CfnOutput(stack, 'userPoolDomain', { | ||
value: userPoolDomain.domain, | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters