{"id":2406,"date":"2022-01-02T15:47:07","date_gmt":"2022-01-02T21:47:07","guid":{"rendered":"https:\/\/www.ciraltos.com\/?p=2406"},"modified":"2023-03-23T05:24:13","modified_gmt":"2023-03-23T10:24:13","slug":"use-existing-resources-with-data-sources-in-terraform-and-azure","status":"publish","type":"post","link":"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/","title":{"rendered":"Use Existing Resources with Data Sources in Terraform and Azure"},"content":{"rendered":"\n<figure class=\"wp-block-image alignleft size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"169\" height=\"162\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2021\/12\/TerraformAzureLogo.png\" alt=\"\" class=\"wp-image-2407\"\/><\/figure>\n\n\n\n<p>Use Terraform long enough, and eventually, we\u2019ll need to use an existing resource not managed by Terraform as part of the deployment.&nbsp; A typical example is deploying a network-enabled resource, a virtual machine, for instance, to an existing virtual network.&nbsp; This post and accompanying video demonstrate using an existing Azure resource as part of a Terraform deployment.&nbsp; <\/p>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"ast-oembed-container\" style=\"height: 100%;\"><iframe loading=\"lazy\" title=\"Use Existing Resources with Data Sources in Terraform and Azure\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/QrSfASpVE14?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/div>\n<\/div><\/figure>\n\n\n\n<p>If you are just getting started with Terraform, be sure to check out other posts and videos here:<br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.ciraltos.com\/getting-started-with-terraform-and-azure-overview-and-setup\/\" target=\"_blank\">Getting started with Terraform and Azure: Overview and Setup<\/a><br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.ciraltos.com\/terraform-workflow-with-azure-write-plan-and-apply\/\" target=\"_blank\">Terraform Workflow with Azure: Write, Plan and Apply<\/a><br><a href=\"https:\/\/www.ciraltos.com\/input-variables-with-terraform-and-azure\/\">Input Variables with Terraform and Azure<\/a> <br><a href=\"https:\/\/www.ciraltos.com\/modules-and-outputs-with-terraform-and-azure\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Modules and Outputs with Terraform and Azure (opens in a new tab)\">Modules and Outputs with Terraform and Azure<\/a><\/p>\n\n\n\n<p>Also, the code used for this post and video can be found on GitHub here:<br><a href=\"https:\/\/github.com\/tsrob50\/TerraformExamples\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"https:\/\/github.com\/tsrob50\/TerraformExamples (opens in a new tab)\">https:\/\/github.com\/tsrob50\/TerraformExamples<\/a><\/p>\n\n\n\n<p>There are two options for using existing resources created by some means other than Terraform: Import, and Data Source.<\/p>\n\n\n\n<h1>Import<\/h1>\n\n\n\n<p>Terraform Import, as the name implies, imports infrastructure\ninto Terraform management.&nbsp; Import adds resources\nto the deployment state, expecting it will be managed by Terraform going\nforward.<\/p>\n\n\n\n<p>Import is for transitioning infrastructure into Terraform management.&nbsp; Resources not currently managed by Terraform can\nbe transitioned into and be managed by Terraform with Import.<\/p>\n\n\n\n<h1>Data Source<\/h1>\n\n\n\n<p>Data Source allows Terraform to define and use infrastructure\ncreated outside of the current deployment.&nbsp;\nThe resources could have been deployed as part of another Terraform\ndeployment or other process such as Azure Resource Manager (ARM) or with the\nportal.<\/p>\n\n\n\n<p>The key difference is that with Data Sources, the source\ndoes not become managed by Terraform or part of the Terraform state. &nbsp;Instead, a Data Source simply references existing\ninfrastructure.&nbsp; The data source can then\nbe used as part of the deployment.<\/p>\n\n\n\n<h1>Terraform Example<\/h1>\n\n\n\n<p>The following example will use a Data block to reference an\nexisting Virtual Network. &nbsp;We will attach\na virtual network interface for a new VM to an existing subnet.&nbsp; The example also uses the <em>Sensitive<\/em>\nargument to obfuscate a password and set VM specific features in the Provider\nblock.<\/p>\n\n\n\n<p>First, we start with an existing Module that creates a\nVM.&nbsp; The module name is WinServer.&nbsp; Within the <em>main.tf<\/em> file for the module,\nwe must supply a Subnet ID for the Network Interface resource.&nbsp; This is supplied by the <em>var.subnetid<\/em>\nvariable.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"719\" height=\"338\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2021\/12\/Subnet-Variable-1.png\" alt=\"\" class=\"wp-image-2408\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Subnet-Variable-1.png 719w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Subnet-Variable-1-300x141.png 300w\" sizes=\"(max-width: 719px) 100vw, 719px\" \/><figcaption class=\"wp-element-caption\"> Subnet Variable<\/figcaption><\/figure>\n\n\n\n<h1>Sensitive Argument<\/h1>\n\n\n\n<p>Another item to note, in the <em>inputs.tf<\/em> is a variable\nfor the local admin password.&nbsp; Notice the\nsensitive argument provided with the variable.&nbsp;\nThe sensitive argument instructs Terraform not to write the password to\nthe console, providing security by obscurity for sensitive variable data.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\">\n<p>For some reason, I created this example with variables in a file named <em>inputs.tf<\/em> instead of <em>variables.tf.<\/em>&nbsp; I\u2019m too far into this example to change it now.<\/p>\n<\/blockquote>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"883\" height=\"197\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2021\/12\/Sensitive-Argument.png\" alt=\"\" class=\"wp-image-2409\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Sensitive-Argument.png 883w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Sensitive-Argument-300x67.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Sensitive-Argument-768x171.png 768w\" sizes=\"(max-width: 883px) 100vw, 883px\" \/><figcaption class=\"wp-element-caption\"> Sensitive Argument <\/figcaption><\/figure>\n\n\n\n<h1>Provider Features<\/h1>\n\n\n\n<p>The Root module calls the WinServer module, passing in all\nthe variables, including the subnet ID. &nbsp;Some\nresources, such as virtual machines, have deployment-wide features that can be enabled\nin a feature block within the provider.&nbsp; These\nfeatures set behaviors for the resources.&nbsp;\nFor example, the provider block below has two Virtual Machine features\nenabled.&nbsp; One feature sets the OS disk to\ndelete when the VM is removed.&nbsp; The other\nwill not force a graceful shutdown on the VM when deleted. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"574\" height=\"223\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2021\/12\/AzureRM-Features.png\" alt=\"\" class=\"wp-image-2410\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/AzureRM-Features.png 574w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/AzureRM-Features-300x117.png 300w\" sizes=\"(max-width: 574px) 100vw, 574px\" \/><figcaption class=\"wp-element-caption\"> AzureRM Features <\/figcaption><\/figure>\n\n\n\n<p>A full list of features can be found at the Terraform Registry documentation located here: <a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs#features\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs#features (opens in a new tab)\">https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs#features<\/a><\/p>\n\n\n\n<h1>Data Source<\/h1>\n\n\n\n<p>Now for the main attraction.&nbsp;\nThe example creates a virtual machine, and as part of that deployment,\nwe need to supply a subnet ID.&nbsp; The subnet\nalready exists, and there is no intention to import the subnet into this\ndeployment for management.&nbsp; We use a <em>data<\/em>\nblock to reference the external subnet resource.<\/p>\n\n\n\n<p>We can find examples of data blocks in the Terraform documentation.&nbsp; A search for subnet will return <em>azurerm_subnet<\/em> under the heading <em>Resources<\/em> and <em>Data Sources<\/em> <a rel=\"noreferrer noopener\" aria-label=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs (opens in a new tab)\" href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs\" target=\"_blank\">https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"364\" height=\"504\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2021\/12\/Resources-and-Data-Sources.png\" alt=\"\" class=\"wp-image-2411\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Resources-and-Data-Sources.png 364w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Resources-and-Data-Sources-217x300.png 217w\" sizes=\"(max-width: 364px) 100vw, 364px\" \/><figcaption class=\"wp-element-caption\"> Resources and Data Sources<\/figcaption><\/figure>\n\n\n\n<p>Select <em>azurerm_subnet<\/em> under <em>Data Sources<\/em> to\nview an example of a data block for Azure subnets and output.&nbsp; Use the documentation for other resources you\nmay need to reference when creating data blocks in Terraform.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"732\" height=\"348\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2021\/12\/Data-Example.png\" alt=\"\" class=\"wp-image-2412\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Data-Example.png 732w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Data-Example-300x143.png 300w\" sizes=\"(max-width: 732px) 100vw, 732px\" \/><figcaption class=\"wp-element-caption\"> Data Example<\/figcaption><\/figure>\n\n\n\n<p>Now that we have an example, we can create the data block.&nbsp; The example below uses variables to provide\nthe name of the subnet, virtual network, and the virtual network&#8217;s resource\ngroup.&nbsp; An important to note is that the resources\ngroup in this context is for the VNet, not the resource group of the\ndeployment.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"532\" height=\"139\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2021\/12\/Subnet-Data-Block.png\" alt=\"\" class=\"wp-image-2413\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Subnet-Data-Block.png 532w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Subnet-Data-Block-300x78.png 300w\" sizes=\"(max-width: 532px) 100vw, 532px\" \/><figcaption class=\"wp-element-caption\"> Subnet Data Block <\/figcaption><\/figure>\n\n\n\n<p>That exposes the external resource to our deployment. &nbsp;Next, we need to supply the Subnet ID to the\nmodule.&nbsp; To do that, we simply reference the\ndata block in the module block as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"753\" height=\"273\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2021\/12\/Subnet-ID.png\" alt=\"\" class=\"wp-image-2414\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Subnet-ID.png 753w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/Subnet-ID-300x109.png 300w\" sizes=\"(max-width: 753px) 100vw, 753px\" \/><figcaption class=\"wp-element-caption\"> Subnet ID<\/figcaption><\/figure>\n\n\n\n<p>Now, when we apply the configuration, the network interface\nfor the new virtual machine will connect to the existing subnet.&nbsp; That is how to reference a data source outside\nof the deployment in Terraform with Azure.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use Terraform long enough, and eventually, we\u2019ll need to use an existing resource not managed by Terraform as part of the deployment.&nbsp; A typical example is deploying a network-enabled resource, a virtual machine, for instance, to an existing virtual network.&nbsp; This post and accompanying video demonstrate using an existing Azure resource as part of a &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/\"> <span class=\"screen-reader-text\">Use Existing Resources with Data Sources in Terraform and Azure<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":2407,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","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":""},"categories":[1159],"tags":[1163,1191,9,992,428,1195,1194,1192,1164,1169,1174,1181,1182,1188,1172,1193,1160,1165,1170,1175,1184,1187,1171,1162,1185,1179,1178,1177,1183,1168,1176,1007,962,268],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Use Existing Resources with Data Sources in Terraform and Azure - ciraltos<\/title>\n<meta name=\"description\" content=\"This post demonstrates using an existing Azure resource as part of a Terraform deployment.\" \/>\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.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Use Existing Resources with Data Sources in Terraform and Azure - ciraltos\" \/>\n<meta property=\"og:description\" content=\"This post demonstrates using an existing Azure resource as part of a Terraform deployment.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/\" \/>\n<meta property=\"og:site_name\" content=\"ciraltos\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-02T21:47:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-23T10:24:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/TerraformAzureLogo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"169\" \/>\n\t<meta property=\"og:image:height\" content=\"162\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Travis Roberts\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ciraltos\" \/>\n<meta name=\"twitter:site\" content=\"@ciraltos\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Travis Roberts\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/\"},\"author\":{\"name\":\"Travis Roberts\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"headline\":\"Use Existing Resources with Data Sources in Terraform and Azure\",\"datePublished\":\"2022-01-02T21:47:07+00:00\",\"dateModified\":\"2023-03-23T10:24:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/\"},\"wordCount\":876,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"keywords\":[\".tf\",\".tfvars\",\"Azure\",\"Azure CLI\",\"Data\",\"data resource\",\"data resource block\",\"data source\",\"HashiCorp\",\"IaC Terraform\",\"main.tf\",\"Modules\",\"outputs\",\"outputs.tf\",\"registry\",\"sensitive\",\"Terraform\",\"Terraform Apply\",\"Terraform Destroy\",\"Terraform for Azure\",\"terraform modules\",\"terraform outputs\",\"Terraform Plan\",\"terraform registry\",\"Terraform Resource\",\"terraform training\",\"terraform tutorial\",\"terraform var\",\"terraform variables\",\"Terraform Write\",\"Terraform.tfvars\",\"Variables\",\"VSCode\",\"workflow\"],\"articleSection\":[\"Terraform\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/\",\"url\":\"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/\",\"name\":\"Use Existing Resources with Data Sources in Terraform and Azure - ciraltos\",\"isPartOf\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#website\"},\"datePublished\":\"2022-01-02T21:47:07+00:00\",\"dateModified\":\"2023-03-23T10:24:13+00:00\",\"description\":\"This post demonstrates using an existing Azure resource as part of a Terraform deployment.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.ciraltos.com\/staging2\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Use Existing Resources with Data Sources in Terraform and Azure\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#website\",\"url\":\"http:\/\/www.ciraltos.com\/staging2\/\",\"name\":\"ciraltos\",\"description\":\"cloud, technology and trends\",\"publisher\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.ciraltos.com\/staging2\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\",\"name\":\"Travis Roberts\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png\",\"contentUrl\":\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png\",\"width\":5657,\"height\":3563,\"caption\":\"Travis Roberts\"},\"logo\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/www.ciraltos.com\",\"https:\/\/twitter.com\/ciraltos\"],\"url\":\"https:\/\/www.ciraltos.com\/staging2\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Use Existing Resources with Data Sources in Terraform and Azure - ciraltos","description":"This post demonstrates using an existing Azure resource as part of a Terraform deployment.","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.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/","og_locale":"en_US","og_type":"article","og_title":"Use Existing Resources with Data Sources in Terraform and Azure - ciraltos","og_description":"This post demonstrates using an existing Azure resource as part of a Terraform deployment.","og_url":"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/","og_site_name":"ciraltos","article_published_time":"2022-01-02T21:47:07+00:00","article_modified_time":"2023-03-23T10:24:13+00:00","og_image":[{"width":169,"height":162,"url":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/12\/TerraformAzureLogo.png","type":"image\/png"}],"author":"Travis Roberts","twitter_card":"summary_large_image","twitter_creator":"@ciraltos","twitter_site":"@ciraltos","twitter_misc":{"Written by":"Travis Roberts","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/#article","isPartOf":{"@id":"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/"},"author":{"name":"Travis Roberts","@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"headline":"Use Existing Resources with Data Sources in Terraform and Azure","datePublished":"2022-01-02T21:47:07+00:00","dateModified":"2023-03-23T10:24:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/"},"wordCount":876,"commentCount":0,"publisher":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"keywords":[".tf",".tfvars","Azure","Azure CLI","Data","data resource","data resource block","data source","HashiCorp","IaC Terraform","main.tf","Modules","outputs","outputs.tf","registry","sensitive","Terraform","Terraform Apply","Terraform Destroy","Terraform for Azure","terraform modules","terraform outputs","Terraform Plan","terraform registry","Terraform Resource","terraform training","terraform tutorial","terraform var","terraform variables","Terraform Write","Terraform.tfvars","Variables","VSCode","workflow"],"articleSection":["Terraform"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/","url":"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/","name":"Use Existing Resources with Data Sources in Terraform and Azure - ciraltos","isPartOf":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#website"},"datePublished":"2022-01-02T21:47:07+00:00","dateModified":"2023-03-23T10:24:13+00:00","description":"This post demonstrates using an existing Azure resource as part of a Terraform deployment.","breadcrumb":{"@id":"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.ciraltos.com\/staging2\/use-existing-resources-with-data-sources-in-terraform-and-azure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.ciraltos.com\/staging2\/"},{"@type":"ListItem","position":2,"name":"Use Existing Resources with Data Sources in Terraform and Azure"}]},{"@type":"WebSite","@id":"http:\/\/www.ciraltos.com\/staging2\/#website","url":"http:\/\/www.ciraltos.com\/staging2\/","name":"ciraltos","description":"cloud, technology and trends","publisher":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.ciraltos.com\/staging2\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a","name":"Travis Roberts","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/","url":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png","contentUrl":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png","width":5657,"height":3563,"caption":"Travis Roberts"},"logo":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/www.ciraltos.com","https:\/\/twitter.com\/ciraltos"],"url":"https:\/\/www.ciraltos.com\/staging2\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/2406"}],"collection":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/comments?post=2406"}],"version-history":[{"count":5,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/2406\/revisions"}],"predecessor-version":[{"id":3788,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/2406\/revisions\/3788"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/media\/2407"}],"wp:attachment":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/media?parent=2406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/categories?post=2406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/tags?post=2406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}