0.2.4 • Published 8 months ago

@backtostage/plugin-catalog-backend-module-gcp v0.2.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

Catalog Backend Module for GCP

This is an extension module to the plugin-catalog-backend plugin, providing extensions targeted at GCP.

Getting started

You will have to add the provider in the catalog initialization code of your backend. They are not installed by default, therefore you have to add a dependency on @backtostage/plugin-catalog-backend-module-gcp to your backend package.

# From your Backstage root directory
yarn add --cwd packages/backend @backtostage/plugin-catalog-backend-module-gcp

Cloud SQL - GoogleSQLDatabaseEntityProvider

To your new backend file, add:

import { catalogModuleGoogleSQLDatabaseEntityProvider } from '@backtostage/plugin-catalog-backend-module-gcp';


backend.add(
  catalogModuleGoogleSQLDatabaseEntityProvider,
);

Memorystore Redis - GoogleRedisDatabaseEntityProvider

To your new backend file, add:

import { catalogModuleGoogleRedisDatabaseEntityProvider } from '@backtostage/plugin-catalog-backend-module-gcp';


backend.add(
  catalogModuleGoogleRedisDatabaseEntityProvider,
);

Project - GoogleOrganizationProjectEntityProvider

To your new backend file, add:

import { catalogModuleGoogleOrganizationProjectEntityProvider } from '@backtostage/plugin-catalog-backend-module-gcp';


backend.add(
  catalogModuleGoogleOrganizationProjectEntityProvider,
);

Configuration

To use this provider, you'll need a Google Service Account. Once generated, store the path to this file in the GOOGLE_APPLICATION_CREDENTIALS environment variable.

You can find more details about this in the official docs

Then you can add a gcp config to the catalog providers configuration:

catalog:
  providers:
    gcp:
      # the project id need to be the GCP Project where your Resources are present
      - project: my-gcp-project-id
        ownerLabel: team # string
        componentLabel: app # string
        cloudsql:
          resourceType: SQL  # string
          suffix: sql  # string
          disabled: true # boolean
        redis:
          resourceType: Redis  # string
          location: us-central1 # string
          suffix: memorystoreredis  # string
          disabled: true # boolean
        schedule: # same options as in TaskScheduleDefinition
          # supports cron, ISO duration, "human duration" as used in code
          frequency: { minutes: 30 }
          # supports ISO duration, "human duration" as used in code
          timeout: { minutes: 3 }
      # you can configure a organization too. If the project is provided, this config will be skipped
      - organization:
          query: "parent:organizations/XPTO"
          resourceType: Project
        schedule: # same options as in TaskScheduleDefinition
          # supports cron, ISO duration, "human duration" as used in code
          frequency: { minutes: 30 }
          # supports ISO duration, "human duration" as used in code
          timeout: { minutes: 3 }

This provider supports multiple projects using different configurations.

  • project (required when not using organization import): Project ID of the project for which to list Cloud SQL instances. You can omit that field if you want the provider to load all projects in your organization to load other resources.
  • organization (optional):

    • query (optional):

      • Default: Query param to Google API
      • You can narrow the search based in your needs. When not provided a empty value is used. Please follow the API format to configure this param
    • resourceType (optional):

      • Default: GCP Project.
      • The provider will set the type based in this information.
    • disabled (optional):

      • Default: false.
      • The entity provider will skip this configuration when disabled.
  • ownerLabel (optional):

    • Default: owner.
    • The provider will look for user defined labels to find the Resource Owner.
    • You can provide the label name where the owner name is present, if the label isn't present the owner will be set unknown.
  • componentLabel (optional):
    • Default: component.
    • The provider will look for user defined labels to find the Resource dependencyOf.
    • You can provide the label name where the component name is present, if the label isn't present dependencyOf will be skipped.
  • cloudsql (optional):

    • resourceType (optional):
      • Default: CloudSQL.
      • The provider will set the type based in this information.
    • suffix (optional):
      • Default: cloudsql.
      • The provider will set the suffix to create a unique name for this resource.
    • disabled (optional):
      • Default: false.
      • The entity provider will skip this configuration when disabled.
    • namespaceByProject (optional):
      • Default: false.
      • The entity provider will use the project in namespace field. The namespace default is used when nothing is defined in this config.
  • redis (optional):

    • resourceType (optional):
      • Default: Memorystore Redis.
      • The provider will set the type based in this information.
    • suffix (optional):
      • Default: redis.
      • The provider will set the suffix to create a unique name for this resource.
    • location (optional):
      • Default: Wildcard value to Google API
      • You can narrow the location to list. When not provided instances from all locations will be listed
    • disabled (optional):
      • Default: false.
      • The entity provider will skip this configuration when disabled.
    • namespaceByProject (optional):
      • Default: false.
      • The entity provider will use the project in namespace field. The namespace default is used when nothing is defined in this config.
  • schedule (required):
    • frequency: How often you want the task to run. The system does its best to avoid overlapping invocations.
    • timeout: The maximum amount of time that a single task invocation can take.
    • initialDelay (optional): The amount of time that should pass before the first invocation happens.
    • scope (optional): 'global' or 'local'. Sets the scope of concurrency control.