Learning history and files of Terraform for Beginners using GCP - Google Cloud (Hands-on) from Udemy
- https://www.udemy.com/course/terraform-for-beginners-using-google-cloud/
- https://github.com/ankit25587/course-material/tree/main/05-terraform-for-beginners-using-google-cloud
- Below is just work note of my learning ;)
- scope
- author
- initialize
- plan
- apply
- VSCode extension
- install it
- Local provider
https://registry.terraform.io/providers/hashicorp/local/2.2.3
- Multiple resource in one main.tf
- File: multiple-resources
- to use variable instead of hardcorded value
- File: variables
string – “cat”
number – 234, 6.5
bool - true/false
list – sequence of value
list(string) =>[“red”, “green”, “blue”]
Tuple – group non homogeneous data type
tuple([string, number, bool]) => [“dog”, 23, true]
map – like key value : Dictionary
{name = “Ankit", age = 32}
set – only unique values
object – complex data type
- There are 4 ways to use variable as below
variable filename {
type = string
default = "sample.txt"
}
var.filename
---
variable filename {} Terraform apply will ask
---
terraform apply -var "filename=sample.txt"
---
export TF_VAR_filename=sample.txt"
- The order of loading variable. 1 is higher priority = load first
1. export TF_VAR_filename=sample.txt“
2. terraform.tfvars file
3. variable.auto.tfvars file
4. terraform apply -var "filename=sample.txt”
- File: Lifecycle Rules
- lifecycle – resource attributes
- create_before_destroy - Create the resource first and then destroy older
- prevent_destroy - Prevents destroy of a resource
- ignore_changes - Ignore Changes to Resource – Specific tag or all
- File: Provisioner Version
- Doc: https://registry.terraform.io/providers/hashicorp/random/latest/docs
- to check current latest version
- Service Account
- https://console.cloud.google.com/iam-admin/serviceaccounts
- created new service account
terraform-gcp
- GCP provider Doc: https://registry.terraform.io/providers/hashicorp/google/latest/docs
- File: Google Provider
- Google Provider base configuration
- projectid, zone, region
- Multiple way to authernticate with GCP
- username/password - gcloud auth application - default login
- Cloud Shell(lecture 26)
- Service Account - Keys: preferred in production(lecture 27)
- Doc: google_storage_bucket
- File-26:
- File-27:
- Doc: https://cloud.google.com/storage
- Doc: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket
- File-30-32:
- 3 Types of VPC
- Default VPC
- Auto Mode
- Custom Mode
- File-34-36:
61-62: BigTable
- a fully managed, wide-column NoSQL database
- File-61-62
- Doc:
63-63: Memoeystore
-
in-memory data store service for Redis and Memcached
-
Doc:
- tf is installed on tfenv
% tfenv list
* 1.3.0 (set by /usr/local/Cellar/tfenv/3.0.0/version)
1.0.10
% terraform --version
Terraform v1.3.0