https://github.com/tomarv2/terraform-google-vm
Terraform module for GCP Virtual Machine
https://github.com/tomarv2/terraform-google-vm
google-cloud-platform google-vm terraform terraform-module
Last synced: about 1 year ago
JSON representation
Terraform module for GCP Virtual Machine
- Host: GitHub
- URL: https://github.com/tomarv2/terraform-google-vm
- Owner: tomarv2
- License: apache-2.0
- Created: 2021-02-20T20:22:19.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-03-01T04:20:30.000Z (over 4 years ago)
- Last Synced: 2025-03-22T15:49:52.925Z (about 1 year ago)
- Topics: google-cloud-platform, google-vm, terraform, terraform-module
- Language: HCL
- Homepage:
- Size: 66.4 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Terraform module to create Google Virtual Machine
## Versions
- Module tested for Terraform 1.0.1.
- GCP provider version [4.11.0](https://registry.terraform.io/providers/hashicorp/google/latest).
- `main` branch: Provider versions not pinned to keep up with Terraform releases.
- `tags` releases: Tags are pinned with versions (use
).
## Usage
### Option 1:
```
terrafrom init
terraform plan -var='teamid=tryme' -var='prjid=project1'
terraform apply -var='teamid=tryme' -var='prjid=project1'
terraform destroy -var='teamid=tryme' -var='prjid=project1'
```
**Note:** With this option please take care of remote state storage
### Option 2:
#### Recommended method (stores remote state in S3 using `prjid` and `teamid` to create directory structure):
- Create python 3.8+ virtual environment
```
python3 -m venv
```
- Install package:
```
pip install tfremote --upgrade
```
- Set below environment variables:
```
export TF_GCLOUD_BUCKET=
export TF_GCLOUD_PREFIX=
export TF_GCLOUD_CREDENTIALS=
```
- Updated `examples` directory with required values.
- Run and verify the output before deploying:
```
tf -c=gcloud plan -var='teamid=foo' -var='prjid=bar'
```
- Run below to deploy:
```
tf -c=gcloud apply -var='teamid=foo' -var='prjid=bar'
```
- Run below to destroy:
```
tf -c=gcloud destroy -var='teamid=foo' -var='prjid=bar'
```
**NOTE:**
- Read more on [tfremote](https://github.com/tomarv2/tfremote)
---
### Virtual Machine
```
module "vm" {
source = "git::git@github.com:tomarv2/terraform-google-vm.git"
user_data_file_path = "user_data.sh"
# --------------------------------------------------
# Do not change the teamid, prjid once set.
teamid = var.teamid
prjid = var.prjid
}
```
Please refer to examples directory [link](examples) for references.