{"id":18412908,"url":"https://github.com/rproenza86/aws-infrastructure-code-serverless-webapp","last_synced_at":"2025-04-07T11:32:15.418Z","repository":{"id":96672237,"uuid":"156262522","full_name":"rproenza86/aws-infrastructure-code-serverless-webapp","owner":"rproenza86","description":"Serverless Web Application using Amazon DynamoDB, Lambda, API Gateway and S3.","archived":false,"fork":false,"pushed_at":"2018-11-12T21:52:36.000Z","size":42,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T17:11:29.581Z","etag":null,"topics":["amazon-dynamodb","api-gateway","aws","aws-lambda","sdk","serverless","terraform"],"latest_commit_sha":null,"homepage":null,"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/rproenza86.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-05T18:18:13.000Z","updated_at":"2023-02-22T07:37:40.000Z","dependencies_parsed_at":"2023-04-11T15:46:30.661Z","dependency_job_id":null,"html_url":"https://github.com/rproenza86/aws-infrastructure-code-serverless-webapp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rproenza86%2Faws-infrastructure-code-serverless-webapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rproenza86%2Faws-infrastructure-code-serverless-webapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rproenza86%2Faws-infrastructure-code-serverless-webapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rproenza86%2Faws-infrastructure-code-serverless-webapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rproenza86","download_url":"https://codeload.github.com/rproenza86/aws-infrastructure-code-serverless-webapp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247644576,"owners_count":20972317,"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":["amazon-dynamodb","api-gateway","aws","aws-lambda","sdk","serverless","terraform"],"created_at":"2024-11-06T03:44:06.108Z","updated_at":"2025-04-07T11:32:15.405Z","avatar_url":"https://github.com/rproenza86.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serverless Web Apps using Amazon DynamoDB\n\n\u003e Terraform scripts to build the AWS environment where to deploy interactive serverless web applications which uses Amazon API Gateway calls to send requests to AWS Lambda backends that query Amazon DynamoDB data.\n\n```\nTested using:\n\nTerraform v0.11.10\n+ provider.aws v1.42.0\n```\n\n## Use case description\nBuild and run an application and services without needing to provision, manage, and scale infrastructure.\n\nDesign, build, and deploy an interactive serverless web application, using a simple HTML/JavaScript web interface which uses Amazon API Gateway calls to end requests to AWS Lambda backends that query Amazon DynamoDB data.\n\n### Infrastructure objectives\n\n- Create Amazon DynamoDB\n  \u003e Non-sql database to store the application data\n- Create the necessary IAM roles and polices\n  \u003e To access the application data\n- Create AWS Lambda\n  \u003e It will interact with DynamoDB and retrieve in several different way\n- Create custom Lambda test\n- Create Amazon API Gateway\n  \u003e It will expose the Lambda function to the Internet as configured API\n- Public web site\n  \u003e UI to retrieve information from DynamoDB via Lambda functions\n- Tie the three services together to build a functional serverless web app, and deploy it live on the web.\n\n## How to use\n\n### Pre-requirement: Set AWS environment variables\n\n```\n$ export TF_VAR_access_key=\u003cyour_key\u003e\n\n$ export TF_VAR_secret_key=\u003cyour-secret\u003e\n\n$ export TF_VAR_region=\u003cyour_region\u003e\n```\n\n### Initialize a working directory\n\n`$ cd serverless_intrastructure/`\n\n`$ terraform init`\n\n### Create an execution plan\n\n`$ terraform plan`\n\n### Apply the changes required to reach the desired state of the configuration\n\n`$ terraform apply`\n\n### Delete infrastructure\n\n`$ terraform destroy`\n\n## How to test?\n\nWhen applied the configuration `terraform` will show us the next output:\n\n```\nOutputs:\n\nGet heroes list API endpoint = https://xdlugc2266.execute-api.us-east-1.amazonaws.com/DeploySuperAPI/getheroeslist\n\nGet heroes mission details API endpoint = https://xdlugc2266.execute-api.us-east-1.amazonaws.com/DeploySuperAPI/getmissiondetails\n\napi_gateway_base_url = https://xdlugc2266.execute-api.us-east-1.amazonaws.com/DeploySuperAPI\n\ndynamoDb_created_table_name = SuperMission\n```\n\nUse the `endpoint` info to test your api directly using this curl calls:\n\n\u003e Get heroes list\n\n```bash\n    curl -X POST \\\n    \u003cUse your \"Get heroes list API endpoint\" output value\u003e \\\n    -H 'Cache-Control: no-cache' \\\n    -H 'Content-Type: application/json' \\\n    -H 'Postman-Token: 84ac228b-d6bc-4768-9a28-a21348f68275' \\\n    -d '{}'\n```\n\n\u003e Get missing details for an specific heroe\n\n```bash\n    curl -X POST \\\n    \u003cUse your \"Get heroes mission details API endpoint\" output value\u003e \\\n    -H 'Access-Control-Request-Headers: content-type' \\\n    -H 'Access-Control-Request-Method: POST' \\\n    -H 'Cache-Control: no-cache' \\\n    -H 'Content-Type: application/json' \\\n    -H 'Origin: null' \\\n    -H 'Postman-Token: 8c2ee690-1e93-4784-9981-654cc7d6515c' \\\n    -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3604.0 Safari/537.36' \\\n    -d '{\n    \"superhero\": \"Batman\"\n    }'\n```\n\n### Generate the SDK For Your API\n\nOn the `Stage` editor of your `ServerlessSuperHeroesApi` API Gateway, click the `SDK Generation` tab, then configure:\n\n\u003cul\u003e\n\u003cli\u003e\n\u003cstrong\u003ePlatform:\u003c/strong\u003e \u003cem\u003eJavascript\u003c/em\u003e\n\u003c/li\u003e\n\u003cli\u003eClick \u003cspan style=\"background-color:#257ACF;font-weight:bold;font-size:90%;color:white;border-radius:5px;padding-top:3px;padding-bottom:3px;padding-left:10px;padding-right:10px;\"\u003eGenerate SDK\u003c/span\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\nNext:\n\u003cul\u003e\n\u003cli\u003e\u003cp\u003eSave the zip file to a location on your computer.\u003c/p\u003e\u003c/li\u003e\n\u003cli\u003e\u003cp\u003eExtract the content of the JavaScript zip file you downloaded in the \u003ccode\u003eserverless_intrastructure/files/apiGateway-js-sdk/\u003c/code\u003e directory.\u003c/p\u003e\n\u003cp\u003eThere, you will have an HTML page that you will use to test your API.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\nAfter that:\n\u003cul\u003e\n\u003cli\u003e\u003cp\u003eOpen index.html located on your \u003ccode\u003eserverless_intrastructure/files/apiGateway-js-sdk/\u003c/code\u003e directory in your browser.\u003c/p\u003e\n\u003cp\u003eYou will notice that the drop-down list uses the API Gateway resource \u003cstrong\u003egetheroeslist\u003c/strong\u003e to invoke the \u003cstrong\u003egetheroeslistFunction\u003c/strong\u003e Lambda function.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp\u003eUsing the index web page, retrieve mission details.\u003c/p\u003e\u003c/li\u003e\n\u003cli\u003e\u003cp\u003eReview the output.\u003c/p\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003cp\u003e\u003cstrong\u003eNote\u003c/strong\u003e To retrieve mission details using the index web page, select the Super Hero name in the drop down list and then click \u003cstrong\u003eGO\u003c/strong\u003e to display the Mission Status and Mission Dossier\u003c/p\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frproenza86%2Faws-infrastructure-code-serverless-webapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frproenza86%2Faws-infrastructure-code-serverless-webapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frproenza86%2Faws-infrastructure-code-serverless-webapp/lists"}