<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Eugene Chuvyrov</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/eugene/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/eugene/feed.xml</link>
    <description>DevOps and Machine Learning in Microsoft Cloud</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:41:31 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Creating Azure Resources with Terraform</title>
      <link>https://docs.microsoft.com/archive/blogs/eugene/creating-azure-resources-with-terraform</link>
      <pubDate>Thu, 03 Nov 2016 13:24:59 GMT</pubDate>
      <dc:creator><![CDATA[Eugene Chuvyrov]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/eugene/?p=35</guid>
      <description><![CDATA[There are multiple ways to provision infrastructure into Azure today, from creating resources...]]></description>
      <content:encoded><![CDATA[<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">There are multiple ways to provision infrastructure into Azure today, from creating resources through the user interface in Azure portal (<a href="https://portal.azure.com/">https://portal.azure.com</a>) to using Azure CLI to authoring Azure Resource Manager JSON-based templates. The last option - writing JSON-based definitions of infrastructure resources - gets us very close to fulfilling the Infrastructure-as-Code promise, but JSON syntax can be hard to read with double quotation marks and unintuitive comment placement.</p>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">This is where <a href="https://www.hashicorp.com">HashiCorp </a>Terraform comes in, providing a way to deploy cloud infrastructure using a higher-level templating language. But beyond improved readability, <a href="https://terraform.io">Terraform </a>templates allow you to use the same language for a variety of cloud providers, making it a valuable tool in any multi-cloud strategy. In this article, I will show you how to get started using Terraform with Azure. I will use an example of provisioning a virtual machine running Ubuntu OS in a resource group together with all the supporting cloud infrastructure (virtual network, public IP, etc.) necessary for that VM to run.</p>

<h2 style="margin-top: 24px;margin-bottom: 16px;font-size: 1.5em;font-weight: 600;line-height: 1.25;padding-bottom: 0.3em;border-bottom: 1px solid #eeeeee;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-style: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a href="https://github.com/echuvyrov/terraform101/blob/master/gettingstarted.md#installing-terraform" id="user-content-installing-terraform" class="anchor"></a>Installing Terraform</h2>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">The install process for Terraform is straightforward -<span class="Apple-converted-space"> </span><a href="https://www.terraform.io/downloads.html">download</a><span class="Apple-converted-space"> </span>the package appropriate for your OS and unzip it into a separate install directory. The package contains a single executable file, which you should also define a global PATH for. Instructions on setting the PATH on Linux and Mac can be found on<span class="Apple-converted-space"> </span><a href="https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux">this page</a>, while<span class="Apple-converted-space"> </span><a href="https://stackoverflow.com/questions/1618280/where-can-i-set-path-to-make-exe-on-windows">this page</a><span class="Apple-converted-space"> </span>contains instructions for setting the PATH on Windows. Verify your installation by running the "terraform" command - you should see a list of available Terraform options as output.</p>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">Let's allow Terraform to access your Azure subscription and perform provisioning steps next.</p>

<h2 style="margin-top: 24px;margin-bottom: 16px;font-size: 1.5em;font-weight: 600;line-height: 1.25;padding-bottom: 0.3em;border-bottom: 1px solid #eeeeee;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-style: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a href="https://github.com/echuvyrov/terraform101/blob/master/gettingstarted.md#setting-up-terraform-access-to-azure" id="user-content-setting-up-terraform-access-to-azure" class="anchor"></a>Setting up Terraform Access to Azure</h2>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">To unlock Terraform magic in Azure, you need to allow Terraform scripts to provision resources into your Azure subscriptions on your behalf. To enable that access, you need to setup two entities in Azure Active Directory (AAD) - AAD Application and AAD Service Principal - and use these entities' identifiers in your Terraform scripts. The reason for having both entities makes perfect sense in multi-tenant environments, where Service Principal is a local instance of a global AAD App and having a Service Principal allows for granular local access control to global resources.</p>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">When working with Terraform, however, you will be using a single AAD Application and a single Service Principal to enable resource provisioning, but you still need to create both. To streamline this setup process, HashiCorp and Microsoft have written scripts that create all the necessary security infrastructure for you in Azure (AAD App and Service Principal), allowing you to simply execute these scripts and copy/paste the necessary information into your Terraform code.</p>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">The steps below outline what you need to do to create an AAD Application and Service Principal using the scripts supplied.</p>

<h3 style="margin-top: 24px;margin-bottom: 16px;font-size: 1.25em;font-weight: 600;line-height: 1.25;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-style: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a href="https://github.com/echuvyrov/terraform101/blob/master/gettingstarted.md#windows-users" id="user-content-windows-users" class="anchor"></a>Windows Users</h3>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">If you are using a Windows machine to write and execute your Terraform scripts, you need to (1)<span class="Apple-converted-space"> </span><a href="https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/#step-1-install">install Azure PowerShell tools</a>and (2) download and execute the<span class="Apple-converted-space"> </span><a href="https://github.com/echuvyrov/terraform101/blob/master/azureSetup.ps1">azure-setup.ps1 script</a><span class="Apple-converted-space"> </span>from the PowerShell console. To run the azure-setup.ps1 script, download it, execute the "./azure-setup.ps1 setup" command from the PowerShell console and login into your Azure subscription with administrative privileges. Then, provide an application name (arbitrary string, required) when prompted and (optionally) supply a strong password. If you don't provide password, the strong password will be generated for you using .Net security libraries.</p>

<h3 style="margin-top: 24px;margin-bottom: 16px;font-size: 1.25em;font-weight: 600;line-height: 1.25;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-style: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a href="https://github.com/echuvyrov/terraform101/blob/master/gettingstarted.md#linuxmac-users" id="user-content-linuxmac-users" class="anchor"></a>Linux/Mac Users</h3>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">To get started with Terraform on Linux machines or Macs, you need to (1)<span class="Apple-converted-space"> </span><a href="https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/">install Azure xPlat CLI tools</a>, (2)<span class="Apple-converted-space"> </span><a href="https://stedolan.github.io/jq/download/">download and install jq</a><span class="Apple-converted-space"> </span>JSON processor and (3) download and execute the<span class="Apple-converted-space"> </span><a href="https://github.com/mitchellh/packer/blob/master/contrib/azure-setup.sh">azure-setup.sh script</a><span class="Apple-converted-space"> </span>bash script from the console. To run the azure-setup.sh script, download it, execute the "./azure-setup setup" command from the console and login into your Azure subscription with administrative privileges. Then, provide an application name (arbitrary string, required) when prompted and (optionally) supply a strong password when prompted. If you don't provide the password, the strong password will be generated for you using .Net security libraries.</p>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">Both Linux and Windows scripts create an AAD Application and a Service Principal, giving Service Principal an owner-level access on the subscription. Because of high level of access granted, you should always protect the security information generated by those scripts. Take a note of all four pieces of security information provided by those scripts:<span class="Apple-converted-space"> </span><em>client_id, client_secret, subscription_id and tenant_id</em>. Finally, if for some reason you were not able to execute the scripts, you can create a Service Principal manually by following this<span class="Apple-converted-space"> </span><a href="https://www.terraform.io/docs/providers/azurerm/index.html">step-by-step documentation</a><span class="Apple-converted-space"> </span>from HashiCorp.</p>

<h2 style="margin-top: 24px;margin-bottom: 16px;font-size: 1.5em;font-weight: 600;line-height: 1.25;padding-bottom: 0.3em;border-bottom: 1px solid #eeeeee;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-style: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a href="https://github.com/echuvyrov/terraform101/blob/master/gettingstarted.md#minimum-viable-terraform-script" id="user-content-minimum-viable-terraform-script" class="anchor"></a>Minimum Viable Terraform Script</h2>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">With Service Principal information in hand, let's use Terraform to create perhaps the smallest unit of work in Azure - an empty resource group.</p>

<h3 style="margin-top: 24px;margin-bottom: 16px;font-size: 1.25em;font-weight: 600;line-height: 1.25;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-style: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a href="https://github.com/echuvyrov/terraform101/blob/master/gettingstarted.md#authoring-the-terraform-script" id="user-content-authoring-the-terraform-script" class="anchor"></a>Authoring the Terraform Script</h3>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">In your text editor of choice (Visual Studio Code/Sublime/Vim/etc), create a file called<span class="Apple-converted-space"> </span><em>terraform_azure101.tf</em>. The exact name of the file is not important, since terraform accepts the folder name as a parameter - all scripts in the folder get executed. Paste the following code in that new file:</p>

<pre style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;margin-top: 0px;margin-bottom: 16px;font-style: normal;font-variant: normal;font-weight: normal;line-height: 1.45;padding: 16px;overflow: auto;background-color: #f7f7f7;color: #333333;letter-spacing: normal;text-align: start;text-indent: 0px"><code style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;padding: 0px;margin: 0px;background: transparent;border: 0px;overflow: visible;line-height: inherit"># Configure the Microsoft Azure Provider
provider "azurerm" {
  subscription_id = "your_subscription_id_from_script_execution"
  client_id       = "your_client_id_from_script_execution"
  client_secret   = "your_client_secret_from_script_execution"
  tenant_id       = "your_tenant_id_from_script_execution"
}

# create a resource group 
resource "azurerm_resource_group" "helloterraform" {
    name = "terraformtest"
    location = "West US"
}
</code></pre>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">In the "provider" section of the script, you tell Terraform to use an Azure provider to provision resources in the script. Refer to the results of Service Principal script execution above for values for subscription_id, client_id, client_secret and tenant_id. The "azure_rm_resource_group" resource instructs Terraform to create a new resource group; you will see more resource types available in Terraform below.</p>

<h3 style="margin-top: 24px;margin-bottom: 16px;font-size: 1.25em;font-weight: 600;line-height: 1.25;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-style: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a href="https://github.com/echuvyrov/terraform101/blob/master/gettingstarted.md#executing-the-script" id="user-content-executing-the-script" class="anchor"></a>Executing the Script</h3>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">With the script saved, exit to the console/command line and type</p>

<pre style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;margin-top: 0px;margin-bottom: 16px;font-style: normal;font-variant: normal;font-weight: normal;line-height: 1.45;padding: 16px;overflow: auto;background-color: #f7f7f7;color: #333333;letter-spacing: normal;text-align: start;text-indent: 0px"><code style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;padding: 0px;margin: 0px;background: transparent;border: 0px;overflow: visible;line-height: inherit">terraform plan terraformscripts
</code></pre>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">In the above, we assume "terraformscripts" is the folder where the script was saved. Note that we used the "plan" Terraform command, which looks at the resources defined in the scripts, compares them to the state information saved by Terraform and then outputs planned execution<span class="Apple-converted-space"> </span><em>without</em><span class="Apple-converted-space"> </span>actually creating resources in Azure.</p>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">You should see something like the following screen after you execute the command above</p>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a target="_blank" href="https://github.com/echuvyrov/terraform101/blob/master/tf_plan2.png"><img alt="Image of Terraform Plan" src="https://github.com/echuvyrov/terraform101/raw/master/tf_plan2.png" /></a></p>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">Everything looks correct, go ahead and provision this new resource group in Azure by executing</p>

<pre style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;margin-top: 0px;margin-bottom: 16px;font-style: normal;font-variant: normal;font-weight: normal;line-height: 1.45;padding: 16px;overflow: auto;background-color: #f7f7f7;color: #333333;letter-spacing: normal;text-align: start;text-indent: 0px"><code style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;padding: 0px;margin: 0px;background: transparent;border: 0px;overflow: visible;line-height: inherit">terraform apply terraformscripts
</code></pre>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">If you look in the Azure portal now, you should see the new empty resource group called "terraformtest." In the section below, you will add a Virtual Machine and all the supporting infrastructure for that vitual machine to that resource group.</p>

<h2 style="margin-top: 24px;margin-bottom: 16px;font-size: 1.5em;font-weight: 600;line-height: 1.25;padding-bottom: 0.3em;border-bottom: 1px solid #eeeeee;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-style: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a href="https://github.com/echuvyrov/terraform101/blob/master/gettingstarted.md#provisioning-ubuntu-vm-with-terraform" id="user-content-provisioning-ubuntu-vm-with-terraform" class="anchor"></a>Provisioning Ubuntu VM with Terraform</h2>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">Let's extend Terraform script we've created above with details necessary to provision a virtual machine running Ubuntu. The list of resources that you will provision in the sections below are: network with a single subnet, a network interface card, a storage account with a storage container, a public IP and a virtual machine utilizing all the resources above. For a thorough documentation of each of the Azure Terraform resources, consult<span class="Apple-converted-space"> </span><a href="https://www.terraform.io/docs/providers/azurerm/index.html">Terraform documentation</a>.</p>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">The full version of the<span class="Apple-converted-space"> </span><a href="https://github.com/echuvyrov/terraform101/blob/master/terraform101.tf">provisioning script</a><span class="Apple-converted-space"> </span>is also provided for convenience.</p>

<h3 style="margin-top: 24px;margin-bottom: 16px;font-size: 1.25em;font-weight: 600;line-height: 1.25;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-style: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a href="https://github.com/echuvyrov/terraform101/blob/master/gettingstarted.md#extending-the-terraform-script" id="user-content-extending-the-terraform-script" class="anchor"></a>Extending the Terraform Script</h3>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">Extend the script created above with the following resources.</p>

<pre style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;margin-top: 0px;margin-bottom: 16px;font-style: normal;font-variant: normal;font-weight: normal;line-height: 1.45;padding: 16px;overflow: auto;background-color: #f7f7f7;color: #333333;letter-spacing: normal;text-align: start;text-indent: 0px"><code style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;padding: 0px;margin: 0px;background: transparent;border: 0px;overflow: visible;line-height: inherit"># create a virtual network
resource "azurerm_virtual_network" "helloterraformnetwork" {
    name = "acctvn"
    address_space = ["10.0.0.0/16"]
    location = "West US"
    resource_group_name = "${azurerm_resource_group.helloterraform.name}"
}

# create subnet
resource "azurerm_subnet" "helloterraformsubnet" {
    name = "acctsub"
    resource_group_name = "${azurerm_resource_group.helloterraform.name}"
    virtual_network_name = "${azurerm_virtual_network.helloterraformnetwork.name}"
    address_prefix = "10.0.2.0/24"
}
</code></pre>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">The script above creates a virtual network and a subnet within that virtual network. Note the reference to the resource group you have created already via the "${azurerm_resource_group.helloterraform.name}" both in the vritual network and subnet definition.</p>

<pre style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;margin-top: 0px;margin-bottom: 16px;font-style: normal;font-variant: normal;font-weight: normal;line-height: 1.45;padding: 16px;overflow: auto;background-color: #f7f7f7;color: #333333;letter-spacing: normal;text-align: start;text-indent: 0px"><code style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;padding: 0px;margin: 0px;background: transparent;border: 0px;overflow: visible;line-height: inherit"># create public IP
resource "azurerm_public_ip" "helloterraformips" {
    name = "terraformtestip"
    location = "West US"
    resource_group_name = "${azurerm_resource_group.helloterraform.name}"
    public_ip_address_allocation = "dynamic"

    tags {
        environment = "TerraformDemo"
    }
}

# create network interface
resource "azurerm_network_interface" "helloterraformnic" {
    name = "tfni"
    location = "West US"
    resource_group_name = "${azurerm_resource_group.helloterraform.name}"

    ip_configuration {
        name = "testconfiguration1"
        subnet_id = "${azurerm_subnet.helloterraformsubnet.id}"
        private_ip_address_allocation = "static"
        private_ip_address = "10.0.2.5"
        public_ip_address_id = "${azurerm_public_ip.helloterraformips.id}"
    }
}
</code></pre>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">Script snippets above create a public IP and a network interface that makes use of the public IP created. Note the references to subnet_id and public_ip_address_id - Terraform has built-in intelligence to understand that network interface has a dependency on the resources that need to be created prior to the creation of the network interface.</p>

<pre style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;margin-top: 0px;margin-bottom: 16px;font-style: normal;font-variant: normal;font-weight: normal;line-height: 1.45;padding: 16px;overflow: auto;background-color: #f7f7f7;color: #333333;letter-spacing: normal;text-align: start;text-indent: 0px"><code style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;padding: 0px;margin: 0px;background: transparent;border: 0px;overflow: visible;line-height: inherit"># create storage account
resource "azurerm_storage_account" "helloterraformstorage" {
    name = "helloterraformstorage"
    resource_group_name = "${azurerm_resource_group.helloterraform.name}"
    location = "westus"
    account_type = "Standard_LRS"

    tags {
        environment = "staging"
    }
}

# create storage container
resource "azurerm_storage_container" "helloterraformstoragestoragecontainer" {
    name = "vhd"
    resource_group_name = "${azurerm_resource_group.helloterraform.name}"
    storage_account_name = "${azurerm_storage_account.helloterraformstorage.name}"
    container_access_type = "private"
    depends_on = ["azurerm_storage_account.helloterraformstorage"]
}
</code></pre>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">Here, you created a storage account and defined a storage container within that storage account - this is where you will store VHDs for the virtual machine about to be created.</p>

<pre style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;margin-top: 0px;margin-bottom: 16px;font-style: normal;font-variant: normal;font-weight: normal;line-height: 1.45;padding: 16px;overflow: auto;background-color: #f7f7f7;color: #333333;letter-spacing: normal;text-align: start;text-indent: 0px"><code style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;padding: 0px;margin: 0px;background: transparent;border: 0px;overflow: visible;line-height: inherit"># create virtual machine
resource "azurerm_virtual_machine" "helloterraformvm" {
    name = "terraformvm"
    location = "West US"
    resource_group_name = "${azurerm_resource_group.helloterraform.name}"
    network_interface_ids = ["${azurerm_network_interface.helloterraformnic.id}"]
    vm_size = "Standard_A0"

    storage_image_reference {
        publisher = "Canonical"
        offer = "UbuntuServer"
        sku = "14.04.2-LTS"
        version = "latest"
    }

    storage_os_disk {
        name = "myosdisk"
        vhd_uri = "${azurerm_storage_account.helloterraformstorage.primary_blob_endpoint}${azurerm_storage_container.helloterraformstoragestoragecontainer.name}/myosdisk.vhd"
        caching = "ReadWrite"
        create_option = "FromImage"
    }

    os_profile {
        computer_name = "hostname"
        admin_username = "testadmin"
        admin_password = "Password1234!"
    }

    os_profile_linux_config {
        disable_password_authentication = false
    }

    tags {
        environment = "staging"
    }
}
</code></pre>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">Finally, the snippet above creates a virtual machine that utilizes all the resources we have provisioned already: storage account and container for a virtual hard disk (VHD), network interface with public IP and subnet specified, as well as the resource group you have already created. Note the vm_size property, where the script specifies the most affordable Azure SKU - A0, as well as the storage image reference to Ubuntu OS from Canonical.</p>

<h3 style="margin-top: 24px;margin-bottom: 16px;font-size: 1.25em;font-weight: 600;line-height: 1.25;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-style: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a href="https://github.com/echuvyrov/terraform101/blob/master/gettingstarted.md#executing-the-script-1" id="user-content-executing-the-script-1" class="anchor"></a>Executing the Script</h3>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">With the full script saved, exit to the console/command line and type</p>

<pre style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;margin-top: 0px;margin-bottom: 16px;font-style: normal;font-variant: normal;font-weight: normal;line-height: 1.45;padding: 16px;overflow: auto;background-color: #f7f7f7;color: #333333;letter-spacing: normal;text-align: start;text-indent: 0px"><code style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 13.6px;padding: 0px;margin: 0px;background: transparent;border: 0px;overflow: visible;line-height: inherit">terraform apply terraformscripts
</code></pre>
<p style="margin-top: 0px;margin-bottom: 16px;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">After some time, you should see the resources, including a virtual machine, appearing in the "terraformtest" resource group in the Azure portal.</p>

<h2 style="margin-top: 24px;margin-bottom: 16px;font-size: 1.5em;font-weight: 600;line-height: 1.25;padding-bottom: 0.3em;border-bottom: 1px solid #eeeeee;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-style: normal;letter-spacing: normal;text-align: start;text-indent: 0px"><a href="https://github.com/echuvyrov/terraform101/blob/master/gettingstarted.md#coming-up-next" id="user-content-coming-up-next" class="anchor"></a>Coming Up Next</h2>
<p style="margin-top: 0px;margin-bottom: 0px !important;color: #333333;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size: 16px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px">In future installments of Terraform on Azure series, we will cover working with the Terraform state, separating Terraform code in modules, working wth Terraform on a distributed team and other topics to allow you to take full advantage of this next-generation cloud provisioning tool.</p>]]></content:encoded>
    </item>
  </channel>
</rss>