Skip to main content

Search the Dev Center

Search tutorials, templates, examples, and more.

Web server on Google Compute Engine, written in HCL

A simple web server on a Google Compute Engine instance, written in HCL

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-hcl-webserver
cd pulumi-examples/gcp-hcl-webserver

A simple web server running on a Google Compute Engine instance, written in Pulumi HCL. Pulumi installs the HCL language plugin and the Terraform Google provider automatically the first time you run the program.

Prerequisites#

  1. Install Pulumi
  2. Configure GCP credentials

Deploying the example#

  1. Create a new stack:

    Terminal window
    pulumi stack init dev
  2. Set the project and zone to deploy into:

    Terminal window
    export GOOGLE_PROJECT=my-project
    export GOOGLE_ZONE=us-central1-a
  3. Run pulumi up to preview and deploy changes. After the preview is shown, you will be prompted to continue:

    Terminal window
    pulumi up
  4. Curl the HTTP server. The instance may take a minute to boot and start serving after the deployment finishes:

    Terminal window
    curl $(pulumi stack output instance_ip)
    Hello, World!

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.