Terraform GCP
Terraform GCP
Google Cloud
Terraform To create VM
HCL script
run 3 times
Only 1 resource will be created
It will not cost 3 times.
© ANKIT MISTRY – TERRAFORM
Native tool
Cloud Native tool available for infrastructure provisioning
Azure – Template
Google – Deployment manager
AWS - Cloud Formation
JSON/Yaml
Terraform is cloud agnostic.
With Multiple provider, resource can be provisioned for multiple cloud.
Arguments
plan
Creates execution plan
Doesn’t change any infrastructure
apply
execute all changes & provision resource specified in configuration files
variable content {
type = string
resource local_file sample_res { default = "I Love Terraform"
filename = var.filename }
content = var.content
}
export TF_VAR_filename=sample.txt"
output name {
value = random_string.rand_name.id
}
output.tf
provider "local" {
# Configuration options
}
https://www.terraform.io/docs/language/expressions/version-constraints.html
output name1 {
value = data.local_file.foo.content
}
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "3.84.0"
}
}
}
provider "google" {
project, region, zone
}
© ANKIT MISTRY – TERRAFORM
Connect with GCP
Google Provider Configuration
Projectid, zone, region