Datasources
- Datasources are used to fetch information about resources.
- Datasource will not create any thing, rather it fetches information and Refer Here for official docs
- Refer Here for datasources example
How does terraform know what it has created
- Terraform on execution will create a file called as
terraform.tfstatelocally in the same directory where the terraform is executed from. - This state file contains the information about the resources created in this execution
- Terraform during execution, will check if there is a state file. If the state file exists,
- it takes backup of the current state file
- it executes the refresh internally to get the current state
- difference between what we want vs current state becomes plan
- Terraform executes the plan
- Terraform apply => refresh + plan + apply
-
Since the state file is present in the local folder, to make the template available for multi users, it is recommended to use Terrform Backends (Common state storage )
Activity 1: ntier in Azure
-
Overview
- Manual steps: Watch classroom recording
- summary
- create resource group
- create virtual network with subnets
- create a network resource groups
- create virtual machines
- login into vms and install necessary softwares
- create resource group Refer Here for changes.
- As a best practice, lets start using terrascan
