Skip to content

Latest commit

 

History

History
101 lines (67 loc) · 4.95 KB

01a_gcp_project_setup_as_code.md

File metadata and controls

101 lines (67 loc) · 4.95 KB

GCP Project Setup as a code

This guide will walk you through how to use the provided terraform scripts to have the project and required settings created and set for you.

Prerequisites

You will need:

  • The Project Creator GCP role and a suitable Billing Account.
  • A valid Looker License Key - please work with your GCP account team if you do not have one.
  • The gcloud command line tool installed.
  • Terraform installed. Ensure version is >= 1.3.0
  • A web domain suitable for development - Google Domains is an excellent choice for registering such a domain if you don't already have one.

Deploy the required infrastructure

Navigate to the terraform/project_creation folder

Step 1: Create your terraform.tfvars file

A minimal example might look something like this:

project_id           = "gcp-project-id"
parent               = "organizations/parent_org_id"
location             = "europe-west3"
sa_name              = "your-service-account-name"
email_address        = "you@example.com"
dns_domain           = "your-dns-domain."
billing_account      = "your-billing-account-id"

Variable definitions are as follows:

Name Description Default
project_id Your GCP Project ID
parent Your projects parent
location Your projects region
repository_id Artifact registry repository name where looker images are stored looker
sa_name Service accounts name that will be created with all the required permissions
email_address Username that will impersonate the created service account see step highlighted here
dns_domain Your DNS domain
billing_account The billing account the project will be tied to

Step 2: Deploy the infrastructure

  1. You will need to initialize Terraform before applying - you will only need to do this once. Execute the following command:
$ terraform init
  1. Next, run the plan to make sure your configuration is valid. Execute the following command:
$ terraform plan
  1. If your plan comes back successfully it is time to deploy! Execute the following command:
$ terraform apply

The deployment will take around 5-10 minutes. Please take note of the outputs as they contain important information.

Step 3: Populate the secrets

While deploying the project, we created three secrets which will be used in the coming steps. These secrets need to have appropriate values created for them. Either Navigate to the secret manager in the Google Cloud console or use gcloud to give each secret their value:

  1. A strong password - Used as a password for Looker's MySQL account. This password should include only alphanumeric characters - no special characters!
  2. Your Looker License Key
  3. A GCM Encryption Key - This can be generated by running the command openssl rand -base64 32. See Looker's encryption documentation for more details.

It was opted to not add the values while deploying as code. This would be possible, but requires the secret values to be stored in your vars file and Terraform state which is not recommended.

Note: If you use gcloud it is a best practice to take steps to avoid logging the commands in your bash history. Typically the easiest way to accomplish this is to add a space at the beginning of your shell command.

Step 4: Configure your Domain Name Servers

You will need to configure your development domain to use Cloud DNS's name servers. The exact procedure will depend on which domain registrar you use - see Cloud DNS documentation for more details. The correct nameserver values to use are included in the module's outputs.

Install Required Software

Let's get the rest of the software stack installed in your development environment. See below for links to installation instructions for each tool.

  1. Terraform. Ensure version is >= 1.3.0
  2. Kubectl
  3. Helm. Ensure version is >= 3.8.0

If you want to make use of VM-based Looker instances (Not Recommended) then you will need to also install the following tools:

  1. Packer
  2. Ansible (Note that Ansible requires Python)

Further information/ToDo

  • The provided script really is the minimal way to configure this using pre-existing modules from the cloud foundation fabric
  • To move more towards production, the tfstate should be stored remotely