View a GCP project's API/service endpoint configurations.

Overview

GCP Service Observer

This is an application that displays GCP Service/API endpoint information for a given project. GCP requires API endpoints to be enabled per project before they can be leveraged so knowing which ones are enabled or disabled is an important first step in programmatically using client libraries or RESTFUL APIs.

The GCP Service Observer application is a personal project and not recommended for production or enterprise environments.

Table of Concents

Features

  • Project ID permissions checks
  • Input sanitation and validation
  • Can return all enabled, disabled, or both APIs for a given project
  • Table filtering
  • Direct-documentation links to enable or disable APIs manually
  • Deploy locally for easy debugging
  • Low cost - runs via Cloud Run

Example Table

Configuration

This application is designed to be deployed in a single project but the service account backing Cloud Run would have an IAM binding on the organization node. This configuration allows you to view any project's API/service endpoint status in the GCP organization.

Before configuring for org-wide observability I would highly recommend adding some type of end user authentication. Google provides a nice turorial here.

The below steps are only required if you want to deploy to Cloud Run. If you want to deploy locally jump to Local Deployment.

Steps

Assuming you just want to demo the application in Cloud Run the only configuration needed is to add a value for the project_id variable in the variables.tf file:

variable "project_id" {
  description = "The project ID where the service is deployed."
  default     = "demo-project-id" # add this line
}

If you want to deploy with observability across an entire organization you will need to add the above project_id variable and the below updates:

  1. Uncomment the variable "org_id" block in the variables.tf file and add a default value:
# Uncomment if using on org-level
#variable "org_id" {
#  description = "The organization ID where the service observer app has API/service view access."
#}

would become:

variable "org_id" {
  description = "The organization ID where the service observer app has API/service view access."
  default     = "my-org-id" # add this line
}
  1. In the main.tf file uncomment the organization specific resources:
# Enable below for org-level project API / service listing
#resource "google_organization_iam_member" "organization-sa-iam" {
#  org_id  = var.org_id
#  role    = google_organization_iam_custom_role.organization-sa-custom-role.id
#  member = "serviceAccount:${google_service_account.service-observer-sa.email}"
#}

#resource "google_organization_iam_custom_role" "organization-sa-custom-role" {
#  role_id     = "ServiceObserverViewerRole"
#  org_id      = var.org_id
#  title       = "Service Observer org IAM role. View only."
#  description = "Provides permissions to view API/services across the organization."
#  permissions = ["resourcemanager.projects.get", "servicemanagement.services.list"]
#}

would become:

resource "google_organization_iam_member" "organization-sa-iam" {
  org_id  = var.org_id
  role    = google_organization_iam_custom_role.organization-sa-custom-role.id
  member = "serviceAccount:${google_service_account.service-observer-sa.email}"
}

resource "google_organization_iam_custom_role" "organization-sa-custom-role" {
  role_id     = "ServiceObserverViewerRole"
  org_id      = var.org_id
  title       = "Service Observer org IAM role. View only."
  description = "Provides permissions to view API/services across the organization."
  permissions = ["resourcemanager.projects.get", "servicemanagement.services.list"]
}
  1. Lastly comment out the project-level IAM resources:
# Disable below if using for org-wide API/service listing
resource "google_project_iam_member" "project-sa-iam" {
  project = var.project_id
  role    = google_project_iam_custom_role.project-sa-custom-role.id
  member  = "serviceAccount:${google_service_account.service-observer-sa.email}"
}

resource "google_project_iam_custom_role" "project-sa-custom-role" {
  project     = var.project_id
  role_id     = "ServiceObserverViewerRole"
  title       = "Service Observer project IAM role. View only."
  description = "Provides permissions to view API/services on a given project."
  permissions = ["resourcemanager.projects.get", "servicemanagement.services.list"]
}

would become:

# Disable below if using for org-wide API/service listing
#resource "google_project_iam_member" "project-sa-iam" {
#  project = var.project_id
#  role    = google_project_iam_custom_role.project-sa-custom-role.id
#  member  = "serviceAccount:${google_service_account.service-observer-sa.email}"
#}

