This is Terraform code to setup a compute instance on Google Cloud.
You get a compute instance with 1vCPU, 1GB RAM and 30GB storage out of which is 2GB Swap space
Yes, it is free of cost as per Google's Free Forever tier.
- Clone this repo locally, and create a Project on Google Console
- Download JSON credentials from your service account. See here.
- Add the json file as
creds.json
in root folder of this repo, and copyterraform.tfvars.example
toterraform.tfvars
- Create a ssh key pair using:
ssh-keygen
- You can find the location of your public key from the output of
ssh-keygen
. See Line 7 in the output like in this image: - Update the values and add your public key to the
.tfvars
file
Do terraform apply
- Terraform would output the
external_ip
of the instance on successful apply. - Now you may use the same IP adreess to ssh:
ssh user@external_ip
Do terraform destroy
Feel free to improve this with a PR or raise an issue.