{"id":2792,"date":"2023-07-17T13:17:05","date_gmt":"2023-07-17T12:17:05","guid":{"rendered":"https:\/\/www.easydeploy.io\/blog\/?p=2792"},"modified":"2024-04-09T11:30:20","modified_gmt":"2024-04-09T10:30:20","slug":"import-existing-resources-under-terraform-configuration","status":"publish","type":"post","link":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/","title":{"rendered":"How to import existing resources under Terraform without writing Terraform configuration"},"content":{"rendered":"<p>Before <strong>Terraform version 1.5<\/strong>, if you want to<strong> import existing resources<\/strong> into a Terraform configuration, you must write a configuration for the resources you want to import. If you haven&#8217;t created any resource block for the resources, you cannot import the resources under<strong> Terraform cloud<\/strong>. you can also use <strong>Terraform Import<\/strong> but the configuration Is safer.<\/p>\n<p>Firstly you have to write a Terraform configuration for the particular resource that you want to import and execute the import command with the resource id. Then you have to run <strong><em>terraform plan<\/em><\/strong> command to compare the configuration changes of the resource from the cloud provider to your <strong>terraform configuration file<\/strong>. This is like writing a <strong>Terraform configuration script<\/strong> from the beginning and If you want to import an infrastructure that has a lot of combined resources, it took more time and confusion to manually import and write Terraform configurations for them.<\/p>\n<p>But recently <strong>Hashicorp released Terraform version 1.5<\/strong> and it has a major update for the import concept. They have introduced a new resource block called <strong>import<\/strong>.<\/p>\n<p>This how-to is also published on our youtube channel. Please find the video here<\/p>\n<div class=\"wpex-responsive-embed\"><iframe loading=\"lazy\" title=\"How to import existing AWS cloud resources inside Terraform code using Terraform import v1.6 2024\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/kLm-gZk2SxI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/div>\n<p>&nbsp;<\/p>\n<p>Using this <strong>import block<\/strong> we need to provide the resource id and a resource block name for the resource. Then running the import command will create a new configuration for that resource automatically and we can manage the resource from terraform cloud. Maybe it won&#8217;t be very clear to you when I say all the things here. So let&#8217;s dive into a simple demo.<\/p>\n<p>That will give you an understanding of the process and\u00a0 so i will explain every step for a deep understanding.<\/p>\n<h2>Prerequisites for Terraform Configuration<\/h2>\n<p><strong>1. Before you take this demo your Windows or Linux machine must have the following tools installed<\/strong><\/p>\n<ul>\n<li><em><a href=\"https:\/\/developer.hashicorp.com\/terraform\/tutorials\/aws-get-started\/install-cli\" target=\"_blank\" rel=\"noopener\">Terraform CLI 1.5 or higher<\/a><\/em><\/li>\n<li><em><a href=\"https:\/\/docs.aws.amazon.com\/cli\/latest\/userguide\/getting-started-install.html\" target=\"_blank\" rel=\"noopener\">AWS CLI<\/a><\/em><\/li>\n<\/ul>\n<p><strong>2<\/strong>.<strong>\u00a0 AWS IAM user with the following permissions<\/strong><\/p>\n<ul>\n<li><em><a data-testid=\"\" class=\"awsui_link_4c84z_144la_93 awsui_variant-secondary_4c84z_144la_140 awsui_font-size-body-m_4c84z_144la_414\" aria-label=\"AmazonEC2FullAccess - Opens in a new tab\" data-analytics-funnel-value=\"link512-1688453952584-642\" target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/us-east-1.console.aws.amazon.com\/iamv2\/home?region=us-east-1#\/policies\/details\/arn%3Aaws%3Aiam%3A%3Aaws%3Apolicy%2FAmazonEC2FullAccess\">AmazonEC2FullAccess<\/a><\/em><\/li>\n<\/ul>\n<p><strong>3<\/strong>.\u00a0<strong> <a href=\"https:\/\/docs.aws.amazon.com\/cli\/latest\/userguide\/cli-configure-envvars.html#envvars-set\" target=\"_blank\" rel=\"noopener\">Configure the AWS CLI with the above IAM user&#8217;s Access and secret keys<\/a><\/strong><\/p>\n<h2>Procedure:<\/h2>\n<h3>Create EC2 Instance and Security Group in AWS console<\/h3>\n<p>Open your <strong>AWS console<\/strong> and search for <strong>EC2<\/strong> and click it. You will be redirected to the <strong>EC2 dashboard<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/1-1.png\" alt=\"AWS EC2 Dashboard\" width=\"1115\" height=\"524\" class=\"aligncenter wp-image-2798 size-full\" title=\"AWS EC2 dashboard\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/1-1.png 1115w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/1-1-300x141.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/1-1-1024x481.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/1-1-768x361.png 768w\" sizes=\"(max-width: 1115px) 100vw, 1115px\" \/><\/p>\n<p>Expand the Launch instance icon and click the Launch instance link like the below-mentioned picture.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/2.png\" alt=\"AWS Launch Instance\" width=\"869\" height=\"552\" class=\"aligncenter wp-image-2799\" title=\"AWS Launch Instance\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/2.png 869w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/2-300x191.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/2-768x488.png 768w\" sizes=\"(max-width: 869px) 100vw, 869px\" \/><\/p>\n<p>Enter a name for your <strong>EC2 instance<\/strong> and scroll down to select an AMI for the server. Then select the Amazon Linux image which is eligible for the free tier for this test purpose.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/3-1.png\" alt=\"selecting OS Instance\" width=\"778\" height=\"715\" class=\"aligncenter wp-image-2800 size-full\" title=\"OS Instance\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/3-1.png 778w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/3-1-300x276.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/3-1-768x706.png 768w\" sizes=\"(max-width: 778px) 100vw, 778px\" \/><\/p>\n<p>For the <strong>Instance type<\/strong> also leaves it as default as t2.micro and for the Key pair choose to <em>Proceed without a key pair<\/em> option. Because we don&#8217;t need to log in to the server now. And click <strong>Edit<\/strong> for the <strong>Network setting<\/strong> section.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/4-1.png\" alt=\"Instance type \" width=\"782\" height=\"601\" class=\"aligncenter wp-image-2801 size-full\" title=\"Instance type\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/4-1.png 782w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/4-1-300x231.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/4-1-768x590.png 768w\" sizes=\"(max-width: 782px) 100vw, 782px\" \/><\/p>\n<p>Do not change th<strong>e VPC, Subnet<\/strong>, and Auto-assign <strong>Public IP options<\/strong>. Just leaves them as default values.<\/p>\n<p>For the Firewall, select the Create <strong>security group option<\/strong>, enter a name for your security group, and change the description of the security group also.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/5.png\" alt=\"AWS Security Group\" width=\"775\" height=\"839\" class=\"aligncenter wp-image-2802 size-full\" title=\"AWS Security\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/5.png 775w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/5-277x300.png 277w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/5-768x831.png 768w\" sizes=\"(max-width: 775px) 100vw, 775px\" \/><\/p>\n<p>Click the Launch instance button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/6-1.png\" alt=\"Launch Instance\" width=\"1183\" height=\"383\" class=\"aligncenter wp-image-2803 size-full\" title=\"Launch Instance\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/6-1.png 1183w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/6-1-300x97.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/6-1-1024x332.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/6-1-768x249.png 768w\" sizes=\"(max-width: 1183px) 100vw, 1183px\" \/><\/p>\n<p>Your instance is getting created. click on the <strong>instance id<\/strong> to view your instance details.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/7-1.png\" alt=\"Launch Instance Initiated\" width=\"621\" height=\"212\" class=\"aligncenter wp-image-2804 size-full\" title=\"Launch Instance Initiated\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/7-1.png 621w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/7-1-300x102.png 300w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/8-e1689074514839.png\" alt=\"Instance\" width=\"874\" height=\"733\" class=\"aligncenter wp-image-2805 size-full\" title=\"Instance\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/8-e1689074514839.png 874w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/8-e1689074514839-300x252.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/8-e1689074514839-768x644.png 768w\" sizes=\"(max-width: 874px) 100vw, 874px\" \/><\/p>\n<h3>Initialize Terraform configuration and Define the Import Block<\/h3>\n<p>Open your Visual Studio code editor in the folder in that you run your <strong>Terraform script<\/strong>.<\/p>\n<p>Create a new file as <strong>provider.tf<\/strong> and paste the below code into the file.<\/p>\n<div>\n<pre><span>provider <\/span><span>\"aws\"<\/span><span> {<\/span><span>}<\/span><\/pre>\n<\/div>\n<div>Run <code class=\"mdx-inline-code_inlineCode__mRRzk mdx-inline-code_size-200__jzxqL hds-typography-code-200\"><em>terraform init<\/em><\/code>\u00a0command to initialize the terraform configurations related to AWS Provider.<\/div>\n<div><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/9-1.png\" alt=\"Terraform init\" width=\"590\" height=\"317\" class=\"aligncenter wp-image-2806 size-full\" title=\"Terraform init\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/9-1.png 590w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/9-1-300x161.png 300w\" sizes=\"(max-width: 590px) 100vw, 590px\" \/><\/div>\n<div><\/div>\n<div>Create another file called<strong> import.tf<\/strong> and paste the following code into the file.<\/div>\n<div>\n<div>\n<pre><span>import<\/span><span> {<\/span>\r\n<span>  <\/span><span>id <\/span><span>=<\/span><span> <\/span><span>\"instance-id\"<\/span>\r\n<span>  <\/span><span>to <\/span><span>=<\/span><span> <\/span><span>aws_instance<\/span><span>.<\/span><span>this<\/span>\r\n<span>}<\/span>\r\n\r\n<span>import<\/span><span> {<\/span>\r\n<span>  <\/span><span>id <\/span><span>=<\/span><span> <\/span><span>\"security-group-id\"<\/span>\r\n<span>  <\/span><span>to <\/span><span>=<\/span><span> <\/span><span>aws_security_group<\/span><span>.<\/span><span>this<\/span>\r\n<span>}<\/span><\/pre>\n<\/div>\n<\/div>\n<div>Change the values for <strong>instance-id<\/strong> and<strong> s<\/strong><span><strong>ecurity-group-id<\/strong> with their respecting IDs of them like the below image.<\/span><\/div>\n<div><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/10-1.png\" alt=\"Terraform import\" width=\"579\" height=\"274\" class=\"aligncenter wp-image-2807 size-full\" title=\"Terraform import\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/10-1.png 579w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/10-1-300x142.png 300w\" sizes=\"(max-width: 579px) 100vw, 579px\" \/><\/div>\n<div><\/div>\n<div>You can find the<strong> Instance Id<\/strong> and <strong>Security group Id<\/strong> from your AWS console. Take the below picture for your reference.<\/div>\n<div><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/11-1.png\" alt=\"Instance\" width=\"822\" height=\"544\" class=\"aligncenter wp-image-2808 size-full\" title=\"Instance \" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/11-1.png 822w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/11-1-300x199.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/11-1-768x508.png 768w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/div>\n<h3>Generating the configuration for the resources<\/h3>\n<p>Now we are going to generate a <strong>configuration file<\/strong> for our existing resources. For this, we have to use <em><code class=\"mdx-inline-code_inlineCode__mRRzk mdx-inline-code_size-200__jzxqL hds-typography-code-200\">terraform plan<\/code><\/em> the command with the <em><code class=\"mdx-inline-code_inlineCode__mRRzk mdx-inline-code_size-200__jzxqL hds-typography-code-200\">-generate-config-out<\/code><\/em><span><em>\u00a0<\/em>flag to generate a configuration file for the resources needed to import.<\/span><\/p>\n<pre>terraform plan -generate-config-out=main.tf<\/pre>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/12-1.png\" alt=\"Terraform import\" width=\"1037\" height=\"419\" class=\"aligncenter wp-image-2809 size-full\" title=\"Terraform import\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/12-1.png 1037w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/12-1-300x121.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/12-1-1024x414.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/12-1-768x310.png 768w\" sizes=\"(max-width: 1037px) 100vw, 1037px\" \/><\/div>\n<div><\/div>\n<div>It will throw an error like the above image. Command out the line mentioned in the below screenshot in the file named <strong>main.tf<\/strong>.<\/div>\n<div><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13-1-e1688549487714.png\" alt=\"terraform configuration\" width=\"867\" height=\"442\" class=\"aligncenter wp-image-2810 size-full\" title=\"Change file type\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13-1-e1688549487714.png 867w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13-1-e1688549487714-300x153.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13-1-e1688549487714-768x392.png 768w\" sizes=\"(max-width: 867px) 100vw, 867px\" \/><\/div>\n<div><\/div>\n<div>Now open the <strong>main.tf<\/strong> file, you can see the configuration in the below picture.<\/div>\n<div><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/14.png\" alt=\"Terraform imported file\" width=\"725\" height=\"786\" class=\"aligncenter wp-image-2811 size-full\" title=\"Terraform imported file\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/14.png 725w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/14-277x300.png 277w\" sizes=\"(max-width: 725px) 100vw, 725px\" \/><\/div>\n<div><\/div>\n<div><span>Run\u00a0<\/span><code class=\"mdx-inline-code_inlineCode__mRRzk mdx-inline-code_size-200__jzxqL hds-typography-code-200\"><em>terraform plan<\/em><\/code><span> to verify that your configuration matches the current settings for the <strong>instance and security<\/strong> group. It shows there will be some resources that need to be imported into the state file.<\/span><\/div>\n<div><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/15.png\" alt=\"Terraform Resources import\" width=\"546\" height=\"129\" class=\"aligncenter wp-image-2812 size-full\" title=\"Terraform import\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/15.png 546w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/15-300x71.png 300w\" sizes=\"(max-width: 546px) 100vw, 546px\" \/><\/div>\n<div><\/div>\n<div>So run <em><strong>Terraform apply\u00a0<\/strong><\/em>command to import the configuration.<\/div>\n<div><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/17.png\" alt=\"Terraform Resources import\" width=\"519\" height=\"256\" class=\"aligncenter wp-image-2813 size-full\" title=\"Terraform import\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/17.png 519w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/17-300x148.png 300w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/div>\n<div><\/div>\n<div>You have successfully imported the resources within this Terraform configuration and updated the state file. Now the manually created resources are coming under the <strong>terraform management<\/strong>.<\/div>\n<h3>Update the Resource and Test<\/h3>\n<p>Now we are done with the process of importing resources into <strong>terraform configuration<\/strong>. So it&#8217;s time to check whether the resources are really managed by Terraform or not.<\/p>\n<p>Open the<strong> main.tf file<\/strong> in the VS code editor and change the following line with the following value exactly like the below screenshot.<\/p>\n<pre>instance_type = \"t2.nano\"<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/18.png\" alt=\"Instance type\" width=\"668\" height=\"525\" class=\"aligncenter wp-image-2814 size-full\" title=\"Change Instance type\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/18.png 668w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/18-300x236.png 300w\" sizes=\"(max-width: 668px) 100vw, 668px\" \/><\/p>\n<p>When running the <em><strong>terraform apply<\/strong><\/em> command it will ask for a confirmation with the detail &#8220;1 Resource will be updated in place&#8221;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/19.png\" alt=\"Terraform apply\" width=\"1005\" height=\"515\" class=\"aligncenter wp-image-2815 size-full\" title=\"Terraform apply\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/19.png 1005w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/19-300x154.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/19-768x394.png 768w\" sizes=\"(max-width: 1005px) 100vw, 1005px\" \/><\/p>\n<p>Verify the plan and enter <strong>yes<\/strong> to apply the changes.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/20.png\" alt=\"Terraform apply\" width=\"600\" height=\"586\" class=\"aligncenter wp-image-2816 size-full\" title=\"Terraform apply\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/20.png 600w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/20-300x293.png 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>Once the apply completed, navigate to the <strong>AWS console<\/strong> and to the AWS EC2 page. Then select the instance that you have created and check the instance type. It will be changed to &#8216;<strong>t2.nano<\/strong>&#8216;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/21.png\" alt=\"instance type\" width=\"1011\" height=\"144\" class=\"aligncenter wp-image-2817 size-full\" title=\"Check instance type\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/21.png 1011w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/21-300x43.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/21-768x109.png 768w\" sizes=\"(max-width: 1011px) 100vw, 1011px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p><span>In this blog post, we explored the power of <strong>Terraform as an infrastructure as a code<\/strong> (IaC) tool for provisioning and managing cloud resources. <\/span>At this place, you have an idea about the new import feature of Terraform with the configuration-generating process for existing resources. With Terraform you can manage a whole infrastructure that has a bunch of Cloud services within a <strong>single configuration file<\/strong>.<\/p>\n<p>With this new <strong>Terraform Import Feature<\/strong>, you can import existing or manually created resources into Terraform configuration file without writing any <strong>Terraform configuration scripts<\/strong> manually, and also you can able to import multiple resources with a single command and mention them in a single configuration file.<\/p>\n<pre><a href=\"https:\/\/www.easydeploy.io\/blog\/category\/terraform\/\"><em>Terraform Blogs<\/em><\/a><\/pre>\n<p>We hope this blog post has provided you with a<strong> solid foundation in Terraform<\/strong> and inspired you to explore the capabilities of this powerful tool further. With Terraform, you have the ability to create and manage infrastructure efficiently and reliably, unlocking new possibilities for your projects and driving innovation.<\/p>\n<p>Remember to continue learning and experimenting with Terraform, staying updated with the latest features and best practices. The possibilities are endless, and we are excited to see what you create with Terraform as you build and manage your cloud infrastructure.<\/p>\n<ol><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Before Terraform version 1.5, if you want to import existing resources into a Terraform configuration, you must write a configuration for the resources you want to import. If you haven&#8217;t created any resource block for the resources, you cannot import the resources under Terraform cloud. you can also use Terraform Import but the configuration Is [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":2901,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2,26,424],"tags":[449],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Import Existing Resources | Terraform Configuration<\/title>\n<meta name=\"description\" content=\"Learn the terraforms new feature on how to import existing resources using Terraform configuration. Explore Now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Import Existing Resources | Terraform Configuration\" \/>\n<meta property=\"og:description\" content=\"Learn the terraforms new feature on how to import existing resources using Terraform configuration. Explore Now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/\" \/>\n<meta property=\"og:site_name\" content=\"easydeploy.io\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/Jerinrathnam\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-17T12:17:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-09T10:30:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/Import-Existing-Resources-Terraform-Configuration.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Jerin Rathnam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@jerin_rathnam\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jerin Rathnam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/\"},\"author\":{\"name\":\"Jerin Rathnam\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/939543ac3b33fadea8b5115ab9a1280f\"},\"headline\":\"How to import existing resources under Terraform without writing Terraform configuration\",\"datePublished\":\"2023-07-17T12:17:05+00:00\",\"dateModified\":\"2024-04-09T10:30:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/\"},\"wordCount\":1098,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/Import-Existing-Resources-Terraform-Configuration.webp\",\"keywords\":[\"terraform configuration\"],\"articleSection\":[\"Amazon Web Services\",\"DevOps\",\"Terraform\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/\",\"name\":\"How to Import Existing Resources | Terraform Configuration\",\"isPartOf\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/Import-Existing-Resources-Terraform-Configuration.webp\",\"datePublished\":\"2023-07-17T12:17:05+00:00\",\"dateModified\":\"2024-04-09T10:30:20+00:00\",\"description\":\"Learn the terraforms new feature on how to import existing resources using Terraform configuration. Explore Now!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#primaryimage\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/Import-Existing-Resources-Terraform-Configuration.webp\",\"contentUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/Import-Existing-Resources-Terraform-Configuration.webp\",\"width\":1280,\"height\":720,\"caption\":\"Terraform configuration\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.easydeploy.io\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to import existing resources under Terraform without writing Terraform configuration\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#website\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/\",\"name\":\"easydeploy.io\",\"description\":\"A Cloud Architect Company\",\"publisher\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.easydeploy.io\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#organization\",\"name\":\"EasyDeploy Technologies Pvt Ltd\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png\",\"contentUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png\",\"width\":536,\"height\":100,\"caption\":\"EasyDeploy Technologies Pvt Ltd\"},\"image\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/939543ac3b33fadea8b5115ab9a1280f\",\"name\":\"Jerin Rathnam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ca2c2ab4a28d380073334816b42aaa40?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ca2c2ab4a28d380073334816b42aaa40?s=96&d=mm&r=g\",\"caption\":\"Jerin Rathnam\"},\"description\":\"Jerin Rathnam is a proficient DevOps engineer who is dedicated to streamlining software development and deployment processes. He has extensive knowledge of cloud infrastructure, containerization, and CI\/CD pipelines, which enables him to effectively connect development and operations. Jerin specializes in creating numerous Terraform modules for multi-cloud infrastructure and possesses immense expertise in configuring and managing cloud infrastructure. His profound understanding of containerization, along with his experience in orchestration tools like Docker and Kubernetes, further supports his skills as a valuable DevOps engineer.\",\"sameAs\":[\"https:\/\/www.gemjerin.site\",\"https:\/\/www.facebook.com\/Jerinrathnam\",\"https:\/\/www.instagram.com\/gem_jerin_rathnam\/\",\"https:\/\/www.linkedin.com\/in\/jerin-rathnam\/\",\"https:\/\/x.com\/jerin_rathnam\",\"@jerinrathnam\"],\"url\":\"https:\/\/www.easydeploy.io\/blog\/author\/jerin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Import Existing Resources | Terraform Configuration","description":"Learn the terraforms new feature on how to import existing resources using Terraform configuration. Explore Now!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/","og_locale":"en_GB","og_type":"article","og_title":"How to Import Existing Resources | Terraform Configuration","og_description":"Learn the terraforms new feature on how to import existing resources using Terraform configuration. Explore Now!","og_url":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/","og_site_name":"easydeploy.io","article_author":"https:\/\/www.facebook.com\/Jerinrathnam","article_published_time":"2023-07-17T12:17:05+00:00","article_modified_time":"2024-04-09T10:30:20+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/Import-Existing-Resources-Terraform-Configuration.webp","type":"image\/webp"}],"author":"Jerin Rathnam","twitter_card":"summary_large_image","twitter_creator":"@jerin_rathnam","twitter_misc":{"Written by":"Jerin Rathnam","Estimated reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#article","isPartOf":{"@id":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/"},"author":{"name":"Jerin Rathnam","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/939543ac3b33fadea8b5115ab9a1280f"},"headline":"How to import existing resources under Terraform without writing Terraform configuration","datePublished":"2023-07-17T12:17:05+00:00","dateModified":"2024-04-09T10:30:20+00:00","mainEntityOfPage":{"@id":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/"},"wordCount":1098,"commentCount":0,"publisher":{"@id":"https:\/\/www.easydeploy.io\/blog\/#organization"},"image":{"@id":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#primaryimage"},"thumbnailUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/Import-Existing-Resources-Terraform-Configuration.webp","keywords":["terraform configuration"],"articleSection":["Amazon Web Services","DevOps","Terraform"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/","url":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/","name":"How to Import Existing Resources | Terraform Configuration","isPartOf":{"@id":"https:\/\/www.easydeploy.io\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#primaryimage"},"image":{"@id":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#primaryimage"},"thumbnailUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/Import-Existing-Resources-Terraform-Configuration.webp","datePublished":"2023-07-17T12:17:05+00:00","dateModified":"2024-04-09T10:30:20+00:00","description":"Learn the terraforms new feature on how to import existing resources using Terraform configuration. Explore Now!","breadcrumb":{"@id":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#primaryimage","url":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/Import-Existing-Resources-Terraform-Configuration.webp","contentUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/Import-Existing-Resources-Terraform-Configuration.webp","width":1280,"height":720,"caption":"Terraform configuration"},{"@type":"BreadcrumbList","@id":"https:\/\/www.easydeploy.io\/blog\/import-existing-resources-under-terraform-configuration\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.easydeploy.io\/blog\/"},{"@type":"ListItem","position":2,"name":"How to import existing resources under Terraform without writing Terraform configuration"}]},{"@type":"WebSite","@id":"https:\/\/www.easydeploy.io\/blog\/#website","url":"https:\/\/www.easydeploy.io\/blog\/","name":"easydeploy.io","description":"A Cloud Architect Company","publisher":{"@id":"https:\/\/www.easydeploy.io\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.easydeploy.io\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/www.easydeploy.io\/blog\/#organization","name":"EasyDeploy Technologies Pvt Ltd","url":"https:\/\/www.easydeploy.io\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png","contentUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png","width":536,"height":100,"caption":"EasyDeploy Technologies Pvt Ltd"},"image":{"@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/939543ac3b33fadea8b5115ab9a1280f","name":"Jerin Rathnam","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ca2c2ab4a28d380073334816b42aaa40?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ca2c2ab4a28d380073334816b42aaa40?s=96&d=mm&r=g","caption":"Jerin Rathnam"},"description":"Jerin Rathnam is a proficient DevOps engineer who is dedicated to streamlining software development and deployment processes. He has extensive knowledge of cloud infrastructure, containerization, and CI\/CD pipelines, which enables him to effectively connect development and operations. Jerin specializes in creating numerous Terraform modules for multi-cloud infrastructure and possesses immense expertise in configuring and managing cloud infrastructure. His profound understanding of containerization, along with his experience in orchestration tools like Docker and Kubernetes, further supports his skills as a valuable DevOps engineer.","sameAs":["https:\/\/www.gemjerin.site","https:\/\/www.facebook.com\/Jerinrathnam","https:\/\/www.instagram.com\/gem_jerin_rathnam\/","https:\/\/www.linkedin.com\/in\/jerin-rathnam\/","https:\/\/x.com\/jerin_rathnam","@jerinrathnam"],"url":"https:\/\/www.easydeploy.io\/blog\/author\/jerin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts\/2792"}],"collection":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/comments?post=2792"}],"version-history":[{"count":20,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts\/2792\/revisions"}],"predecessor-version":[{"id":3469,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts\/2792\/revisions\/3469"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/media\/2901"}],"wp:attachment":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/media?parent=2792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/categories?post=2792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/tags?post=2792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}