#resource "google_project_iam_custom_role" "project-sa-custom-role" {
#  project     = var.project_id
#  role_id     = "ServiceObserverViewerRole"
#  title       = "Service Observer project IAM role. View only."
#  description = "Provides permissions to view API/services on a given project."
#  permissions = ["resourcemanager.projects.get", "servicemanagement.services.list"]
#}

Deployment

This application runs via Cloud Run and is deployed via Terraform or can be run locally. Please review the Configuration section before deploying.

In order to deploy to GCP you'll need administrator permissions for Cloud Run and the ability to enable/disable APIs and create IAM resources.

Cloud Deployment

Before deploying authenticate locally via gcloud auth login --update-adc

  1. To deploy first change directories into the terraform folder and execute terraform init
# Change directory
  cd terraform/

# initialize terraform
  terraform init
  • You should see a message stating Terraform has been successfully initialized!
  1. Next execute a terraform plan -out tfplan.json and then review the potential updates.

  2. If you are satisfied with the updates deploy the terraform via terraform apply tfplan.json

  3. After the terraform is deployed you will see an output at the very end of the deployment that will look similar to

Outputs:

sa_id = "[email protected]"
  1. Export the service account ID and the project ID you used for the Terraform project_id variable:
export SA_ID="[email protected]"
export PROJ_ID="demo-project-id"
  1. Now that the infrastructure is mostly deployed we can deploy to Cloud Run via:
# Remember to change directories to the root of the repo
cd ../

# Deploy Cloud Run
gcloud beta run deploy gcpserviceobserver --source "." \
    --region="us-east1" \
    --service-account=$SA_ID \
    --allow-unauthenticated \
    --project=$PROJ_ID
  1. GCP will perform all of the configuration needed for Cloud Run and once completed will provides a URL to access the application. Your output will look similar to below (if nothing went wrong):
Building using Dockerfile and deploying container to Cloud Run service [gcpserviceobserver] in project [gcp-service-observer] region [us-east1]
✓ Building and deploying new service... Done.
  ✓ Uploading sources...
  ✓ Building Container... Logs are available at [https://console.cloud.google.com/cloud-build/builds/2730
  3291-f10b-4f13-978f-74b941787060?project=285094994588].
  ✓ Creating Revision...
  ✓ Routing traffic...
  ✓ Setting IAM Policy...
Done.
Service [gcpserviceobserver] revision [gcpserviceobserver-00001-mif] has been deployed and is serving 100 percent of traffic.
Service URL: https://gcpserviceobserver-hda7rvdo7a-ue.a.run.app
  1. Clicking the Service URL value will launch the GCP Service Observer application.

Local Deployment

  1. To deploy locally you will first need to export the Flask environment url:
export FLASK_APP=main
  1. Next run Flask:
flask run
  1. Enter the local URL in your browser window http://127.0.0.1:5000

Contributing

Contributions are always welcome! This is a personal project but of course feel free to fork and have fun with it!

Comments / concerns / bug info? Message me on Twitter @jasonadyke or LinkedIn.

You might also like...

Official moon configurations for popular JavaScript developer tooling.

moon development configs This repository is a collection of moon owned and maintained configurations and presets for common developer tools -- primari

Nov 10, 2022

Git Frameworker is a CLI tool for quickly bootstrapping custom framework configurations.

Git Frameworker is a CLI tool for quickly bootstrapping custom framework configurations.

Git Frameworker Git Frameworker is a tool that allows you to quickly bootstrap a project using a framework from GitHub. If the repository you clone co

May 3, 2023

RESTful service to provide API linting as-a-service

API Linting Service Prerequisites / general idea General idea behind this API implementation is to provide an API as a service based on the awesome sp

Mar 14, 2022

📺 useless little service to view websites as ascii in the terminal

📺 useless little service to view websites as ascii in the terminal

browscii useless little service to view websites as ascii screenshot in the terminal Usage curl the service and add the site you want to see as url qu

Aug 26, 2022

Front-end for FireNearby service. View recent fires and sign up to receive alerts: caseymm.github.io/fire-nearby

