Skip to main content

GCP instance

A GCP Go Pulumi to create an instance

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set gcp-go-instance
cd pulumi-examples/gcp-go-instance

Create a GCP instance using Pulumi and Go.

Prerequisites#

  1. Install Pulumi
  2. Configure GCP credentials
  3. Install Go

Deploying the example#

  1. Create a new stack:

    Terminal window
    pulumi stack init dev
  2. Configure the project:

    Terminal window
    pulumi config set gcp:project YOURGOOGLECLOUDPROJECT
    pulumi config set gcp:zone us-central1-a
  3. Install dependencies:

    Terminal window
    go mod download
  4. Run pulumi up to preview and deploy changes:

    Terminal window
    pulumi up
    Updating (dev):
    Type Name Status
    + pulumi:pulumi:Stack gcp-instance created
    + └─ gcp:compute:Instance instance created
    Outputs:
    instanceName: "instance-6beb431"
    Resources:
    + 2 created
    Duration: 23s

Cleaning up#

Once you’re finished experimenting, destroy your stack and remove it:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.