GC-301e · Module 3
Pulumi & Deployment Automation
3 min read
Pulumi uses real programming languages — TypeScript, Python, Go — instead of HCL for infrastructure definitions. This aligns naturally with Gemini CLI's code generation strengths. When you ask Gemini to generate infrastructure code in TypeScript, it produces the same typed, IDE-friendly code it generates for application logic. Pulumi with Gemini CLI feels more like writing application code than configuring infrastructure, which lowers the cognitive barrier for developers who are not infrastructure specialists.
Deployment automation with Gemini CLI extends beyond resource provisioning. Gemini can orchestrate full deployment pipelines: run tests, build container images, push to Artifact Registry, update Terraform/Pulumi state, deploy to Cloud Run, verify health checks, and roll back if checks fail. The entire pipeline lives in a single conversational session. If a step fails, Gemini can diagnose the failure, suggest a fix, and retry — without the developer writing pipeline YAML.
import * as gcp from "@pulumi/gcp";
import * as pulumi from "@pulumi/pulumi";
const config = new pulumi.Config();
// Cloud Run service with auto-scaling
const service = new gcp.cloudrunv2.Service("api", {
location: "us-central1",
template: {
containers: [{
image: config.require("containerImage"),
resources: {
limits: { cpu: "1", memory: "512Mi" },
},
envs: [{
name: "DATABASE_URL",
valueSource: {
secretKeyRef: {
secret: dbSecret.secretId,
version: "latest",
},
},
}],
}],
scaling: {
minInstanceCount: 1,
maxInstanceCount: 10,
},
},
});
// IAM — allow unauthenticated access
const invoker = new gcp.cloudrunv2.ServiceIamMember("invoker", {
name: service.name,
location: service.location,
role: "roles/run.invoker",
member: "allUsers",
});
export const serviceUrl = service.uri;