 Terraform is an amazing tool for building, changing, and versioning infrastructure safely and efficiently. It can manage popular service providers like AWS, Azure, Google Cloud, as well as your custom in-house solutions. It uses a set of configuration files written in HCL, which stands for Hashagorp Configuration Language to describe the desired state of the infrastructure and it can create, update, and delete resources as needed to reach that desired state. It can detect when changes have been made and it can create a plan for resetting those changes if desired. The Terraform state keeps track of everything and it'll see changes from outside of the configuration and it'll include those in the change plans and tell you about it. Terraform is just one of several tools that together allow for infrastructure as code. So what is infrastructure as code or IAC? Well, infrastructure as code is a practice in which infrastructure is provisioned and managed using code rather than manual processes. Now this allows for version control, collaboration, and automation of infrastructure management. Instead of manually setting up systems over and over again, just create your IAC for each thing and never have to do that repetitive work again. This saves so much time and reduces errors in environment creation and setup. With IAC, the infrastructure is defined in a machine readable format and can be managed using version control tools like Git, tested and deployed automatically with systems like Jenkins. And this allows for easier management and scaling of infrastructure and it can help to reduce errors and improve consistency across your organization. Terraform is just one example of a tool that can be used to implement IAC along with AWS CloudFormation, Ansible, Chef and many others. So why should you use Terraform? So there are several reasons why you might choose to use Terraform for infrastructure management. Automation, Terraform allows you to automate the process of creating, updating and deleting resources and it can save you a lot of time compared to just doing it manually. Version control, Terraform supports version control which means that you can track all of your changes to your infrastructure over time and you can roll back to previous versions if you need to. Reusability, Terraform allows you to create reusable modules which can be used to create similar infrastructure across multiple environments. This can help to improve consistency and reduce errors. Collaboration, Terraform supports collaboration which means that you can work with other team members on the infrastructure. Scalability, Terraform allows you to easily scale your infrastructure up or down which can save you time compared to having to do it manually. Multicloud support, now Terraform supports multiple cloud providers so you can use it to manage infrastructure across different environments. This can save you time and reduce the risk of errors. Improved visibility, Terraform allows you to see the entire state of your infrastructure in just one place. Open source, Terraform is open source and it can be used without any license fees whatsoever. As you can see, Terraform offers a range of features so is Terraform better than CloudFormation? Both tools have their own strengths and are suitable for different use cases. One of the main advantages of Terraform is its ability to work across multiple cloud providers and on-premises infrastructure while CloudFormation is specific to AWS. Terraform also has a more human readable syntax and its state file is more informative than CloudFormation's JSON and YAML. But on the other hand, CloudFormation provides more built-in functions and support for AWS services out of the box. And that can really save you time if you're only working with AWS and you don't care about those other things. Terraform also has a feature called the state file which shows the current state of the infrastructure as far as Terraform knows. This can be saved in an S3 bucket or somewhere secure so that you can keep it safe. In summary, Terraform and CloudFormation are both very powerful IEC tools and the best choice for you will depend on your use case and your requirements. If you're working exclusively with AWS then maybe CloudFormation is the better choice but if you need to work across multiple cloud providers or really just don't like JSON YAML then maybe Terraform is the better choice. All right, so let's talk about HCL for a second. This stands for Hashicorp Configuration Language. This is the language that's used in the Terraform configuration files. It's a human readable language that's designed to be easy to write and to understand. So here's an example of what a simple Terraform configuration file written in HCL might look like. This example creates an AWS EC2 instance and a security group. This resource block is used to define a new resource and the AWS instance and AWS security group specify the type of resource to create. This example after the resource type is the name that we're given to the resource. The block enclosing curly braces contains the properties and the values of this resource. HCL also supports variables, conditions, loops and various other constructs making it a very powerful and flexible language to define the desired state of your infrastructure. So using Terraform there's really only four main commands that you need to know to use Terraform. Terraform init sets up the state and the local directory, your state file and it gets everything ready with the providers. This is generally the first command that you're going to run. Next is Terraform plan. Now this checks the configuration and the save state against the actual state and it tells you if there are things that needs to be updated. The output can be saved out to a file easily to ensure that what you apply in the next step does exactly what you expect. Terraform apply runs the plan that you just created in the previous step. It's a good practice to apply the plan output from a file to ensure that nothing has changed since the last plan command. Terraform destroy. Now this destroys all of the resources contained in the current state. This is really good for cleaning up after some testing to save you some money on unused resources. You don't want that stuff out there just costing you money. So now that you see how Terraform can help you create a manager infrastructure give it a try yourself. You can set up something like local stack in a Docker container and experiment with some basic AWS services for free. It really is exciting the first time to see it build all the pieces just based on these configuration files. I'll be making more videos about using modules and other tips for Terraform soon so make sure you subscribe with this interest tube. Thanks for watching and check out this playlist to learn more.