{"id":19624867,"url":"https://github.com/hungds99/aws-serverless-crud-api","last_synced_at":"2026-05-08T03:09:36.328Z","repository":{"id":205002043,"uuid":"712286140","full_name":"hungds99/aws-serverless-crud-api","owner":"hungds99","description":"⛳️ User management API deploy in AWS using Serverless architecture","archived":false,"fork":false,"pushed_at":"2023-11-02T01:16:14.000Z","size":57,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-09T12:03:01.732Z","etag":null,"topics":["aws","cdk","lambda","nodejs","serverless"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hungds99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-31T06:55:42.000Z","updated_at":"2023-11-17T01:32:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e269d00-e453-43c0-abd3-b944e192cf1d","html_url":"https://github.com/hungds99/aws-serverless-crud-api","commit_stats":null,"previous_names":["hungds99/aws-serverless-crud-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungds99%2Faws-serverless-crud-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungds99%2Faws-serverless-crud-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungds99%2Faws-serverless-crud-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungds99%2Faws-serverless-crud-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hungds99","download_url":"https://codeload.github.com/hungds99/aws-serverless-crud-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240926382,"owners_count":19879737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","cdk","lambda","nodejs","serverless"],"created_at":"2024-11-11T11:39:16.809Z","updated_at":"2026-05-08T03:09:31.283Z","avatar_url":"https://github.com/hungds99.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Simple CRUD API using CDK TypeScript\n\n![Screenshot 2023-10-30 at 15 39 51](https://github.com/hungds99/aws-serverless-crud-api/assets/34293141/7a09e4b3-f9f6-4c29-81ef-861d680dd9a2)\n\nYou should explore the contents of this project. It demonstrates a CDK app with stacks:\n  - `dynamodbCdkStack`: Build dynamodb table\n  - `lambdaCdkStack`: Build lambda function\n  - `apiCdkStack`: Build api gateway\n\nThe `cdk.json` file tells the CDK Toolkit how to execute your app.\n\n## Prerequisites\n* Node.js\n* AWS CLI\n* AWS CDK\n* AWS Account\n\n## How to run\n - Clone this repository\n - Run the following commands:\n   - `cd aws-serverless-crud-api`\n   - `npm install`\n   - Configure your AWS credentials\n   - Copy `.env.example` to `.env` and update the values\n   - `cdk deploy --all` -\u003e Deploy all stacks\n   - Play with the API\n   - `cdk destroy --all` -\u003e Destroy all stacks\n\n## APIs\n* `GET /api/users`: Get all users\n* `GET /api/users/{id}`: Get user by id\n* `POST /api/users`: Create new user\n* `DELETE /api/users/{id}`: Delete user by id\n* `PUT /api/users/{id}`: Update user by id\n\n## How to create an API\n\n### Step 1: Create a table in DynamoDB\n```typescript\nconst usersTable = new Table(this, 'usersTable', {\n  tableName: TableNames.USERS,\n  partitionKey: { name: 'id', type: AttributeType.STRING },\n  billingMode: BillingMode.PAY_PER_REQUEST\n});\n```\n\n### Step 2: Create a lambda function\n- Add a lambda handler in `src/handlers/user.ts`\n```typescript\nexport const createUser = async (event: any): Promise\u003cany\u003e =\u003e {\n  const user = await userService.save(JSON.parse(event.body));\n  return { statusCode: 201, body: JSON.stringify(user) };\n};\n```\n- Define a lambda function\n```typescript\nconst createUserFn = new NodejsFunction(this, 'createUserFn', {\n  functionName: 'createUserFn',\n  description: 'Create user',\n  entry: 'src/handlers/user.ts',\n  handler: 'createUser',\n});\n```\n- Grant permission to access DynamoDB\n```typescript\nusersTable.grantReadWriteData(createUserFn);\n```\n\n### Step 3: Create an API Gateway\n```typescript\nconst restApi = new RestApi(this, 'userManagementRestApi', {\n  restApiName: 'User Management API',\n  description: 'User management REST API',\n});\n```\n\n### Step 4: Create resources and methods with Lambda integration\n```typescript\nconst users = apiRoot.addResource('users');\nconst createUserIntegration = new LambdaIntegration(createUserFn);\nusers.addMethod('POST', createUserIntegration);\n```\n\n## Useful commands\n\n* `npm run build`   compile typescript to js\n* `npm run watch`   watch for changes and compile\n* `npm run test`    perform the jest unit tests\n* `cdk deploy`      deploy this stack to your default AWS account/region\n* `cdk diff`        compare deployed stack with current state\n* `cdk synth`       emits the synthesized CloudFormation template\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungds99%2Faws-serverless-crud-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhungds99%2Faws-serverless-crud-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungds99%2Faws-serverless-crud-api/lists"}