{"id":80231,"date":"2021-12-05T19:51:59","date_gmt":"2021-12-06T01:21:59","guid":{"rendered":"https:\/\/www.whizlabs.com\/blog\/?p=80231"},"modified":"2021-12-06T05:37:52","modified_gmt":"2021-12-06T11:07:52","slug":"terraform-aws","status":"publish","type":"post","link":"https:\/\/www.whizlabs.com\/blog\/terraform-aws\/","title":{"rendered":"How to use Terraform with AWS?"},"content":{"rendered":"<p style=\"text-align: left;\"><span style=\"font-weight: 400;\"><a href=\"https:\/\/www.whizlabs.com\/blog\/what-is-terraform-terraform-tutorial\/\">Terraform<\/a> is an open-source tool from HashiCorp that lets you easily manage, provision, and configure the infrastructure.\u00a0<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">The management process and infrastructure building is typically a long and time-consuming task involving multiple IT teams. Using the Terraform platform streamlines this process, and it is also possible to adjust the infrastructure that has already been built.<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">You can use Terraform to manage infrastructure across multiple clouds. Terraform&#8217;s configuration language is human-readable, so it is easy to use. It&#8217;s called Hashicorp Configuration Language, or HCL.<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">By using APIs, or Application Programming Interfaces, the cloud provider can connect to all cloud platforms. AWS is an Infrastructure provider platform. Using <\/span><b>Terraform and AWS<\/b><span style=\"font-weight: 400;\">, we can manage infrastructure quickly and effectively.<\/span><\/p>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"size-medium wp-image-80232 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-300x131.jpg\" alt=\"How to use Terraform with AWS?\" width=\"300\" height=\"131\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-300x131.jpg 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS.jpg 459w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<h2 style=\"text-align: left;\"><b>How to use Terraform with AWS?<\/b><\/h2>\n<p style=\"text-align: left;\"><i><span style=\"font-weight: 400;\">Now let us see how to build infrastructure using <\/span><\/i><b><i>Terraform with AWS<\/i><\/b><i><span style=\"font-weight: 400;\">.<\/span><\/i><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">Creating a Terraform infrastructure requires a few <\/span><b>Terraform and AWS<\/b><span style=\"font-weight: 400;\"> prerequisites. First, you will need the Terraform CLI, the AWS CLI, an AWS account, and AWS credentials.<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">Here are the steps for creating an AWS account:<\/span><\/p>\n<ul style=\"text-align: left;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">To get started, you will first need to create an account with the IAM section of AWS.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Select the programmatic access and then click next, followed by the admin group.<\/span><\/li>\n<\/ul>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\" wp-image-80233 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS.-300x165.jpg\" alt=\"How to use Terraform with AWS?\" width=\"371\" height=\"204\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS.-300x165.jpg 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS..jpg 415w\" sizes=\"(max-width: 371px) 100vw, 371px\" \/><\/p>\n<ul style=\"text-align: left;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Upon creating the user, you will receive a password ID and a secret password that will be required later to configure the system. Both keys are confidential and should be kept safe.<\/span><\/li>\n<\/ul>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\" wp-image-80234 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-1-300x117.jpg\" alt=\"How to use Terraform with AWS?\" width=\"531\" height=\"207\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-1-300x117.jpg 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-1.jpg 599w\" sizes=\"(max-width: 531px) 100vw, 531px\" \/><\/p>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\" wp-image-80235 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-2-300x154.jpg\" alt=\"How to use Terraform with AWS?\" width=\"500\" height=\"257\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-2-300x154.jpg 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-2.jpg 423w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/p>\n<h2 style=\"text-align: left;\"><b>EC2 instance using Terraform.<\/b><\/h2>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">We have created the IAM user and have Terraform already installed. Now it is time to build and destroy the EC2 instance using Terraform. Consider the following file,<\/span><\/p>\n<p style=\"text-align: left;\"><b>Provider \u201caws\u201d {<\/b><\/p>\n<p style=\"text-align: left;\"><b>\u00a0\u00a0\u00a0\u00a0\u00a0Access_key = \u201cACCESS_KEY_HERE\u201d<\/b><\/p>\n<p style=\"text-align: left;\"><b>Secret_key= \u201cSECRET_KEY_HERE\u201d<\/b><\/p>\n<p style=\"text-align: left;\"><b>REGION\u00a0\u00a0\u00a0\u00a0<\/b><\/p>\n<p style=\"text-align: left;\"><b>\u00a0\u00a0\u00a0\u00a0= \u201cus-east-1\u201d<\/b><\/p>\n<p style=\"text-align: left;\"><b>}<\/b><\/p>\n<p style=\"text-align: left;\"><b>Resource \u201caws_instance\u201d \u201cforexample\u201d {<\/b><\/p>\n<p style=\"text-align: left;\"><b>\u00a0\u00a0\u00a0\u00a0Ami = \u201cami-13be557e\u201d<\/b><\/p>\n<p style=\"text-align: left;\"><b>\u00a0\u00a0\u00a0\u00a0Instance_type = \u201ct2.micro\u201d<\/b><\/p>\n<p style=\"text-align: left;\"><b>}<\/b><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">In the above example, AWS is the provider that Terraform is using. The provider aids Terraform in creating and managing resources successfully. We have already safely located the access which we can provide here.\u00a0<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">AWS_instance id represents the identifier of an EC2 instance. It tells us to start supplying it with resources. The name identifier follows, which can be anything you prefer. Here is the name identifier we are using.<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">We then specify the AMI type on AWS and the instant_type, here we are using t2.micro., which can be found in the AWS free tier package. We are thus using it here.<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">Finally, we have to run the <\/span><b>terraform init, <\/b><span style=\"font-weight: 400;\">where you created the instance.tf file. Here, we have specified the AWS provider plugin in that file. Then we must download and initialize the provider plugin that is the AWS.<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">As soon as the Terraform process is completed, the <\/span><b>Terraform plan <\/b><span style=\"font-weight: 400;\">can be executed. It will enable you to view what Terraform will do before we apply it. We use the <\/span><b>Terraform apply<\/b><span style=\"font-weight: 400;\"> to create the instance.\u00a0<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">If you navigate to the EC2 section of the AWS console, you should see the t2.micro instance created. Terraform-based infrastructure has been created successfully using AWS and Terraform.<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">You can use the <\/span><b>terraform destroy<\/b><span style=\"font-weight: 400;\"> to destroy the infrastructure created, and it will also destroy all the resources created in the Terraform infrastructure.<\/span><\/p>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\" wp-image-80236 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-3-300x185.jpg\" alt=\"How to use Terraform with AWS?\" width=\"489\" height=\"302\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-3-300x185.jpg 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-3.jpg 501w\" sizes=\"(max-width: 489px) 100vw, 489px\" \/><\/p>\n<p style=\"text-align: left;\"><b>Final Words!<\/b><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">Terraform makes infrastructure management effortless and hassle-free. Now you will have a clear idea about how to create infrastructure in <\/span><b>Terraform with AWS<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p style=\"text-align: left;\">\n","protected":false},"excerpt":{"rendered":"<p>Terraform is an open-source tool from HashiCorp that lets you easily manage, provision, and configure the infrastructure.\u00a0 The management process and infrastructure building is typically a long and time-consuming task involving multiple IT teams. Using the Terraform platform streamlines this process, and it is also possible to adjust the infrastructure that has already been built. You can use Terraform to manage infrastructure across multiple clouds. Terraform&#8217;s configuration language is human-readable, so it is easy to use. It&#8217;s called Hashicorp Configuration Language, or HCL. By using APIs, or Application Programming Interfaces, the cloud provider can connect to all cloud platforms. AWS [&hellip;]<\/p>\n","protected":false},"author":355,"featured_media":80307,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[10],"tags":[],"class_list":["post-80231","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-computing-certifications"],"uagb_featured_image_src":{"full":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",560,315,false],"thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4-150x150.jpg",150,150,true],"medium":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4-300x169.jpg",300,169,true],"medium_large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",560,315,false],"large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",560,315,false],"1536x1536":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",560,315,false],"2048x2048":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",560,315,false],"profile_24":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",24,14,false],"profile_48":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",48,27,false],"profile_96":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",96,54,false],"profile_150":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",150,84,false],"profile_300":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",300,169,false],"tptn_thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4-250x250.jpg",250,250,true],"web-stories-poster-portrait":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",560,315,false],"web-stories-publisher-logo":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",96,54,false],"web-stories-thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/12\/How-to-use-Terraform-with-AWS-4.jpg",150,84,false]},"uagb_author_info":{"display_name":"Himanshu Chellani","author_link":"https:\/\/www.whizlabs.com\/blog\/author\/himanshu\/"},"uagb_comment_info":4,"uagb_excerpt":"Terraform is an open-source tool from HashiCorp that lets you easily manage, provision, and configure the infrastructure.\u00a0 The management process and infrastructure building is typically a long and time-consuming task involving multiple IT teams. Using the Terraform platform streamlines this process, and it is also possible to adjust the infrastructure that has already been built.&hellip;","_links":{"self":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/80231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/users\/355"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/comments?post=80231"}],"version-history":[{"count":6,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/80231\/revisions"}],"predecessor-version":[{"id":80319,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/80231\/revisions\/80319"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media\/80307"}],"wp:attachment":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media?parent=80231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/categories?post=80231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/tags?post=80231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}