{"id":19565232,"url":"https://github.com/t18n/prisma2-graphql-aws-cdk","last_synced_at":"2025-07-28T06:09:30.058Z","repository":{"id":55413090,"uuid":"229473975","full_name":"t18n/prisma2-graphql-aws-cdk","owner":"t18n","description":"A GraphQL server build on top of Apollo + Prisma 2. This project is configured to deploy to AWS using AWS CDK.","archived":false,"fork":false,"pushed_at":"2021-01-01T18:39:00.000Z","size":275,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-27T01:33:05.864Z","etag":null,"topics":["apollo-server","aws-cdk","aws-lambda","aws-rds","graphql","prisma2"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/t18n.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}},"created_at":"2019-12-21T19:32:24.000Z","updated_at":"2023-07-19T23:17:28.000Z","dependencies_parsed_at":"2022-08-14T23:50:26.815Z","dependency_job_id":null,"html_url":"https://github.com/t18n/prisma2-graphql-aws-cdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/t18n/prisma2-graphql-aws-cdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t18n%2Fprisma2-graphql-aws-cdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t18n%2Fprisma2-graphql-aws-cdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t18n%2Fprisma2-graphql-aws-cdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t18n%2Fprisma2-graphql-aws-cdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t18n","download_url":"https://codeload.github.com/t18n/prisma2-graphql-aws-cdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t18n%2Fprisma2-graphql-aws-cdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267470062,"owners_count":24092352,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["apollo-server","aws-cdk","aws-lambda","aws-rds","graphql","prisma2"],"created_at":"2024-11-11T05:25:43.295Z","updated_at":"2025-07-28T06:09:30.025Z","avatar_url":"https://github.com/t18n.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PRISMA 2 + Apollo 2 + GraphQL with AWS CDK\n\n\u003e If you would like to use this project only for testing purpose, rememember to run `cdk destroy --profile profile-name` to delete the stack afterwards to prevent any unexpected charge.\n\u003e This project is not fully optimized for production\n\n## Prerequisites\n\n- Install [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-macos.html)\n- Install [AWS CDK](https://docs.aws.amazon.com/cdk/latest/guide/home.html)\n- Install [Yarn](https://yarnpkg.com/lang/en/docs/install/#mac-stable)\n\n## Getting started\n\n1. Prepare\n\n- Run `git clone git@github.com:turbothinh/prisma2-graphql-aws-cdk.git`\n- Run one-liner command to install yarn `cd prisma2-graphql-aws-cdk \u0026\u0026 yarn \u0026\u0026 cd cdk yarn \u0026\u0026 cd ../`\n- \u003e Note: All `cdk` commands must be run inside `cdk` folder\n- Install 2 AWS profiles with command `aws configure --profile \u003cprofile-name\u003e`, profile name can be replaced as you wish, for e.g.\n  - 1 programming profile has full IAM permission\n  - 1 programming profile to be assigned to custom policy\n- Create a local database and add connection string to `.env.development` file\n\n1. Seed database\n\n- Run `yarn env:dev \u0026\u0026 yarn db:migrate`\n- Run `yarn db:seed:dev`\n- Run `yarn generate:photon:dev`\n- Run `yarn start:dev`\n- Open `localhost:4000` on browser\n\n## Deployment\n\n- Run `yarn build:cdk`\n- Go inside `cdk` folder and run `PROFILE=\u003cyour-configured-aws-profile\u003e aws:cdk:deploy`\n- Go to AWS Console -\u003e CloudFormation to see deployed stack\n\n## Removing stack\n\n- Go inside `cdk` folder\n- Run `cdk destroy --profile \u003cyour-configured-aws-profile\u003e`\n- \u003e Note: AWS CloudFormation sometimes fails to delete resources as they are dependent on the others, I see it happens a lot with RDS and its Subnet. If this causes CloudFormation stack DELETE_FAIL status, try deleting it manually in AWS Console -\u003e RDS -\u003e Database\n\n## Development;\n\n1. Resources\n\n   - [CDK Documentation](https://docs.aws.amazon.com/cdk/api/latest/typescript/api/index.html)\n   - [CDK Examples](https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript)\n   - [Prisma 2 Docs](https://github.com/prisma/prisma2/tree/master/docs)\n\n2. Deploying to Lambda Function\n   - [Generating correct Binaries for Photon](https://github.com/prisma/specs/blob/master/binaries/Readme.md#1-development-machine-is-mac-but-the-deployment-platform-is-aws-lambda)\n     Create a file called `env.production` and add BINARY_TARGET='rhel-openssl-1.0.x' to build Photon for Lambda\n\n3) Connect to Database Inside VPC using Bastion server\n\n   - [Documentation](https://aws.amazon.com/de/blogs/compute/new-using-amazon-ec2-instance-connect-for-ssh-access-to-your-ec2-instances/)\n   - Find instance id of your Bastian host: AWS Console -\u003e EC2 -\u003e Instances -\u003e Instance ID\n   - Prepare ssh public key locally\n   - Locate region and availability zone of the Bastian host, then upload SSH key\n\n     ```bash\n     aws ec2-instance-connect send-ssh-public-key --region eu-west-2 --instance-id i-0d390c831797b24f2 --availability-zone eu-west-2a --instance-os-user \u003cyour-aws-profile\u003e --ssh-public-key file://~/.ssh/id_rsa.pub --profile \u003cyour-aws-profile\u003e\n     ```\n\n   - After uploading, you have 60s to connect to the Bastion via SSH. Find the Public DNS of the Bastion AWS Console -\u003e EC2 -\u003e Instances -\u003e Publish DNS. Afterwards, use username `ec2-user` to connect via ssh.\n\n     ```\n     ssh ec2-user@\u003cbastion-public-dns-address\u003e\n     ```\n\n## Architecture\n\n![Architecture diagram](https://raw.githubusercontent.com/turbothinh/prisma2-graphql-aws-cdk/master/static/Architecture.png)\n\nBastion is a great way to access resource inside VPC. I initially take that approach to access the database. However, I realized that it would add complexity and cost to the stack. Fortunately, AWS comes with Security Group, which allows you to define what IP can access your resource. I believe Security Group approach is way more handy and flexible. Therefore, feel free to remove the Bastion host from the stack. Remember to update your Database security group with your IP to enable access from host machine.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft18n%2Fprisma2-graphql-aws-cdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft18n%2Fprisma2-graphql-aws-cdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft18n%2Fprisma2-graphql-aws-cdk/lists"}