Skip to content

Latest commit

 

History

History
104 lines (68 loc) · 5.77 KB

quick-create-terraform.md

File metadata and controls

104 lines (68 loc) · 5.77 KB
title titleSuffix description services author ms.author ms.date ms.topic ms.service ms.custom content_well_notification ai-usage
Quickstart: Direct web traffic with Azure Application Gateway - Terraform
Azure Application Gateway
In this quickstart, you learn how to use Terraform to create an Azure Application Gateway that directs web traffic to virtual machines in a backend pool.
application-gateway
greg-lindsay
greglin
05/30/2024
quickstart
application-gateway
devx-track-terraform
AI-contribution
ai-assisted

Quickstart: Direct web traffic with Azure Application Gateway - Terraform

In this quickstart, you use Terraform to create an Azure Application Gateway. Then you test the application gateway to make sure it works correctly. The Standard v2 SKU is used in this example.

[!INCLUDE About Terraform]

[!div class="checklist"]

Conceptual diagram of the quickstart setup.

Note

Application Gateway frontend now supports dual-stack IP addresses (Preview). You can now create up to four frontend IP addresses: Two IPv4 addresses (public and private) and two IPv6 addresses (public and private).

Prerequisites

Implement the Terraform code

  1. Create a directory in which to test the sample Terraform code and make it the current directory.

  2. Create a file named providers.tf and insert the following code:

    :::code language="Terraform" source="~/terraform_samples/quickstart/101-application-gateway/providers.tf":::

  3. Create a file named main.tf and insert the following code:

    :::code language="Terraform" source="~/terraform_samples/quickstart/101-application-gateway/main.tf":::

Tip

You can modify values of the Name and Tier parameters under resource\applicationGateWay\main\sku to use a different SKU. For example: Basic.

  1. Create a file named variables.tf and insert the following code:

    :::code language="Terraform" source="~/terraform_samples/quickstart/101-application-gateway/variables.tf":::

  2. Create a file named outputs.tf and insert the following code:

    :::code language="Terraform" source="~/terraform_samples/quickstart/101-application-gateway/outputs.tf":::

Initialize Terraform

[!INCLUDE terraform-init.md]

Create a Terraform execution plan

[!INCLUDE terraform-plan.md]

Apply a Terraform execution plan

[!INCLUDE terraform-apply-plan.md]

Verify the results

  1. When you apply the execution plan, Terraform displays the frontend public IP address. If you've cleared the screen, you can retrieve that value with the following Terraform command:

    echo $(terraform output -raw gateway_frontend_ip)
  2. Paste the public IP address into the address bar of your web browser. Refresh the browser to see the name of the virtual machine. A valid response verifies the application gateway is successfully created and can connect with the backend.

Clean up resources

[!INCLUDE terraform-plan-destroy.md]

Troubleshoot Terraform on Azure

Troubleshoot common problems when using Terraform on Azure

Next steps

[!div class="nextstepaction"] Learn more about using Application Gateway