/gcp-nginx-helloworld

Simple private network for Nginx hacking

Primary LanguageHCL

GCP Starter Project

This repo gets you up and running in GCP.

  • Creates a minimal network and subnet
  • Creates a Cloud NAT for egress to the internet
  • Creates two small VM's to test HTTP requests

Setup

  1. Create a GCP Project

    1. While it's possible to Terraform the project itself, the attachment of the billing account doesn't propagate in time and results in a mess of null resource dependencies and sleeping...

    2. ...with that said, create a new GCP Project using the web console

    3. Make sure you set the billing account and folder

  2. Install the gcloud CLI

  3. Install Terraform

  4. Clone this repo

  5. Initialize terraform init

  6. Login using the CLI gcloud auth application-default login. Alternatively you can authenticate as a service account.

Create the Infrastructure

This will deploy all the resources in main.tf.

  1. Edit terraform.tfvars to include your project id and desired settings.

  2. Deploy your infrastructure

    terraform plan
    terraform apply
    
  3. SSH to the consumer instance using IAP tunneling

    gcloud compute ssh nginx-consumer
    
  4. Make a request to the Nginx web server, you should see some HTML as a result that has Thank you for using nginx in it.

    curl nginx
    
    exit
    
  5. You can now SSH to the Nginx web server and edit configs as needed.

     gcloud compute ssh nginx