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:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set gcp-hcl-webservercd pulumi-examples/gcp-hcl-webserverA 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#
-
Create a new stack:
Terminal window pulumi stack init webserver-testing -
Configure your GCP credentials and set the project and zone to deploy into:
Terminal window export GOOGLE_PROJECT=my-projectexport GOOGLE_ZONE=us-central1-a -
Run
pulumi upto preview and deploy changes. After the preview is shown you will be prompted if you want to continue or not. -
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.
-
To clean up resources, run
pulumi destroyand answer the confirmation question at the prompt.