Skip to content

Matarp13/port-gcp-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Port GCP Exporter

This GCP Function is written in Python and is used to retrieve information about services in your GCP project, and report it to your Port application.

For your comfort, in the Terraform directory you can find a Terraform automation to setup everything in your gcp project.

Note: This function currently only supports Scheduled-base function and gets information about:

  • Pub/Sub Topics
  • Buckets
  • VM Instances

How Does it work?

Function Startup

In Google Cloud Platform, Functions can be triggred by multiple mechanisms. In our case, We have a GCP Scheduler triggering events to a GCP Topic. The function is subscribed to the same GCP Topic, so whenever the Scheduler triggers an event to the topic, the function is being invoked.

Function Workflow

  1. Pulls a config file with the resources and attributes we want to export to Port
  2. Pulls to Port's credentials saved in your project Secrets
  3. Uses Google Cloud Asset Inventory API to read and map the resources in your GCP Project.
  4. Report the relevant resources to Port using Port's REST API.

For addition information about configuration see the config file explenation in Ports AWS exporter docs

Prerequisites

In order to use this GCP Function, you will need to have the following:

  • A Google Cloud project - you can create a free account on the GCP website.
  • A Google Cloud account with permission for creating GCP functions, GCP Scheduler and GCP Pub/Sub Topics
  • Install Terraform on your environment
  • Install the gcloud cli and configure it to your relevant project
  • Make sure you have GOOGLE_APPLICATION_CREDENTIALS environment variable saved and point to a file with your GCP creation account key.
  • Find your Port credentials for the function to connect with Port's REST API and save them as secrets in your Google Cloud project
  • Create a Google Service Account , and assign it the following permission:
    • Cloud Asset Viewer
    • Pub/Sub Viewer
    • Secret Manager Secret Accessor
    • Storage Object Viewer
  • A config file defining the resources and attributes you want to export - see example in examples/config.py The config file need to be saved in a Bucket in your project
  • A GCP Source Repository containing this Git repo (You can mirror this repo directly instead of fork it and copy)

Note: First time running the function you might need to enable some APIS in your google account, so make sure to follow the logs in order to see what API is disabled

Terraform Configuration

In the terraform directory, you can find a Terraform configuration file (main.tf) and a variables file (vars.tf) for setting up the GCP function.

To run the Terraform configuration, navigate to the terraform directory and:

  1. Set the variables in vars.tfvars with your project (Make sure all the required are filled)
  2. Run terraform init to initialize the Terraform configuration.
  3. Run terraform plan to preview the changes that will be made.
  4. Run terraform apply to apply the changes and deploy the function to GCP.

Additional Information

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published