{"id":211,"date":"2020-08-08T20:24:07","date_gmt":"2020-08-08T14:54:07","guid":{"rendered":"http:\/\/blogs.shydrate.com\/?p=211"},"modified":"2020-08-08T20:24:09","modified_gmt":"2020-08-08T14:54:09","slug":"building-infrastructure-for-aws-using-terraform","status":"publish","type":"post","link":"https:\/\/blogs.shydrate.com\/index.php\/2020\/08\/08\/building-infrastructure-for-aws-using-terraform\/","title":{"rendered":"Building infrastructure for AWS using terraform"},"content":{"rendered":"\n<p>What is terraform?<\/p>\n\n\n\n<p>Terraform&nbsp;is an&nbsp;open-source infrastructure as code, software tool created by&nbsp;HashiCorp. It enables users to define and provision data center infrastructure using a declarative configuration language known as HashiCorp Configuration Language (HCL), or optionally&nbsp;JSON. Terraform supports all cloud providers.<\/p>\n\n\n\n<p>In this article i will show how to build simple architecture in aws using terraform. <\/p>\n\n\n\n<p>First install terraform on your system. Based on your Operating system download <a href=\"https:\/\/www.terraform.io\/downloads.html\">terrafrom<\/a>. <\/p>\n\n\n\n<p>Let&#8217;s start with ec2-creation. I am using ubuntu 18.04 as base OS and instance type t2.micro which falls under free-tier.<\/p>\n\n\n\n<p>Ec2-resource creation:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">resource \"aws_instance\" \"MyFirstInstance\"{<br>#add ami,instance,tag values to create instance<br>ami = \"ami-02354e95b39ca8dec\"<br>instance_type = \"t2.micro\"<br>vpc_security_group_ids = [\"${aws_security_group.allow_ssh.id}\"]<br>subnet_id = \"${aws_subnet.PublicSubnet.id}\"<br>tags = {<br>Name = \"MyEc2Instance\"<br>}<\/pre>\n\n\n\n<p><br>Elastic ip creation:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">resource \"aws_eip\" \"EipForInstance\"{ instance = \"${aws_instance.MyFirstInstance.id}\" vpc = true tags = { Name = \"Ec2_instance_ip\" }}<\/pre>\n\n\n\n<p>VPC Creation: Here for demo i have allowed all ips for ssh. Don&#8217;t follow this practice in dev\/production server<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">resource \"aws_vpc\" \"mainvpc\" { cidr_block = \"10.0.0.0\/16\" instance_tenancy = \"default\" enable_dns_hostnames = true<br>tags = { Name = \"VPC_TF\" }<br>}<\/pre>\n\n\n\n<p>You can find code in my <a href=\"https:\/\/github.com\/shydrate\/Terraform_aws.git\">repo<\/a> . Kindly check the readme file for running terraform file. <\/p>\n\n\n\n<p><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>What is terraform? Terraform&nbsp;is an&nbsp;open-source infrastructure as code, software tool created by&nbsp;HashiCorp. It enables users to define and provision data center infrastructure using a declarative configuration language known as HashiCorp Configuration Language (HCL), or optionally&nbsp;JSON. Terraform supports all cloud providers.<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-211","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/comments?post=211"}],"version-history":[{"count":1,"href":"https:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":213,"href":"https:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/posts\/211\/revisions\/213"}],"wp:attachment":[{"href":"https:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/media?parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/categories?post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/tags?post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}