This repository acts as the location for deploying the infrastructure needed for a gce infrastructure example, satisfying the specification:
- 2 Windows virtual machines hosted in Google Cloud Europe West 2 region
- The virtual machines must be labelled with `environment: test`
- Each virtual machine must have 1 data drive
- IAC must be written in Terraform
- IAC must be reusable to allow deployments to other regions.
- Employees require RDP access from the office IP 80.193.23.74/32
- Port 443 must be open to the internet.
The main file used to achieve this is gce-default.tf.
Runbooks for two use cases can be also found at the runbook directory runbooks
This repo has been strucured to allow for easy deployment to a each region. We achieve this by using terraform's input variables, defined in variables.tf at the root level of the repo.
Looking at this file you can see there are three variables we setup:
project- The target GCP project we wish to deploy our infrastructure to.
- This defaults to our
gce-testproject, but can be overidden with the explicit project you wish for the resources to deploy in.
environment- The working environment for our deployment
- This defaults to our only use case of
testbut can be overidden for any env use case such aspreprodorprod
region- This must be explictly set each time we want to deploy
The values for these variables can be assigned using multiple methods, in this repository we leverage the .tfvars file method:
-
Create a new
.tfvarsfile in theenvironments/directory e.g:gce-eu-west2.tfvars
-
In this file, assign your region:
region = europe-west2Note: If you wish to change environment and project, they can be declared here using the same method.
-
Follow the next steps on running your IAC locally:
-
Ensure you have terraform installed on your machine
-
To initialise your working directory, first run
terraform initinitcommand documentation can be found here
-
Next, create your execution plan by running
terraform plan-
Target your enviroment specific tfvars file by appending the
-var-fileflag to your plan command e.g.:terraform plan -var-file=./environments/gce-eu-west2.tfvars -
plancommand documentation can be found here
-
-
Finally, once satisfied with the changes to your infrastrucure outlined in the plan, action your
planby runnningterraform apply-
Equally with the apply command, target your enviroment specific tfvars file by appending the
-var-fileflag to your apply command e.g.:terraform apply -var-file=./environments/gce-eu-west2.tfvars -
applycommand documentation can be found here
-