How do I create and configure a GCP project using Pulumi?
In this guide, we will create and configure a Google Cloud Platform (GCP) project using Pulumi. We will define a new project resource, set up some basic properties, and ensure it’s ready for use with other GCP services.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
// Define a new GCP project
const project = new gcp.organizations.Project("my-gcp-project", {
name: "my-gcp-project",
projectId: "my-unique-project-id",
orgId: "your-organization-id",
billingAccount: "your-billing-account-id",
labels: {
environment: "dev",
team: "pulumi",
},
});
// Export the project ID and name
export const projectId = project.projectId;
export const projectName = project.name;
Key Points
- We use the
gcp.organizations.Project
resource to create a new GCP project. - The
name
,projectId
,orgId
, andbillingAccount
properties are required to define the project. - Labels are added to help with the organization and management of the project.
- The project ID and name are exported for use in other parts of your Pulumi stack.
Summary
We created and configured a GCP project using Pulumi. This setup includes defining the project with necessary properties like name, project ID, organization ID, and billing account. Labels were added for better management, and the project ID and name were exported for further use.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.