The repository contains a Python script that converts YAML generated by a Config Connector bulk export into JSON suitable for use with the pulumi import
command. The code in this repository was written to accompany the blog post Google Cloud: Bulk Importing Resources into Pulumi.
This code should be considered proof-of-concept. A small percentage of Goolge Cloud resource types are supported. However, mapping new resource types is relatively straightforward. See the blog post for details.
-
Install the Config Connector CLI (instructions). Note that you do not need to a Kubernetes cluster or the Config Connector CRD - just the CLI.
-
Export your resources to a YAML file, e.g.:
config-connector bulk-export --project YOUR-GOOGLE-CLOUD-PROJECT-ID --output config-connector-export.yaml --iam-format policymember --on-error continue
-
Clone this repository, initialize any virtual environments, download dependencies, and run the following command:
cd config-connector-transform python3 main.py -i path/to/config-connector-export.yaml -o path/to/pulumi/target/project/pulumi-import.json -p YOUR-GOOGLE-CLOUD-PROJECT-ID
-
In your Pulumi project, bulk import the resources, e.g.:
pulumi import -f pulumi-import.json -y -s dev -o index.ts
The pulumi import
command will automatically detect the correct language for your project, so substitute this value appropriately, e.g. main.go
, __main__.py
, etc.
Pull requests and issue submissions are welcome!
We don't have a comprehensive test bench yet, but including a sample Pulumi program to generate any infrastructure that your pull request addresses would be helpful. (If this repo generates sufficient interest we'll add a proper pipeline and integration tests.)