{"id":15950215,"url":"https://github.com/omerap12/serverless-url-shortener-api","last_synced_at":"2025-03-26T06:31:55.468Z","repository":{"id":171883569,"uuid":"613357678","full_name":"omerap12/Serverless-url-shortener-api","owner":"omerap12","description":"This repository contains Terraform configurations and AWS Lambda functions to create a simple URL shortener API using AWS API Gateway, AWS Lambda, and DynamoDB. ","archived":false,"fork":false,"pushed_at":"2023-11-11T12:07:28.000Z","size":487,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T09:51:09.870Z","etag":null,"topics":["aws","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","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/omerap12.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-03-13T12:20:49.000Z","updated_at":"2025-03-03T11:46:47.000Z","dependencies_parsed_at":"2023-11-11T13:25:04.028Z","dependency_job_id":null,"html_url":"https://github.com/omerap12/Serverless-url-shortener-api","commit_stats":null,"previous_names":["omerap12/serverless-url-shortener-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omerap12%2FServerless-url-shortener-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omerap12%2FServerless-url-shortener-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omerap12%2FServerless-url-shortener-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omerap12%2FServerless-url-shortener-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omerap12","download_url":"https://codeload.github.com/omerap12/Serverless-url-shortener-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245603953,"owners_count":20642914,"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","terraform"],"created_at":"2024-10-07T12:58:46.958Z","updated_at":"2025-03-26T06:31:55.057Z","avatar_url":"https://github.com/omerap12.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Serverless URL Shortener API\n\nThis repository contains Terraform configurations and AWS Lambda functions to create a simple URL shortener API using AWS API Gateway, AWS Lambda, and DynamoDB. The API allows users to create short URLs and retrieve the original full URLs associated with the short URLs.\n![READ](https://github.com/omerap12/Serverless-url-shortener-api/assets/61663422/22ae2c2f-b262-4f5e-b64d-c08eb26bf463)\n\n## Terraform Configurations\n\n\n\nThe Terraform configurations in this repository create the following AWS resources:\n\n\n* API Gateway: An API Gateway with HTTP protocol enabled. It has two routes:\n\n1. GET /read: Retrieves the original full URL associated with a short URL.\n2. POST /write: Creates a short URL associated with a full URL.\n\n* AWS Lambda Functions:\n\n1. read_lambda: Handles the GET /read route. It retrieves the full URL associated with a short URL from DynamoDB.\n2. write_lambda: Handles the POST /write route. It stores the short URL and full \n* URL mapping in DynamoDB.\nDynamoDB Table: A DynamoDB table named url-table to store the mappings between short URLs and full URLs.\n## Prerequisites\n\nBefore applying the Terraform configurations, make sure you have the following:\n* AWS account credentials configured.\n* Terraform installed on your local machine.\n\n## Deployment\n\n1. Clone this repository:\n\n```bash\n  git clone https://github.com/omerap12/Serverless-url-shortener-api.git\n  cd Serverless-url-shortener-api\n```\n2. Initialize Terraform and apply the configurations:\n```bash\nterraform init\nterraform apply\n```\n3. After applying the Terraform configurations, the API Gateway endpoint URLs for read and write operations will be provided as outputs. You can find them in the Terraform output variables.\n\n## Usage Examples\n### Add Short URL\nTo add a short URL, use the following `curl` command:\n```bash\ncurl -X POST -d '{\"full_url\":\"test.com\",\"short_url\":\"test\"}' -H \"Content-Type: application/json\" -i $api_url_write\n```\n### Get Full URL\nTo get a Full URL from a short URL, use the following `curl` command:\n```bash\ncurl -X GET -d '{\"short_url\":\"test\"}' -H \"Content-Type: application/json\" -i $api_url_read\n```\n\n## Lambda Functions\n\n### `read_lambda` Function\n\nThe read_lambda function handles the GET /read route. It takes a short URL as input, retrieves the corresponding full URL from DynamoDB, and returns the full URL in the response.\n\n### `write_lambda` Function\nThe write_lambda function handles the POST /write route. It takes a JSON payload containing a short URL and a full URL, stores the mapping in DynamoDB, and returns a success message in the response.\n## Cleanup\n\nTo destroy the resources created by Terraform, run:\n```bash\nterraform destroy\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomerap12%2Fserverless-url-shortener-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomerap12%2Fserverless-url-shortener-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomerap12%2Fserverless-url-shortener-api/lists"}