
In this blog post series we will learn about terraform right from the beginning, this series contains multiple blog post which you can navigate to specific section if you need.
Let's first of all understand
1. What is Infrastructure as Code
Infrastructure as code (IaC) tools allow you to manage infrastructure with configuration files rather than through a graphical user interface. IaC allows you to build, change, and manage your infrastructure in a safe, consistent, and repeatable way by defining resource configurations that you can version, reuse, and share.
2. What is Terraform?
Terraform allows you to manage your infrastructure with code and configuration called HashiCorp's.
It lets you define resources and infrastructure in human-readable, declarative configuration files, and manages your infrastructure's lifecycle. Using Terraform has several advantages over manually managing your infrastructure:
- Terraform can manage infrastructure on multiple cloud platforms.
- The human-readable configuration language helps you write infrastructure code quickly.
- Terraform's state allows you to track resource changes throughout your deployments.
- You can commit your configurations to version control to safely collaborate on infrastructure.
3. Install Terraform
Terraform is widely used tool to automate your infrastructure with any cloud provider and its available for Free, you just need to install terraform exe and store in your workstation its really simple.
Terraform installer is version controlled managed by HashiCorp, to download the appropriate version you have to check the terraform documentation.
How to install it ?
There any many ways to install terraform across different operating system (such as Windows, Mac, Linux)
https://learn.hashicorp.com/tutorials/terraform/install-cli
4. Write your first terraform command
Following command can be used to know all the basic commands of terraform
terraformMaincommands:initPrepareyourworkingdirectoryforothercommandsvalidateCheckwhethertheconfigurationisvalidplanShowchangesrequiredbythecurrentconfigurationapplyCreateorupdateinfrastructuredestroyDestroypreviously-createdinfrastructureAllothercommands:consoleTryTerraformexpressionsataninteractivecommandpromptfmtReformatyourconfigurationinthestandardstyleforce-unlockReleaseastucklockonthecurrentworkspacegetInstallorupgraderemoteTerraformmodulesgraphGenerateaGraphvizgraphofthestepsinanoperationimportAssociateexistinginfrastructurewithaTerraformresourceloginObtainandsavecredentialsforaremotehostlogoutRemovelocally-storedcredentialsforaremotehostoutputShowoutputvaluesfromyourrootmoduleprovidersShowtheprovidersrequiredforthisconfigurationrefreshUpdatethestatetomatchremotesystemsshowShowthecurrentstateorasavedplanstateAdvancedstatemanagementtaintMarkaresourceinstanceasnotfullyfunctionaltestExperimentalsupportformoduleintegrationtestinguntaintRemovethe'tainted'statefromaresourceinstanceversionShowthecurrentTerraformversionworkspaceWorkspacemanagementGlobaloptions(usethesebeforethesubcommand,ifany):-chdir=DIRSwitchtoadifferentworkingdirectorybeforeexecutingthegivensubcommand.-helpShowthishelpoutput,orthehelpforaspecifiedsubcommand.-versionAnaliasforthe"version"subcommand.
To verify the version of terraform you have installed you can run
terraform version------------- This should display the output like this -------Terraform v1.1.2on windows_amd64Your version of Terraform is out of date! The latest versionis 1.2.1. You can update by downloading from https://www.terraform.io/downloads.html
`
5. Integrated Development tool
There are many IDE tools which you have use to start development using terraform, even notepad is okay, the most widely used IDE right now is Visual Studio Code, which you can download for free.
With VSCode there are many extensions you can install which can ease you terraform development experience.
following of them I have installed in my VSCode
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse