GCP Deployment Manager
Relevant source files
The following files were used as context for generating this wiki page:
- packages/gcp-deployment-manager/README.md
- packages/gcp-deployment-manager/package.json
- packages/gcp-deployment-manager/project.json
- packages/gcp-deployment-manager/src/generators/init/schema.json
- e2e/gcp-deployment-manager-e2e/tests/gcp-deployment-manager.spec.ts
- packages/gcp-deployment-manager/generators.json
GCP Deployment Manager is an Nx plugin that deploys Google Cloud resources using the Google Cloud Deployment Manager service. It allows developers to treat infrastructure as code by using YAML or Python templates within an Nx workspace.
The plugin provides tools to manage the resource lifecycle, including initialization of new deployment projects and the execution of deployment commands. It integrates with other Google Cloud Platform plugins in the nx-extend ecosystem, such as @nx-extend/gcp-cloud-run and @nx-extend/gcp-functions.
Sources: packages/gcp-deployment-manager/README.md:1-12, README.md:27-31
Key Features
The module supports the following core functionalities for infrastructure management:
- Infrastructure as Code: Utilizes YAML or Python templates for resource definitions.
- Lifecycle Management: Handles the creation and update of Google Cloud resources.
- Nx Integration: Provides generators and executors to run deployments as standard Nx tasks.
- Preview Support: Allows users to preview deployment changes before applying them.
Sources: packages/gcp-deployment-manager/README.md:14-19, packages/gcp-deployment-manager/CHANGELOG.md:197-199
Workflow Architecture
The plugin follows a standard Nx plugin architecture, separating project initialization (generators) from task execution (executors).
The diagram shows the flow from initial project generation to final deployment on Google Cloud.
Sources: packages/gcp-deployment-manager/README.md:23-28, e2e/gcp-deployment-manager-e2e/tests/gcp-deployment-manager.spec.ts:16-22
Project Initialization
To set up a new deployment project, you use the init generator. This process creates the necessary configuration files, including a default src/deployment.yml file used for defining resources.
Initialization Options
| Name | Type | Description |
|---|---|---|
name | string | The name of the deployment project. |
project | string | The specific GCP project ID for the deployment. |
directory | string | The workspace directory where the project is placed. |
tags | string | Tags used for project linting and organization. |
Sources: packages/gcp-deployment-manager/src/generators/init/schema.json:7-34, e2e/gcp-deployment-manager-e2e/tests/gcp-deployment-manager.spec.ts:18-21
Deployment Execution
The plugin facilitates deployment through the deploy target. This target triggers the underlying GCP Deployment Manager APIs to create or update resources based on the provided configuration file.
Execution Options
| Option | Type | Default | Description |
|---|---|---|---|
project | string | - | Target GCP project ID. |
file | string | - | The source configuration file (YAML/Python) to use. |
name | string | - | Internal name of the resource in Google Cloud. |
Sources: packages/gcp-deployment-manager/README.md:32-43, packages/gcp-deployment-manager/CHANGELOG.md:209-211
Project Structure and Configuration
A project configured with this plugin is defined as a library in the Nx workspace. It includes standard targets for maintenance and distribution.
The class diagram represents the logical structure of a Deployment Manager project within the Nx workspace.
Sources: packages/gcp-deployment-manager/project.json:1-12, packages/gcp-deployment-manager/package.json:13-17
Standard Targets
- build: Uses
@nx/js:tscto compile the plugin source. - lint: Validates TypeScript files using ESLint.
- test: Executes unit tests via Jest.
- publish: Runs
npm publishfor the compiled package distribution.
Sources: packages/gcp-deployment-manager/project.json:13-72
Summary
GCP Deployment Manager provides a structured approach to managing Google Cloud infrastructure within an Nx monorepo. By leveraging YAML/Python templates and integrating with Nx executors, it ensures that infrastructure changes are version-controlled, testable, and easily deployable alongside application code.
Sources: packages/gcp-deployment-manager/README.md:7-12, README.md:5-9