This demo is based on the official Google quickstart for API Gateway fronting a Cloud Run instance. Lovingly repurposed from Google with <3 for the benefit of all.
The application itself is based on previous work on cloud-run-ts-apollo-graphql.
The example app is a GraphQL server (Apollo Server 2) that responds to the typical /graphql
endpoint, which is also exposed in the API specification (api-spec.yaml
).
- You have a GCP account
- You are logged in through your environment
- You have set your variables as needed in
setup.sh
- Run
deploy-app.sh
to deploy your basic demo application to Cloud Run - Set
x-google-backend.address
inapi-spec.yaml
to your Cloud Run endpoint (looks similar tohttps://PROJECT_AND_RANDOM_STRING.a.run.app/graphql
) - Refer to https://cloud.google.com/iap/docs/app-engine-quickstart#enabling_iap for how to enable IAP. Copy the IAP client ID and set it in
x-google-backend.address.jwt_audience
inapi-spec.yaml
. - Go to IAP and set up your consent screen if it's not done above. You will most likely use the "External" option. Add a few users (like yourself) that should be granted access. Enable IAP for the web service.
- Run
setup.sh
to login, update yourgcloud
CLI tool and enable required APIs, and then finally deploy the API resources. - Visit the application URL. Any requests from an accepted user should go through and the rest should be blocked.
Install dependencies, then run npm start
to use ts-node
to run your code.