GCP Free Tier

Terraform modules that provisions cloud resources within the Google Cloud Platform (GCP) Free Tier limits.

DISCLAIMER: The author of this project does not guarantee that you will not incur charges with GCP if you use this project.

Prerequisites

Create a GCP account and project at https://console.cloud.google.com.

In that project, creat a Service Account for the project with the following roles attached:

  • Compute Public IP Admin
  • Compute Instance Admin
  • Compute Network Admin
  • Compute Security Admin
  • Monitoring Admin

Required Terraform credentials/environment variables

Set the following environment variables for the google Terraform provider:

Full Example

See examples.tf for example implementations of all the modules.

In addition to the environment variables listed above, the examples expect the following env vars:

  • TF_VAR_GCE_ZONE
  • TF_VAR_SSH_PUBKEY_FILE
  • TF_VAR_SSH_USER
  • TF_VAR_NOTIFICATION_CHANNEL_NAME (Optional; set if you want to receive alerts when on track to exceed free tier thresholds)

Modules

Compute

Provisions an f1-micro Google Compute Cloud instance that can run 24x7 while not incurring charges. Be aware that there are data transfer limits in order to stay in the free tier.

This instance has firewall rules that allow inbound traffic for SSH (port 22), HTTP/HTTPS (ports 80 and 443), and DNS (port 53)

This module requires the following variables provided to it:

  • gce_zone - A zone in the region you've configured in GOOGLE_REGION; usually ${GOOGLE_REGION}-a (or -b or -c).
  • gce_ssh_pubkey_file - A public SSH key used to connect to the instance
  • gce_ssh_user - Your SSH user