So, far you've been creating Google Cloud resources using the Google Cloud Console and Cloud Shell. We recommend the Google Cloud Console when you're new to using a service or if you prefer a UI. Cloud Shell works best when you're comfortable using a specific service and you want to quickly create resources using the command line. Terraform takes this one step further. Terra form is one of the tools used for infrastructure as code or IaC. Before we dive into understanding terraform, let's look at what infrastructure as code is. In essence Infrastructure as code allows for quickly provisioning, and removing of infrastructures. On demand provisioning of the deployment is extremely powerful. This can be integrated into a continuous integration pipeline that smooths the path to continuous deployment. Automated infrastructure provisioning means that the infrastructure can be provisioned on demand, and the deployment complexity is managed in code. This provides the flexibility to change infrastructure as requirements change. All the changes are in one place. Infrastructure for environments such as development and tests can now easily replicate production and can be deleted immediately when not in use. All because of infrastructure as code. Several tools can be used for IaC. Google Cloud supports terraform where deployments are described in a file known as a configuration. This details, all the resources that should be provisioned. Configurations can be modularized using templates, which allows for the abstraction of resources into reusable components across deployments. In addition to terraform, Google Cloud also provides support for other IaC tools including chef, puppet, ansible, and packer. In this course however, we will focus on terraform. Terraform is an open source tool that lets you provision Google cCoud resources. Terraform lets you provision Google Cloud resources such as virtual machines, containers, storage, and networking with declarative configuration files. You just specify the resources needed in your application and clarity format and deploy your configuration. HashiCorp configuration language or HCL, allows for concise descriptions of resources using blocks, arguments, and expressions. This deployment can be repeated over and over with consistent results and you can delete a whole deployment with a one command or click. The benefit of a declarative approach is that, it allows you to specify what the configuration should be and let the system figure out the steps to take. Instead of deploying each resource separately, you specify a set of resources which compose the application or service allowing you to focus on the application. Unlike Cloud Shell, terraform will deploy resources in parallel. Terraform uses the underlying APIs of each Google Cloud service to deploy your resources. This enables you to deploy almost everything we have seen so far from instances to instance templates. And groups to VPC networks, firewall rules, VPN tunnels, Cloud routers, and load balancers for a full list of supported resource types. A link to the using terraform with Google Cloud documentation page is included in the course resources. The terraform language is a user interface to declare resources. Resources are infrastructure objects such as compute engine storage containers, etcetera. A terraform configuration is a complete document in the terraform language that tells terraform how to manage a given collection of infrastructure. A configuration can consist of multiple files and directories. The syntax of the terra form language includes Blocks that represent objects and can have zero or more labels. A block has a body that enables one to declare arguments and nested blocks, arguments are used to assign value to name and expressions, which are used to assign values to various identifiers. Terraform can be used on multiple, public and private Clouds. Terra form is already installed in Cloud Shell. The example configuration file shown on the right begins by indicating that the provider is Google Cloud. What follows is the configuration of a compute engine instance and its disk. The output section allows for the IP addresses of the provisions instance to be obtained from the deployment. Let's look at a simple example in terraform. Before you get into the lab, let me walk you through how to reform can be used to set up an auto mode network with http firewall rule. For this example, we're going to find our infrastructure in a single file. Main.tf. As our infrastructure becomes more complex. We can build each element into a separate file to make management easier. Let's start with the main.tf file. The main.tf file is where we specify the infrastructure we wish to create. It's like a blueprint for our desired state. First, we define the provider. Next we define our network setting the auto create sub networks flag to true, which will automatically create a sub network in each region. We also set the mtu to 1460. Next we define our firewall. Here we are allowing TCP access across [ort 80 and port 8080. Terraform takes this main.tf file and use it as a specification for what to create. Once we have completed the main.tf file, we can deploy the defined infrastructure in Cloud Shell. We use the command terraform init, to initialize the new terraform configuration. We run this command in the same folder as the main.tf file. The terraform init command, make sure that the Google provider plug in is downloaded and installed in a subdirectory of the current working directory. Along with various other bookkeeping files, you'll see a initializing provider plug ins message. Terraform knows that you're running from a Google project and it's getting the Google resources. The terraform plan command performs a refresh unless explicitly disabled. And then determines what actions are necessary to achieve the desired state specified in the configuration files. This command is a convenient way to check whether the execution plan for a set of changes matches your expectations without making any changes to real resources or to the state. The terraform apply command creates the infrastructure defined in the main.tf file. Once this command is completed, you will be able to access to defined infrastructure.