Pulumi Google Cloud (GCP) Provider

9.19.0 · active · verified Mon Apr 13

The `pulumi-gcp` Python package provides a robust interface for defining, deploying, and managing Google Cloud Platform resources using infrastructure-as-code principles. It leverages the Pulumi CLI and Python language to offer programmatic control over GCP services. Currently at version 9.19.0, it is actively maintained with frequent releases that often include updates to align with upstream Terraform provider changes and new GCP features.

Warnings

Install

Imports

Quickstart

This quickstart program creates a Google Cloud Storage bucket. Before running, ensure you have the Pulumi CLI installed, are authenticated to GCP via `gcloud auth application-default login`, and have run `pulumi new gcp-python` to set up a project. You may need to set the `gcp:project` configuration value using `pulumi config set gcp:project <YOUR_GCP_PROJECT_ID>` or set the `GCP_PROJECT_ID` environment variable.

import pulumi
from pulumi_gcp import storage
import os

# Configure the GCP project ID (replace with your project ID or set via pulumi config)
# pulumi config set gcp:project my-gcp-project-id
project_id = os.environ.get('GCP_PROJECT_ID') or pulumi.Config('gcp').get('project')

# Create a GCP Storage Bucket
# Note: Bucket names must be globally unique.
bucket = storage.Bucket(
    'my-unique-bucket-name',
    project=project_id, # Ensure project_id is configured or passed
    location='US-CENTRAL1', # Specify a region or multi-region
    uniform_bucket_level_access=True # Recommended best practice for security
)

# Export the bucket's self_link and URL
pulumi.export('bucket_self_link', bucket.self_link)
pulumi.export('bucket_url', bucket.url)

view raw JSON →