Skip to main content

Tools you need before you start using Terraform for orchestration infrastructure in cloud

Terraform one of the famous open source tool used for planning, deploying and maintaining infrastructure as a code and the beauty of this tool is that it works across various cloud service providers.

Even though I personally like the AWS Cloudformation, it is AWS only and most probably it will always remain limited to Amazon Web Services. It has few advantages over other tools when using with AWS and will be the first to have new AWS features incorporated before other tools and APIs catch up.

However if you are not limiting yourself to AWS only or have hybrid environment you may want to use a 3rd party tool compatible for all cloud infrastructures. Terraform being one of them is youngest client only tool and this article will help you setting up your desktop environment and give you understanding of how it works before you can start to code.

Prerequisites:

Computer running Windows, Linux, Solaris or MacOS operating system.

Downloads:
Download Terraform directly from the creator HashiCorpp 
Download open source code editor - Visual Studio Code from Microsoft

You could also adopt the Chocolatey to install packages using Linux like commands. 

Setting up Windows desktop:

Using Chocolatey you can run following command to install Terraform and it will set environment variables for you automatically.

c:\choco install terraform

Alternatively you download Terraform executable and place it in a folder such as C:\Terraform\Terraform.exe. Essentially the executable is all you need but you'll have to manually set up environment variable to execute it from anywhere in console by adding path to environment variable %path%. In order to add path you'll have to go to Control Panel to System and Security > System > Advanced System Settings > Environment Variables. You then open path for user only or system variables and add path to Terraform.exe to the list.

Code editing can be performed by any editor such as Notepad, Notepad++ or for better editor you could choose to install downloaded code editor from Microsoft called Visual Studio Code.

You then need to write a Terraform format file and using the executable you can plan, apply or destroy your infrastructure defined within your terraform file with .tf extension and variables in file named terraform.tfvars available within same folder.

So your project will look like below;
.ProjectName
└──mainproject.tf
└──terraform.tfvars

You need to go to Command Prompt or use terminal within Visual Studio Code which uses powershell and change your working directory to ProjectName.

cd c:\users\username\documents\projectname

Once you are in your working folder and have your first project with variables, providers and resources defined you need to get the provider api or executables downloaded which can be done simply by typing following command.

terraform.exe init

You can also check list of providers by using the command bellow.

terraform.exe providers

With your sample project ready you can see what the implementation will look like by using command below. This will tell you what terraform will do including number of resources to be added, changed or destroyed.

terraform.exe plan

If you are happy with the plan you can run the plan by executing command below.

terraform.exe apply

Changes to the original plan can be implemented by executing above command again after modifying your main project .tf file. However please ensure that you do not make any changes to other system generated files.

Please pay attention to the full output.

Once you have finished with your project you can destroy everything that was created using this project by executing below.

terraform.exe destroy

The sample project to create a single web server is available in this blog.



Popular posts from this blog

Useful website performance and load testing tools

http://tsung.erlang-projects.org/ http://httpd.apache.org/docs/2.0/programs/ab.html http://phantomjs.org/ https://developers.google.com/speed/pagespeed/ http://servermonitoringhq.com/blog/how_to_quickly_stress_test_a_web_server https://code.google.com/p/httperf/ http://loadimpact.com/ http://www.paessler.com/webstress http://loaduiweb.org/ http://en.wikipedia.org/wiki/Web_server_benchmarking http://en.wikipedia.org/wiki/Load_testing http://www.loadui.org/ http://www.loadtestingtool.com/index.shtml http://www.appdynamics.com/blog/devops/load-testing-tools-explained-the-server-side/

VMWare ESXi 6.5 HP Custom Image Upgrade to v6.5U3

I had been escaping the Unhandled Exception error every time I log into my ESXi standalone server running v6.5 on N54L and can't be upgraded to v6.7 due to process compatibility. I have finally found the HP Custom image updated to v6.5U3 which appeared to have the fix built into it. It was quite straightforward update using the l latest 6.5 HP image so as habit I am making notes here for myself and everyone else who may find it useful. First of all I downloaded HP Custom v6.5U3 image  by selecting Offline Bundle. I then placed it in my datastore e.g. ds001. Once copied I ran following command line after I was connected to ESXi using ssh. # esxcli software vib update -d /vmfs/volumes/ds001/VMware-ESXi-6.5.0-Update3-14990892-HPE-preGen9-650.U3.9.6.10.1-Dec2019-depot.zip This command took few seconds or may be minutes but confirmed that updates have been installed and will take effect after reboot. So I rebooted the host and it worked like magic. # reboot I did not place host in main...

TrueCrypt on macOS X Mojave 10.14

If you have updated your macOS recently to Mojave otherwise known as verison 10.14 you may not be able to install the last version of Truecrypt in order to access your old volumes encrypted with Truecrypt software. This article will guide you to get this working on your MacOS v10.14 (Mjoave) . Download the package from  https://truecrypt.ch/downloads/  or  https://www.truecrypt71a.com/downloads/ . Find downloaded package using Finder in your HDD/Users/username/Downloads folder and will look like  TrueCrypt 7.1a Mac OS X.dmg . Open file location in Finder and open or double click on  TrueCrypt 7.1a Mac OS X.dmg . This will mount Truecrypt 7.1a and will have Truecrypt 7.1a.mpkg in it. Drag the package T rueCrypt 7.1a.mpkg and drop in your Downloads folder. From Locations in Finder you can eject your TrueCrypt mount. Now go to your Downloads location, find the file  TrueCrypt 7.1a.mpkg , right click and select Show Package Contents . Find the ...