This is NodeJs(Typescript) Digital Wallet API Project based on AWS serverless-wallet blog
Get APIs require GET method with pathParameters, while others require POST method with body. The body of the request must be a JSON object with the following attributes: "requestTime" works as idempotency key and must be specified by client side.
- /getBalance(GET):
/{accountId}
- /getTransactions(GET):
/{accountId}?afterTime={timestamp}&beforeTime={timestamp}
- /createAccount(POST):
{ "accountId": <string> }
- /deleteAccount(POST):
{ "accountId": <string> }
- /updateBalance(POST):
{ "accountId": <string>, "amount": <number>, requestTime: <ISO8601 string> }
- /transferFunds(POST):
{ "fromAccountId": <string>, "toAccountId": <string>, "amount": <number>, requestTime: <ISO8601 string> }
- /addTransaction(POST):
{ "accountId": <string>, "amount": <number>, requestTime: <ISO8601 string> }
- /closeTransaction(POST):
{ "accountId": <string>, requestTime: <ISO8601 string>, status: <string> }
The cdk.json
file tells the CDK Toolkit how to execute your app.
This project will deploy digital wallet service using serverless technologies on AWS. Including:
- REST API on API Gateway
- Lambda Functions
- QLDB Ledger
- QLDB Ledger stream and Kinesis Data Stream
- DynamoDB Table
- IAM roles
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
-
Follow instruction to set up CDK
- Install awscli via brew --> aws command failed --> Install six via brew
- Install aws-cdk
aws configure sso
cdk bootstrap aws://ACCOUNT-NUMBER/REGION
--> Error: "no credentials have been configured" --> Look into the hidden files ~/.aws/config and ~/.aws/credentials, then copy and paste the value from "Coomand line or programmatic access" popup SSO login screen. (Credential often expires hence need to update ~/.aws/credentials everytime.)
-
Folow instruction to deploy CDK
- Test deploy:
cdk init app --language typescript
,npm run build
,cdk ls
,cdk synth
,cdk deploy
- Add actual code based on AWS Sample serverless-wallet (Python)
cdk deploy
--> Error: "Ledger is not yet active" --> Deploy only creating QLDB and DynamoDB portion first, then after confirming Ledger is active, deploy all.
- Test deploy:
-
Create the QLDB table. You may use the QLDB query editor on the Amazon QLDB Console to execute these queries. The table name must match the 'qldb_table_name' parameter in config.py: --
CREATE TABLE "<qldb_table_name>"
-
Create an index on the table for the
accountId
attribute: --CREATE INDEX ON "<qldb_table_name>" (accountId)