IAAC — Introduction to Terraform

  • Traditional IT Workflows.
  • Interaction with Cloud.
  • Introduction to Terraform.
  • Terraform Workflow.
  • Introduction to “Local Provider” terraform plugin.
  • Creating single resource (local_file resource type) using Terraform.
  • Setting custom file_permissions for Files generated through Terraform.
  • Creating multiple resources (local_file resource type) using Terraform.
  • Introduction to “Random Provider” terraform plugin.
  • Using Random_Integer resource type using Terraform.
  • Using Random_String resource type using Terraform.
  • First thing is business always create a requirement of very, very high level requirement, detailing about the features that needs to be added to the application.
  • The role of being a business analyst come into picture who converts your requirement into some kind of very high level technical detail.
  • Next thing is either Technical Architect or any Senior technical person will create infrastructure design detailing the resources required for provisioning inside the cloud or in company’s own data-centre.
  • If project demands more hardware, definitely we shall need to contact our procurement team and buying new hardware in a data-center may take weeks to months.
  • Once infrastructure is procured by Infrastructure team, the same shall be handed over to the development team, so that they can start on deployment plan for the application.
  • This flow has a very, very slow deployment cycle.
  • It’s expensive also, and it has a scaling issue also because it’s not like a public cloud that it’s highly elastic in nature. If you need more of it, you might need to wait four weeks or even two months or so.
  • And because there are lots of teams being involved throughout this complete lifecycle, so definitely human error will be involved.
  • Going to a cloud based infrastructure can probably solve these problems. In cloud, this resource provisioning is very much fast.
  • From months to meet in a matter of weeks or within a matter of days, if the budget has been allocated, you can immediately create those resources.
  • Either you can use website like a cloud console or a portal through which you can interact with, but it is good enough if you are managing a limited resource. For example, let’s say you are just managing five different little machines. That’s good enough.
  • But let’s say you need to manage thousands of different resources. In that case, this click based approach will not be a good solution. So, there is another way to interact with our public cloud i.e. programmatically through Application Programming Interface (API).
  • Docker
  • Puppet
  • Ansible
  • TerraForm.
  • Packer.
  • TerraForm is one of the most popular tools currently available in the market for infrastructure provisioning.
  • It’s a completely free, of course, and it’s open source.
  • It is being developed by Hashicorp Organisation.
  • We use a language called as HashiCorp Configuration Language, for this purpose.
  • Terraform does provides support for different cloud- vendors like AWS or Azure or GCP.
  • We don’t need to write code differently for each cloud provider.
  • Network provisioning.
  • DNS provisioning.
  • Firewall creation.
  • Databases maintenance.
  • Database creation.
  • Note that, whatever you learn for Google Cloud’s Deployment Manager will not be applicable to the AWS’s Cloud formation. So, there is no unifying common approach.
  • TerraForm TerraForm is a cloud agnostic. It’s independent of cloud, but it has a multiple providers’s support available.
  • You can create a resource with uniform programming language, unifying approach for infrastructure creation.
  • Scoping → To identify the infrastructure for your project i.e. what are the different resources you are going to create inside the infrastructure?
  • Authoring → Next one is you need to write the configuration file for your infrastructure. Now, depending on what infrastructure you are going to create, you need to create a configuration file and this configuration files are written in HCL i.e. HashiCorp Configuration Language.
  • Initialise → Here we are going to download all the plugins required to manage your infrastructure.
  • Plan and apply → Plan will tell us our execution plan that, what are the changes you are going to make in your remote infrastructure And last, you are actually going to apply all those changes.
  • Creating a virtual machine inside the Google Cloud platform.
  • Create a big table inside the Google Cloud platform.
  • Create a very simple local file by writing some content inside it. (Most Simple).
  • resource → This resource is nothing but a block. We are going to create the file-name as mentioned in resource block
  • resource type → Here, we are going to create a resource of local_file type.
  • resource name → So, for each individual infrastructure creation or any resource creation, we shall define the properties for the same. Here resourceName is : sample_res. We have to provide some arguments like name, permissions and content, etc. to this resource.
  • We need to execute after writing our configuration file.
  • During this step, it shall download the required plugins, for e.g. local provider plugin shall be downloaded.
  • It doesn’t mean any infrastructure, but it will tell us that what are the necessary change you are going to apply?
  • For example : What different resource you are going to create ? What are the properties of resources you are going to update or do some kind of necessary changes OR what resource or how many resource you are going to destroy, right?
  • If we are satisfied with this plan, we can go ahead with the apply step.
  • One file which we actually want to create i.e. sample.txt.
  • Another file is terraform.tfstate
  • User have got all full permissions of RWX.
  • Group have got all NIL permissions.
  • Others have got all NIL permissions.
  • cat.txt
  • dog.txt
  • Range has been pre-defined i.e. minimum and maximum from which random integer could be generated.
  • Output shall be stored as value and would be displayed in output.
  • length has been defined upfront and it can very well contain upper characters.
  • Output shall be stored as value and would be displayed in output.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store