This repository sets up Virtual Machines in Google Cloud Platform for man7.org training. This terraform module will output
- Private key (RSA PEM encoded) for the user account (default username
tux
). - Password for the user account (default username
tux
). - SSH commands via key and password.
- SSH command to access Serial Console. This is needed to access GRUB menu or debug VM at boot time if needed.
- Saves the Terraform state file in a bucket in your project.
- A wrapper shell script
./tf.sh
which automatically downloads Terraform binary and sets up your environment etc. - Updates GRUB config for the machine.
- Installs all the relevant tools (Ubuntu only).
- Create a new project in GCP or use an existing one. Note down the Project ID and update the variable
project-id
in./variables.tf
. You may need to enable Compute Engine API if you are creating a new project. - Create a bucket with a unique name and update
backend.tf
variablebucket
. This is because backend definition does not allow interpolation. :( - Create a service account with
Editor
andOwner
permissions for Terraform. Default name for the account isterraform
. - Create a key pair for the above service account and save it in
./credentials/key.json
. - Also, save the key inside the heredoc in
./credentials/secret.auto.tfvars
by pasting the JSON document between theEOF
s heredoc.
Use the private RSA key and the serial console command to SSH into serial console in a separate terminal window.
Rebooting Virtual Machine and immediately switching to the serial console and pressiing SHIFT key will get you GRUB menu.
$ ./tf.sh init
$ ./tf.sh graph | dot -Tpng > graph.png
$ /tf.sh plan
$ ./tf.sh apply