Skip to content

GCP.ServiceUsage reference

Source: src/GCP/ServiceUsage/ProjectService.ts

Enables a Google Cloud API for a project — the GCP analog of a Terraform google_project_service.

Service Usage has no per-caller ownership marker, so an API that is already enabled (by another stack, the console, or a dependent service) is adopted as-is. By default destroy only releases Alchemy state and leaves the API enabled. Set disableOnDestroy only for APIs this stack alone relies on: it disables the API project-wide, even if it was enabled before this stack adopted it.

Enable Compute Engine before creating a network

const computeApi = yield* GCP.ServiceUsage.ProjectService("ComputeApi", {
service: "compute.googleapis.com",
});

Disable the API on destroy

yield* GCP.ServiceUsage.ProjectService("TranslateApi", {
service: "translate.googleapis.com",
disableOnDestroy: true,
});