{"id":21507403,"url":"https://github.com/felipelaptrin/serverless-infra-blog","last_synced_at":"2026-05-07T21:36:36.868Z","repository":{"id":264040099,"uuid":"892177073","full_name":"felipelaptrin/serverless-infra-blog","owner":"felipelaptrin","description":"A demo for my blog post on how to deploy a serverless infrastructure (DynamoDB, API Gateway, Lambda, S3, CloudFront) using Terraform","archived":false,"fork":false,"pushed_at":"2024-11-21T16:37:18.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T00:29:24.854Z","etag":null,"topics":["api-gateway","aws","blog","cloudfront","devbox","go","lambda","terraform"],"latest_commit_sha":null,"homepage":"https://felipetrindade.com/serverless-infra/","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/felipelaptrin.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":"2024-11-21T16:33:31.000Z","updated_at":"2024-11-21T16:37:22.000Z","dependencies_parsed_at":"2024-11-21T17:47:02.487Z","dependency_job_id":null,"html_url":"https://github.com/felipelaptrin/serverless-infra-blog","commit_stats":null,"previous_names":["felipelaptrin/serverless-infra-blog"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fserverless-infra-blog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fserverless-infra-blog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fserverless-infra-blog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fserverless-infra-blog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felipelaptrin","download_url":"https://codeload.github.com/felipelaptrin/serverless-infra-blog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244052955,"owners_count":20390235,"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":["api-gateway","aws","blog","cloudfront","devbox","go","lambda","terraform"],"created_at":"2024-11-23T20:13:54.240Z","updated_at":"2026-05-07T21:36:31.845Z","avatar_url":"https://github.com/felipelaptrin.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serverless Infra (Blog)\n\n## Running this project\nThe only dependency needed to start using this project is [Devbox](https://www.jetify.com/devbox) and [Nix](https://nixos.org/download/) (if you install Devbox first it will install Nix for you if you don't have it), all the other tools will be installed by it. Make sure your AWS region was already CDK bootstrapped.\n\n1) Export AWS credentials and region (`AWS_REGION`) environment variables\n\n2) Install dependencies\n\n```sh\ndevbox shell\n```\n\n3) Create S3 for states and DynamoDB table\n\n```sh\ncd iac/bootstrap\nterraform init\nterraform apply\n```\n\nCopy the `s3-state-bucket-name` and `dynamodb-lock-table-name` because we will use it to run step 5.\n\n4) Deploy infrastructure\n\nCreate `variables.tfvars` in the `iac/src` folder.\n\n```\ndomain               = \"mydomain.com\"\nfrontend_bucket_name = \"assets-frontend-serverless-infra-bucket\"\n```\n\nModify the `iac/src/versions.tf` file to use the correct `dynamodb_table` and `bucket` created during bootstrap (exported during step 3). Apply the infrastructure code.\n\n```sh\ncd ../src/\nterraform init\nterraform apply --var-file=variables.tfvars\n```\n\nIt's **expected** for this run to fail.\n\n5) Build and deploy backend image\n\n```sh\ncd ../../backend/\nAWS_ACCOUNT=$(aws sts get-caller-identity --query Account --output text)\naws ecr get-login-password | docker login --username AWS --password-stdin $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com\ndocker build -t backend-api .\ndocker tag backend-api:latest $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/backend-api:latest\ndocker push $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/backend-api:latest\n```\n\n6) Push frontend assets to S3 bucket\n\n```sh\ncd ../iac/src/\nBUCKET=$(terraform output -raw frontend_bucket)\naws s3 sync ../../frontend s3://$BUCKET\n```\n\n7) Apply Infrastructure again\n\n```sh\nterraform apply --var-file=variables.tfvars\n```\n\nAll done!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipelaptrin%2Fserverless-infra-blog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelipelaptrin%2Fserverless-infra-blog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipelaptrin%2Fserverless-infra-blog/lists"}