Cloud engineering on Google Cloud
Pulumi’s infrastructure as code SDK helps create, deploy, and manage Google Cloud Platform containers, serverless functions, and infrastructure using real programming languages.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const bucket = new gcp.storage.Bucket("bucket", {
location: "US",
});
export const bucketName = bucket.url;
The benefits of using Pulumi
Tame cloud complexity
Deliver infrastructure from hundreds of cloud and SaaS providers. Pulumi’s SDKs provide a complete and consistent interface that offers full access to clouds and abstracts complexity.
Bring the cloud closer to application development
Build reusable cloud infrastructure and infrastructure platforms that empower developers to build modern cloud applications faster and with less overhead.
Use engineering practices with infrastructure
Replace inefficient, manual infrastructure processes with automation. Test and deliver infrastructure through CI/CD workflows or automate deployments with code at runtime.
Foster collaboration and innovate faster
Unite infrastructure teams, developers, and security teams around shared languages and tools so that everyone can ship products quickly and reliably.
Reduce your complexity with shared packages
Pulumi components let you define Google Cloud best practices once and reuse them everywhere. Wrap a Cloud Run service, its IAM bindings, and your organization’s defaults in a single component, then share it as a package that teammates can consume in the language of their choice, regardless of the language you authored it in.
Follow the component authoring guide to build and publish your own.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
interface PublicServiceArgs {
location: pulumi.Input<string>;
image: pulumi.Input<string>;
}
// A reusable component: a Cloud Run service that anyone can invoke.
class PublicService extends pulumi.ComponentResource {
public readonly url: pulumi.Output<string>;
constructor(name: string, args: PublicServiceArgs, opts?: pulumi.ComponentResourceOptions) {
super("acme:gcp:PublicService", name, {}, opts);
const service = new gcp.cloudrunv2.Service(name, {
location: args.location,
template: { containers: [{ image: args.image }] },
deletionProtection: false,
}, { parent: this });
new gcp.cloudrunv2.ServiceIamMember(`${name}-invoker`, {
name: service.name,
location: service.location,
role: "roles/run.invoker",
member: "allUsers",
}, { parent: this });
this.url = service.uri;
this.registerOutputs({ url: this.url });
}
}
const hello = new PublicService("hello", {
location: "us-central1",
image: "us-docker.pkg.dev/cloudrun/container/hello",
});
export const url = hello.url;
Create your own GKE cluster
Pulumi supports programming against Kubernetes — Minikube, custom on-premises, or cloud-hosted custom clusters or in managed clusters such as Google GKE. This code defines a GKE cluster with configurable settings that could be packaged in a module and then used to deploy an app to the cluster.
import * as gcp from "@pulumi/gcp";
import * as k8s from "@pulumi/kubernetes";
import * as pulumi from "@pulumi/pulumi";
const name = "demo";
const engineVersion = gcp.container.getEngineVersions().then(v => v.latestMasterVersion);
const cluster = new gcp.container.Cluster(name, {
initialNodeCount: 2,
minMasterVersion: engineVersion,
nodeVersion: engineVersion,
nodeConfig: {
machineType: "n1-standard-1",
oauthScopes: [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
],
},
});
export const clusterName = cluster.name;
Need help with Google Cloud?
Learn how top engineering teams are using Pulumi’s SDK to create, deploy, and manage Google Cloud resources.
Get started with Pulumi and Google Cloud
Deploy your first Google Cloud project in minutes. Follow our quickstart guide, or talk to our team about your specific needs.