{"id":22983272,"url":"https://github.com/mikejoh/serverless-bookstore","last_synced_at":"2026-04-16T11:02:24.805Z","repository":{"id":133966486,"uuid":"159073644","full_name":"mikejoh/serverless-bookstore","owner":"mikejoh","description":"Creates a AWS serveless bookstore with terraform to demo Lambda, Dynamodb and API Gateway.","archived":false,"fork":false,"pushed_at":"2018-11-28T19:25:20.000Z","size":64,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T04:02:25.546Z","etag":null,"topics":["aws","aws-apigateway","aws-dynamodb","aws-lambda","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/mikejoh.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-25T20:53:28.000Z","updated_at":"2018-11-28T19:25:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"cfe4c44e-73a9-44b2-be9b-04037752471a","html_url":"https://github.com/mikejoh/serverless-bookstore","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/mikejoh%2Fserverless-bookstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikejoh%2Fserverless-bookstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikejoh%2Fserverless-bookstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikejoh%2Fserverless-bookstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikejoh","download_url":"https://codeload.github.com/mikejoh/serverless-bookstore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246794436,"owners_count":20834993,"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","aws-apigateway","aws-dynamodb","aws-lambda","serverless","terraform"],"created_at":"2024-12-15T02:37:03.689Z","updated_at":"2025-10-18T00:42:49.943Z","avatar_url":"https://github.com/mikejoh.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create the serverless Bookstore with terraform\n\nThis repository extends [this](https://www.alexedwards.net/blog/serverless-api-with-go-and-aws-lambda) great blog post written by [Alex Edwards](https://github.com/alexedwards/) by using `terraform` to create the final serverless bookstore example.\n\n**If you haven't already make sure you read through and follow the blog post at least once before you begin!**\n\n## Step-by-step guide\n\n_Note that this guide uses the `us-east-1` as the AWS region where everything will be created. You can change the region in the `vars.tf` file but remember to also change the region in the `books/db.go` file and the global `db` variable._\n\n1. [Download](https://www.terraform.io/downloads.html) and [install](https://www.terraform.io/intro/getting-started/install.html) `terraform`\n2. Create a new IAM User (i called the user `terraformer`) and generate access keys. Take a note of the `AccessKeyId` and `SecretAccessKey` fields when you generate the access keys below, you'll need them in step 3:\n```\naws iam create-user --user-name terraformer\naws iam create-access-keys --user-name terraformer\n```\n2. Attach the `AdministratorAccess` to the newly created user:\n```\naws iam attach-user-policy --policy-arn arn:aws:iam::aws:policy/AdministratorAccess --user-name terraformer\n```\n3. Create a new `awscli` profile and reference the generated access keys (through `stdin`):\n```\naws configure --profile terraformer\n```\n4. Run `make aws-lambda-build` in the `books/` directory to compile a binary and create the needed zip-file. The zip-file must be present when running `terraform` in the next step!\n5. Now run the following `terraform` commands in root of this repository:\n```\nterraform validate\nterraform init\nterraform plan\nterraform apply\n```\nWhen everything is created you'll be presented with an output similar to this:\n\n```\nApply complete! Resources: 12 added, 0 changed, 0 destroyed.\n\nOutputs:\n\nbooks_rest_api_endpoint = https://REST_API_ID.execute-api.REGION.amazonaws.com/staging/books\n```\n\nYou can use `terraform output` retrieve the `books_rest_api_endpoint` later on. \n\nTo test the serverless bookstore and create a new book through the API:\n```\ncurl -i -H \"Content-Type: application/json\" -X POST \\\n-d '{\"isbn\":\"978-0141439587\", \"title\":\"Emma\", \"author\": \"Jane Austen\"}' \\\n$(terraform output books_rest_api_endpoint)\n```\n\nAnd to get the created book item:\n```\ncurl $(terraform output books_rest_api_endpoint)?isbn=978-0141439587\n```\n\nTo remove all resource created in AWS you can run `terraform destroy`.\n\n## Overview (GET request)\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/mikejoh/serverless-bookstore/blob/master/aws-serverless-bookstore-get.png\" title=\"GET request\"\u003e\n\u003c/p\u003e\n\n## Terraform\n\nAbout Terraform (taken from the official homepage):\n\n_HashiCorp Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned._\n\nSee the official Terraform Getting Started guide [here](https://www.terraform.io/intro/getting-started/build.html).\n\nSome words on the `terraform` commands that we ran in the guide above:\n\n`terraform validate`, validates the syntax of the `terraform` configuration files.\n\n`terraform init` initializes a working directory containing Terraform configuration files.\n\n`terraform plan` is used to create an execution plan. Terraform performs a refresh, unless explicitly disabled, and then determines what actions are necessary to achieve the desired state specified in the configuration files.\n\n`terraform apply` is used to apply the changes required to reach the desired state of the configuration, or the pre-determined set of actions generated by a terraform plan execution plan.\n\n`terraform destroy` is used to destroy the Terraform-managed infrastructure.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikejoh%2Fserverless-bookstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikejoh%2Fserverless-bookstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikejoh%2Fserverless-bookstore/lists"}