fire-nearby (firenearby service front-end) This application is composed of three pages: Map of recent fires Sign up form to receive alerts About this

Mar 30, 2022

TypeScript plugin for service-to-service (aka. "functionless") cloud integrations.

Functionless λ Functionless is a TypeScript plugin that transforms TypeScript code into Service-to-Service (aka. "functionless") integrations, such a

Jan 2, 2023

Sample code of UI projects for SAP BTP Launchpad Service.

SAP BTP Launchpad Service Samples This repository contains the sample projects which are discussed in blog Designing UI5 Apps for SAP Launchpad Servic

Dec 15, 2022

The leaderboard website displays scores submitted by different players. It also allows you to submit your score. All data is preserved thanks to the external Leaderboard API service. Build with Html, CSS, JS, API, and Webpack.

The leaderboard website displays scores submitted by different players. It also allows you to submit your score. All data is preserved thanks to the external Leaderboard API service. Build with Html, CSS, JS, API, and Webpack.

Mar 11, 2022

This application displays scores submitted by different players from an API service. It also allows a user to submit his/her score while saving the data on the API.

Leaderboard This application displays scores submitted by different players from an API service. It also allows a user to submit his/her score while p

Jul 15, 2022
Owner
Jason Dyke
twitter: @jasonadyke
Jason Dyke
This repo contains configurations for webpack, webhint, stylelint and eslint, it is a boiler-plate template and a starting point for coming projects.

Project Name Description the project. Built With Major languages Frameworks Technologies used Live Demo (if available) Experience a live Demo ?? Getti

Adel Guitoun 6 Oct 20, 2022
O projeto MKS Sistemas tem como objetivo o desenvolvimento de uma aplicação em React que utilize endpoint da API de produtos fornecida pela própria MKS Sistemas.

MKS front-end Descrição O projeto MKS Sistemas tem como objetivo o desenvolvimento de uma aplicação em React que utilize endpoint da API de produtos f

Rodrigo William 4 Jul 21, 2022
A button to POST an emoji to an endpoint.

<open-heart> A button for the Open Heart Protocol. ?? Highly experimental. Tag a version to avoid unexpected changes. Usage <!-- Include `OpenHeartEle

ddddddddʣzzz 20 Nov 3, 2022
Custom endpoint to backup the PG database and upload the `.dump` to Directus.

Directus Backup Endpoint Custom Directus endpoint to backup Postgres database using pg_dump and upload the .dump file into Directus files. Usage Clone

Guilherme Oliveira 7 Dec 21, 2022
A plugin for Strapi CMS that adds a preview button and live view button to the content manager edit view.

Strapi Preview Button A plugin for Strapi CMS that adds a preview button and live view button to the content manager edit view. Get Started Features I

Matt Milburn 53 Dec 30, 2022
StarkNet support extension for VSCode. Visualize StarkNet contracts: view storage variables, external and view functions, and events.

StarkNet Explorer extension This VSCode extension quickly shows relevant aspects of StarkNet contracts: Storage variables of the current contract, and

Crytic 6 Nov 4, 2022
⚙️ Monorepo for shared configurations used in Alphaworks

@alpha-dao/shared-config Usage Shared Config Wondering which configuration to use when starting a new project? Then you're probably looking for this m

Alphaworks 8 Nov 17, 2022
An Eleventy wrapper for type supported configurations

Shareable Eleventy configuration strap. The module can be dropped in to your .eleventy.js configuration file for Typed supported configuration options.

ΝΙΚΟΛΑΣ 5 Jun 17, 2022
fcall, fetch and call any remote hot functions, anywhere, anytime, without installations or configurations.

fcall, fetch and call any remote hot functions, anywhere, anytime, without installations or configurations.

立党 Lidang 4 Sep 20, 2022
🚀 A boilerplate with generic configurations to a Nextjs project with bun, vitest, cicd and etc

?? Next.JS Template with Linter ?? Tools: NextJS Typescript ESLint (Code Pattern) Prettier (Formatter) Husky (Pre-commit) Vitest (Unit/Integration Tes

Rodrigo Victor 8 Dec 18, 2022