{"id":15759468,"url":"https://github.com/tomkat-cr/chalice_crud_backend","last_synced_at":"2026-05-05T23:33:08.852Z","repository":{"id":117687831,"uuid":"527005436","full_name":"tomkat-cr/chalice_crud_backend","owner":"tomkat-cr","description":"Serverless CRUD Backend based on the AWS Chalice framework, AWS DynamDb database, and Auth0 for API security.","archived":false,"fork":false,"pushed_at":"2022-08-22T02:31:51.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T09:11:16.589Z","etag":null,"topics":["auth0","auth0-api","auth0-jwt","aws","aws-lambda","chalice","crud","crud-api","dynamodb","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomkat-cr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-20T18:14:55.000Z","updated_at":"2023-03-07T13:28:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae299ceb-660d-413d-b5fe-13447b52cbe2","html_url":"https://github.com/tomkat-cr/chalice_crud_backend","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"2c5beb648b33774b19ed7071ae893e4fa6fa7b73"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tomkat-cr/chalice_crud_backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomkat-cr%2Fchalice_crud_backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomkat-cr%2Fchalice_crud_backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomkat-cr%2Fchalice_crud_backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomkat-cr%2Fchalice_crud_backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomkat-cr","download_url":"https://codeload.github.com/tomkat-cr/chalice_crud_backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomkat-cr%2Fchalice_crud_backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32672675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["auth0","auth0-api","auth0-jwt","aws","aws-lambda","chalice","crud","crud-api","dynamodb","python"],"created_at":"2024-10-04T10:20:26.370Z","updated_at":"2026-05-05T23:33:08.837Z","avatar_url":"https://github.com/tomkat-cr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chalice CRUD Backend\n\nServerless CRUD Backend based on the AWS Chalice framework, AWS DynamDb database, and Auth0 for API security.\n\nAWS Chalice is a serverless Python framework developed by Amazon.\nIt shares so many similarities in syntax and semantics with Flask.\nLike other serverless technology, Chalice allows the developer to be able to concentrate on application development without having to deal with managing servers.\nIt uses AWS Lambda and the Amazon API Gateway.\n\n## INSTRUCTIONS\n\n## Prepare the environment\n\n### 1. Configure AWS Credentials\n\nYou need to set up your AWS credentials on the AWS CLI. This will allow you to use the Amazon API Gateway and AWS Lambda.\nIf you installed AWS CLI successfully, then you can use the command below to configure your AWS credentials:\n\n`aws configure`\n\nYou should get a prompt for the AWS Access Key ID, AWS Secret Access Key, and default region name. Supply your AWS Access keys and a chosen region. You can use any available AWS region. Finally, you can skip the default output format to use the default option: None:\n\n```\nAWS Access Key ID [None]: ****************ABCD\nAWS Secret Access Key [None]: ****************abCd\nDefault region name [None]: us-east-1\nDefault output format [None]:\n```\n\nIf you don't have AWS credentials yet, you will need to set up an IAM user in the IAM Console. Visit Creating IAM users for a guide on how to create IAM Users. Once you have created the IAM user, you can then go through the instructions for setting up the AWS Access keys.\n\nTo check whether you set up your credentials correctly, run the following command:\n\n`aws ec2 describe-regions`\n\nYou should see the list of all regions where EC2 is available.\n\n### 2. Install Project Dependencies\n\nUse the following commands to activate the Python virtual environment and install the requirements:\n\n`python3 -m venv env`\n\n`source env/bin/activate`\n\n`pip install -r requirements.txt`\n\n### 3. Database Configuration and Deployment Setup\n\nThere are 2 files inside the `chalice-api/.chalice` directory:\n\n- `dynamodb_cf_template.yaml`: It's the template that CloudFormation will use to create the database. CloudFormation is a tool for specifying the resources and dependencies for your AWS project. It also helps you set them up. The CloudFormation template, in a JSON or YAML format, contains resources that make up your stack. CloudFormation uses that template to set up and configure the resources specified in it.\n\n- `policy-dev.json`: contains the policy for reading and writing from the DynamoDB database. In that file there's the provision for your user to create log groups and log events, DynamoDB actions for reading, creating, updating, scanning, and query operations on database items, and assigning the DynamoDB table name as `my-demo-table`.\n\nTo create the stack `my-stack` on Cloudformation and the DynamoDB database, use the following command:\n\n`aws cloudformation deploy --template-file chalice-api/.chalice/dynamodb_cf_template.yaml --stack-name \"my-stack\"`\n\n### 4. Run the local server\n\nNow, you may run and test the setup on the localhost. Run the commands below:\n\n`cd chalice-api`\n\n`chalice local`\n\nYou should get a terminal output as follows:\n\n```\nServing on http://127.0.0.1:8000\nFound credentials in shared credentials file: ~/.aws/credentials\n```\n\n### 5. Test the CRUD Features\n\nThere are some pre-configured tests for [Postman](https://www.postman.com/downloads/) in the file `Chalice-CRUD-Practice.postman_collection.json` you can use to test the API.\n\n### 6. Deploy to AWS\n\nBefore you deploy your code to AWS, make sure you have the necessary permissions set for your IAM account as defined in the AWS user guide. Now, with a single command `chalice deploy`, you can deploy your Chalice application to AWS.\n\n`chalice deploy`\n\nYou should get the API URL endpoint and a Lambda ARN on your terminal, which you can use to interact with the API.\n\n```\nCreating deployment package.\nCreating IAM role: chalice-api-dev-api_handler\nCreating lambda function: chalice-api-dev\nCreating Rest API\nResources deployed:\n    - Lambda ARN: arn:aws:lambda:us-west-2:xxxxxxxxxxxx:function:chalice-api-dev\n    - Rest API URL: https://dv2zde7gnj.execute-api.us-west-2.amazonaws.com/api/\n```\n\nNow, If you look at the folder structure, you will notice a few new, automatically generated files to accommodate the deployment changes under the `.chalice` sub-folder:\n\n```\nchalice-api\n├── app.py\n├── .chalice\n|   ├── deployed\n|   ├── deployments\n│   └── config.json\n├── .gitignore\n└── requirements.txt\n```\n\n### 7. Testing the Deployed Chalice API\n\nNow, you can test the REST API URL generated by Chalice:\n\nhttp GET https://dv2zde7gnj.execute-api.us-west-2.amazonaws.com/api/\n\nThe output would look like the following:\n\n```\nHTTP/1.1 200 OK\nConnection: keep-alive\nContent-Length: 73\nContent-Type: application/json\nDate: Sun, 02 May 2021 00:32:35 GMT\nVia: 1.1 xxxxxxxxxx.cloudfront.net (CloudFront)\nX-Amz-Cf-Id: xxxxxxxxxxxxxxxx==\nX-Amz-Cf-Pop: AMS1-C1\nX-Amzn-Trace-Id: Root=1-xxxxxxxxx-xxxxxxxxxxxxxx;Sampled=0\nX-Cache: Miss from cloudfront\nx-amz-apigw-id: xxxxxxxxxxxxxx=\nx-amzn-RequestId: xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx\n\n{\n    \"data\": [\n        {\n            \"author\": \"Carlos J. Ramirez\",\n            \"id\": \"123\",\n            \"title\": \"Chalice Book\"\n        }\n    ]\n}\n```\n\nCongratulations! You have built and tested your REST API with AWS Chalice.\n\n### 8. Adding authentication | Auth0\n\nYou could add authentication and authorization features to your application by enabling Auth0 in the API.\nAuth0 enables you to authenticate your users. It also enables you to provide authorized access to the endpoints in your REST APIs.\nTo use Auth0 authentication, you need an Auth0 account. If you don't have an account yet, you can sign up for a free Auth0 account [here](https://auth0.com/signup).\n\nAfter signing up or signing in, go to your dashboard and locate the Accounts tab.\u003cbr\u003e\nSelect Create Application. Supply a name for your app and select Regular Web Applications.\u003cbr\u003e\nAfter creating the app, navigate to the Settings tab to see the parameters needed to connect your Chalice API application with Auth0.\n\nTo enable Auth0 in the API, create a `.env` file by copying the `.env.example` file and add the values for the Auth0 parameters:\n\n`cp .env.example .env`\n\n```\n# .env\n\nAUTH0_ENABLED=1\n\nAUTH0_MAPI_CLIENT_ID=XXXXXX\nAUTH0_MAPI_CLIENT_SECRET=XXXXXX\nAUTH0_MAPI_API_TOKEN=XXXXXX\n\nAUTH0_CLIENT_ID=XXXXXX\nAUTH0_CLIENT_SECRET=XXXXXX\nAUTH0_DOMAIN=XXX\n\nAUTH0_API_AUDIENCE=https://XXXXXX/\nAUTH0_ALGORITHMS=RS256\n```\n\nTo set the AUTH0_DOMAIN, AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET environment variables in the `.env` file:\n\n* Go to the Auth0 dashboard, then go to option `Applications \u003e Applications` and click on your App.\nCopy the values for `Domain`, `Client ID`, and `Client Secret` and paste them into the corresponding variables.\n\nTo get valid tokens, the AUTH0_MAPI_CLIENT_ID and AUTH0_MAPI_CLIENT_SECRET, and AUTH0_MAPI_API_TOKEN environment variables must be set.\n\n- Go to the Auth0 dashboard, then go to option `Applications \u003e API \u003e Auth0 Management API \u003e Test`. Copy the `client_id` and `client_secret` parameter values on the API calls and paste them into the corresponding `AUTH0_MAPI_*` variables.\n\n- Go to the Auth0 dashboard, then go to option `Applications \u003e API \u003e Auth0 Management API \u003e API Explorer`. Enable the option and copy the `Token` parameter value and paste it in the `AUTH0_MAPI_CLIENT_SECRET` variable.\n\nNow, all the calls to the API must include an `Authorization` header of type `Bearer Token` with an Auth0 valid token.\n\nTherefore, if a user is not signed in, Auth0 cannot have Access tokens that enable Auth0 to verify the user. So, they can't use those endpoints protected by the @requires_auth decorator.\n\nTo get a valid token, make a call to `http://127.0.0.1/login` endpoint on your Chalice app.\n\nIt will return something like this:\n\n```\n{\n    \"access_token\": \"eyJhbGciOiJ...\",\n    \"scope\": \"read:client_grants create:client_grants...\",\n    \"expires_in\": 86400,\n    \"token_type\": \"Bearer\"\n}\n```\n\nCopy the value of the `access_token` element and paste it into the Authorization header token on all the API calls.\n\n### 9. Cleaning up the AWS resources created\n\nIf you would like to delete your application, you can use the following command:\n\n`chalice delete`\n\nDon't forget to delete the DynamoDB table that you created too:\n\n`aws cloudformation delete-stack --stack-name my-stack`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomkat-cr%2Fchalice_crud_backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomkat-cr%2Fchalice_crud_backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomkat-cr%2Fchalice_crud_backend/lists"}