|
| 1 | +--- |
| 2 | +description: 'Terraform - Microsoft Azure provider for Nitric' |
| 3 | +--- |
| 4 | + |
| 5 | +# Terraform Azure Provider Overview |
| 6 | + |
| 7 | +_The officially supported Nitric Terraform Azure Provider._ |
| 8 | + |
| 9 | +```yaml |
| 10 | +provider: nitric/azuretf@latest |
| 11 | +``` |
| 12 | +
|
| 13 | +<Note> |
| 14 | + The Nitric Terraform Azure Provider is currently in preview, it's not |
| 15 | + recommended for production deployments. We recommend using the [Pulumi Azure |
| 16 | + Providers](/providers/pulumi/azure) for production deployments until the |
| 17 | + Terraform provider is stable. |
| 18 | +</Note> |
| 19 | +
|
| 20 | +## Prerequisites |
| 21 | +
|
| 22 | +The **Terraform CLI** is required to deploy the resulting Terraform Stack that Nitric generates. You can find the installation instructions for Terraform in the [Terraform documentation](https://learn.hashicorp.com/tutorials/terraform/install-cli). |
| 23 | +
|
| 24 | +The provider is built with the [Cloud Development Kit for Terraform (CDKTF)](https://developer.hashicorp.com/terraform/cdktf). Since CDKTF relies on Node.js, you'll need to have Node.js installed, you can read about the full CDKTF prerequisites in the [CDKTF documentation](https://developer.hashicorp.com/terraform/tutorials/cdktf/cdktf-install#prerequisites). |
| 25 | +
|
| 26 | +## Enabling Nitric Terraform Providers |
| 27 | +
|
| 28 | +The Nitric Terraform providers are currently in preview, to enable them you'll need to enable `beta-providers` in your Nitric project. You can do this by adding the following to your project's `nitric.yaml` file: |
| 29 | + |
| 30 | +```yaml title:nitric.yaml |
| 31 | +preview: |
| 32 | + - beta-providers |
| 33 | +``` |
| 34 | + |
| 35 | +## Azure Credentials |
| 36 | + |
| 37 | +The Terraform CLI typically uses standard Azure credential settings to authenticate with Azure. If you've set credentials for the Azure CLI or an Azure SDK previously, these settings should work without modification. |
| 38 | + |
| 39 | +If you're setting up your credentials for the first time, simply run azure login command and finish the login via your browser. |
| 40 | + |
| 41 | +```bash |
| 42 | +az login |
| 43 | +``` |
| 44 | + |
| 45 | +Verify the Azure CLI install - |
| 46 | + |
| 47 | +```bash |
| 48 | +az -v |
| 49 | +``` |
| 50 | + |
| 51 | +<Note> |
| 52 | + See [Azure |
| 53 | + documentation](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli) |
| 54 | + for full details on credentials and configuration. |
| 55 | +</Note> |
| 56 | + |
| 57 | +### Azure CLI Installation |
| 58 | + |
| 59 | +Installing the Azure CLI assists with credentials setup. You can install it using these summarized instructions, for more options see the [Microsoft docs](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli). |
| 60 | + |
| 61 | +<OSTabs> |
| 62 | + |
| 63 | +<TabItem label="Windows"> |
| 64 | + |
| 65 | +Download & install the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli). |
| 66 | + |
| 67 | +</TabItem> |
| 68 | + |
| 69 | +<TabItem label="Linux"> |
| 70 | + |
| 71 | +```bash |
| 72 | +curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash |
| 73 | +``` |
| 74 | + |
| 75 | +</TabItem> |
| 76 | + |
| 77 | +<TabItem label="macOS"> |
| 78 | + |
| 79 | +```bash |
| 80 | +brew update && brew install azure-cli |
| 81 | +``` |
| 82 | + |
| 83 | +</TabItem> |
| 84 | + |
| 85 | +</OSTabs> |
| 86 | + |
| 87 | +## Locating deployed resources |
| 88 | + |
| 89 | +This Nitric Azure provider deploys resources for a stack into a resource group dedicated to that stack. You can either use one that you already have by configuring it in the stack configuration or let Nitric create one for you. |
| 90 | + |
| 91 | +Once a stack has been deployed to Azure it's resource group should be present in the [Resource groups](https://portal.azure.com/#blade/HubsExtension/BrowseResourceGroupBlade/resourceType/Microsoft.Resources%2Fsubscriptions%2FresourceGroups) page of the portal. Assuming it was deployed to a subscription you have access to. |
| 92 | + |
| 93 | +<Note> |
| 94 | + Resource groups are conventionally named `<project-name>-<stack-name>-<randomId>` |
| 95 | + |
| 96 | +In this example the project name is `api-testing` and the stack name is `az`. |
| 97 | + |
| 98 | +</Note> |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +## Stack Configuration |
| 103 | + |
| 104 | +```yaml title:nitric.[stack ID].yaml |
| 105 | +# The provider to use and its published version |
| 106 | +# See releases: |
| 107 | +# https://github.com/nitrictech/nitric/tags |
| 108 | +provider: nitric/azuretf@latest |
| 109 | +
|
| 110 | +# The target Azure region to deploy to |
| 111 | +# See available regions: |
| 112 | +# https://azure.microsoft.com/en-us/explore/global-infrastructure/products-by-region/?products=container-apps |
| 113 | +region: my-azure-stack-region |
| 114 | +
|
| 115 | +# Org to associate deployed API Management services with |
| 116 | +org: example-org |
| 117 | +
|
| 118 | +# Admin email to associate deployed API Management services with |
| 119 | + |
| 120 | +
|
| 121 | +# Subscription ID to associate deployed services with |
| 122 | +subscription-id: example-subscription-id |
| 123 | +``` |
| 124 | + |
| 125 | +<Note> |
| 126 | + Missing something? Let us know by raising an issue in |
| 127 | + [GitHub](https://github.com/nitrictech/nitric) or by dropping us a line on |
| 128 | + [Discord](https://nitric.io/chat) |
| 129 | +</Note> |
0 commit comments