https://github.com/leonelgalan/cdk-unauthenticated-demo
A `LambdaRestApi` with unauthenticated access.
https://github.com/leonelgalan/cdk-unauthenticated-demo
aws-apigateway aws-identity-pool aws-lambda aws-sdk-js aws-sdk-js-v3 cdk cdk-examples
Last synced: 9 months ago
JSON representation
A `LambdaRestApi` with unauthenticated access.
- Host: GitHub
- URL: https://github.com/leonelgalan/cdk-unauthenticated-demo
- Owner: leonelgalan
- Created: 2022-01-22T19:43:43.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-23T19:15:16.000Z (over 4 years ago)
- Last Synced: 2025-02-11T13:23:25.476Z (over 1 year ago)
- Topics: aws-apigateway, aws-identity-pool, aws-lambda, aws-sdk-js, aws-sdk-js-v3, cdk, cdk-examples
- Language: TypeScript
- Homepage:
- Size: 169 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Stack
- An _Identity Pool_ with "Allow unauthenticated identities"
- An _Unauthenticated_ role, to be assumed by unauthenticated identities.
- A `LambdaRestAPI` with a single `ANY` method on root authorized by IAM.
- A _Policy_ that allows _Unauthenticated_ to execute that single endpoint.
## Tooling
- CDK:
- [AWS CDK v2](https://docs.aws.amazon.com/cdk/v2/guide/home.html)
- Client
- [AWS SDK for JavaScript v3](https://github.com/aws/aws-sdk-js-v3):
- `GetIdCommand`
- `GetCredentialsForIdentityCommand`
- [Axios](https://github.com/axios/axios) and [aws4](https://github.com/mhart/aws4)
## Setup
```sh
npm install
cdk bootstrap
npm run deploy
npm run client
```
### Notes
- `npm run deploy` instead of `cdk deploy` to run the `"postdeploy"` script. This will read the outputs and write them into the _.env_ file.
- The **client** is a demo on how to retrieve the identity and credentials to call the API.