- name:
configure_gcp_endpoints
- yaml reference:
Auddia/cicd/actions/configure_gcp_endpoints@<tag>
- action type: Docker Action
This is a custom action used for deploying updated api definitions to gcp endpoints.
NOTE: This action assumes that you have setup the gcloud sdk with this action
This action is available on tags v0
and above
- Deploy new/updated endpoints configuration/definition (i.e. changes to the
openapi.yaml
) to GCP endpoints. - Build a new image for the gateway proxy to endpoints and upload it to container registry, so it can be redeployed in cloud run.
- Redeploy the gateway proxy (i.e. a Cloud Run Service) using the newly generated image
- Update the default service account privileges, so it can invoke the backend endpoints through the gateway proxy
To use this action in your repository you need to do the following steps to configure the GCP environment properly.
- Create the Gateway Proxy for GCP endpoints
- Create Cloud Run Service by deploying ESPv2 container:
$ gcloud run deploy <API_NAME>-endpoints-cloudrun-service \
--image="gcr.io/endpoints-release/endpoints-runtime-serverless:2" \
--allow-unauthenticated \
--platform managed \
--project <GCP_PROJECT> \
--region us-central1
-
Map the custom subdomain to the desired backend service in cloud run.
- Go to the GCP cloud console.
- First click on to
Cloud Run
- Then click
Manage Custom Domains
in the top banner - Add the mapping of api service to the desired domain name.
- NOTE: Make sure the domain is verified in
Cloud DNS
- NOTE: Make sure the domain is verified in
-
Run the
configure_gcp_endpoints
action. -
(Optional) If you see an error about the ownership of the domain name and it is the first time you are attempting to successfully run this workflow follow the steps below to fix the issue.
- Note: This may not solve the issue
- Error Example:
ERROR: (gcloud.endpoints.services.deploy) PERMISSION_DENIED: Ownership for domain name 'events.cfr-staging.auddia.services' on project 'cfr-projects-staging' cannot be verified.
- Automatically compile the openapi document or copy it from the CICD workflow into the file
openapi
. - Run this command
$ gcloud endpoints services deploy ./openapi --project <gcp_project>
- Description: The GCP project name
type
:string
required
:true
- Description: The subdomain of the api being deployed
type
:string
required
:true
- Description: Name of the api
type
:string
required
:false
- You must specify this field or the
function_name
field
- Description: Name of the GCP function
type
:string
required
:false
- You must specify this field or the
api_name
field
- Description: Name of the GCP endpoints service name
type
:string
required
:true
- Description: The service account you want to run the gcloud deployment commands
type
:string
required
:true
- Description: The location of the openapi yaml that defines the api's endpoints
type
:string
default
:./open_api.yaml
jobs:
example_job:
name: 'Configure GCP Enpoints Example'
runs-on: ubuntu-latest
steps:
- name: GCloud SDK Setup
uses: Auddia/cicd/actions/setup_gcloud@<tag>
with:
gcp_credentials: ${{ secrets.GCP_CREDEENTIALS }}
- name: 'Configure Endpoints'
uses: Auddia/cicd/actions/configure_gcp_endpoints@<tag>
with:
gcp_project: ${{ inputs.gcp_project }}
api_subdomain: ${{ inputs.api_subdomain }}
api_name: ${{ inputs.api_name }}
endpoints_service_name: ${{ inputs.endpoints_service_name }}
default_service_account: ${{ inputs.default_service_account }}
openapi_yaml: ${{ inputs.openapi_yaml }}
- Tests
- Reuseable Workflow OpenAPI Update
- OpenAPI Update Deployment
- Note this is call to the reusable workflow from above, but it is still an example of how to configure the
configure_gcp_endpoints
action.
- Note this is call to the reusable workflow from above, but it is still an example of how to configure the