Review the New Project

Let’s review some of the generated project files:

  • Pulumi.yaml defines the project.
  • Pulumi.dev.yaml contains configuration values for the stack we initialized.
  • index.jsindex.ts__main__.pymain.goProgram.csProgram.fsProgram.vb is the Pulumi program that defines our stack resources. Let’s examine it.
"use strict";
const pulumi = require("@pulumi/pulumi");
const gcp = require("@pulumi/gcp");

// Create a GCP resource (Storage Bucket)
const bucket = new gcp.storage.Bucket("my-bucket");

// Export the DNS name of the bucket
exports.bucketName = bucket.url;
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

// Create a GCP resource (Storage Bucket)
const bucket = new gcp.storage.Bucket("my-bucket");

// Export the DNS name of the bucket
export const bucketName = bucket.url;
import pulumi
from pulumi_gcp import storage

# Create a GCP resource (Storage Bucket)
bucket = storage.Bucket('my-bucket')

# Export the DNS name of the bucket
pulumi.export('bucket_name',  bucket.url)
using System.Collections.Generic;
using System.Threading.Tasks;
using Pulumi;
using Pulumi.Gcp.Storage;

class Program
{
    static Task Main()
    {
        return Deployment.RunAsync(() =>
        {
            // Create a GCP resource (Storage Bucket)
            var bucket = new Storage.Bucket("my-bucket");

            // Export the DNS name of the bucket
            return new Dictionary<string, object> {
                { "bucket_name", bucket.Url },
            };
        });
    }
}

This Pulumi program creates a storage bucket and exports the bucket URL.

For Python, before we deploy the stack, the following commands need to be run to create a virtual environment, activate it, and install dependencies:

$ virtualenv -p python3 venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt

Next, we’ll deploy the stack.