Skip to main content

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.

Deploying and running the program#

  1. Create a new stack:

    Terminal window
    pulumi stack init webserver-testing
  2. Configure your GCP credentials and 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 if you want to continue or not.

  4. Curl the HTTP server:

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

    The instance may take a minute to boot and start serving after the deployment finishes.

  5. To clean up resources, run pulumi destroy and answer the confirmation question at the prompt.

Related

The infrastructure as code platform for any cloud.