https://github.com/heiwa4126/sam-auth-coguserpool
Cognito Authorizerのサンプル
https://github.com/heiwa4126/sam-auth-coguserpool
aws-lambda cognito example sam
Last synced: 12 months ago
JSON representation
Cognito Authorizerのサンプル
- Host: GitHub
- URL: https://github.com/heiwa4126/sam-auth-coguserpool
- Owner: heiwa4126
- Created: 2022-01-04T08:07:20.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-04T08:08:08.000Z (about 4 years ago)
- Last Synced: 2025-01-04T16:18:51.323Z (about 1 year ago)
- Topics: aws-lambda, cognito, example, sam
- Language: Shell
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sam-auth-coguserpool
Cognitoのuser poolでLambdaの認証を行うサンプル。
一般的な Amazon Cognito シナリオ
の
[ユーザープールと共に API Gateway と Lambda を使用してリソースにアクセスする](https://docs.aws.amazon.com/ja_jp/cognito/latest/developerguide/cognito-scenarios.html#scenario-api-gateway)
に相当する。
# デプロイ
## リソースのデプロイ
SAMなので
```sh
sam build
sam deploy --guided # --guidedは最初の1回
```
## ユーザの作成
```sh
cp user_template.sh user.sh
vim user.sh
```
でユーザ名(emailアドレス)とパスワード、名前と苗字を編集する。
```sh
./create_and_conferm_a_user.sh
```
を実行すると、ユーザ名(emailアドレス)に
`Your verification code` という題名の
> Your confirmation code is 123456
のようなメールが届くので、この6桁のコードを
> Check the mailbox and Enter verification code:
のプロンプトのところへコピペしてEnter。これでユーザプールに認証済みのユーザができる。
# テスト
## 失敗するテスト
認証無しでlambdaを呼び出す。
```sh
./call_lambda_without_auth.sh
```
## 認証付きテスト
ID Tokenを使ってlambdaを呼び出す。
```sh
./call_lambda.sh
```
# 削除
```sh
sam delete
```