# Upload using Terraform Type of document: How-to guide Product: NGINXaaS for Azure --- ## Overview F5 NGINXaaS for Azure (NGINXaaS) configurations can be managed using Terraform. This document outlines common Terraform workflows for NGINXaaS. ## Prerequisites - Confirm that you meet the [NGINXaaS Prerequisites](/nginxaas-azure/getting-started/prerequisites.md). - [Authenticate Terraform to Azure](https://learn.microsoft.com/en-us/azure/developer/terraform/authenticate-to-azure) - [Install Terraform](https://learn.hashicorp.com/tutorials/terraform/install) **Note:** The examples in the NGINXaaS for Azure Snippets GitHub repository use the prerequisites module [available in the same repository](https://github.com/nginxinc/nginxaas-for-azure-snippets/tree/main/terraform/prerequisites). ## Upload an NGINX configuration You can find examples of Terraform configurations in the [NGINXaaS for Azure Snippets GitHub repository](https://github.com/nginxinc/nginxaas-for-azure-snippets/tree/main/terraform/configurations) To create a deployment and add a configuration, run the following commands: ```shell terraform init terraform plan terraform apply --auto-approve ``` ## Manage an NGINX configuration NGINX configuration files are uploaded and returned as base64 encoded data. We recommend using git or other version control systems to view human-readable differences between configuration files during `terraform plan`. Alternatively, you can decode the file contents to view the whole file. For example, ```shell $ terraform plan ... - config_file { - content = "aHR0cCB7CiAgICBzZXJ2ZXIgewogICAgICAgIGxvY2F0aW9uIC8gewogICAgICAgICAgICByZXR1cm4gMjAwICJIZWxsbyI7CiAgICAgICAgfQogICAgfQoK" -> null - virtual_path = "nginx.conf" -> null } + config_file { + content = "aHR0cCB7CiAgICBzZXJ2ZXIgewogICAgICAgIGxvY2F0aW9uIC8gewogICAgICAgICAgICByZXR1cm4gMjAwICJIZWxsbyBXb3JsZCEiOwogICAgICAgIH0KICAgIH0KfQoK" + virtual_path = "nginx.conf" } ... ``` ``` $ echo aHR0cCB7CiAgICBzZXJ2ZXIgewogICAgICAgIGxvY2F0aW9uIC8gewogICAgICAgICAgICByZXR1cm4gMjAwICJIZWxsbyBXb3JsZCEiOwogICAgICAgIH0KICAgIH0KfQoK | base64 --decode http { server { location / { return 200 "Hello World!"; } } } ``` ## Delete a deployment Once the deployment is no longer needed, run the following to clean up the deployment and related resources: ```shell terraform destroy --auto-approve ``` ## Additional resources - [Terraform NGINX configuration documentation](https://registry.terraform.io/providers/hashicorp/azurerm/3.97.0/docs/resources/nginx_configuration) - [NGINXaaS Managed Identity Documentation](/nginxaas-azure/getting-started/managed-identity-portal.md) - [NGINXaaS Azure Monitor Documentation](/nginxaas-azure/monitoring/enable-metrics.md) **Note:** See the [NGINX connfiguration overview](overview.md) topic to learn more about: - [NGINX configuration automation workflows](overview.md#nginx-configuration-automation-workflows) - [NGINX filesystem restrictions](overview.md#nginx-filesystem-restrictions) - [Disallowed configuration directives](overview.md#disallowed-configuration-directives) - [Directives that cannot be overridden](overview.md#directives-that-cannot-be-overridden) - [Configuration directives list](overview.md#configuration-directives-list)