Upload using Terraform

Overview

F5 NGINX as a Service for Azure (NGINXaaS) configurations can be managed using Terraform. This document outlines common Terraform workflows for NGINXaaS.

Prerequisites

Caution:
The examples in the NGINXaaS for Azure Snippets GitHub repository use the prerequisites module available in the same repository.

Upload an NGINX configuration

You can find examples of Terraform configurations in the NGINXaaS for Azure Snippets GitHub repository

To create a deployment and add a configuration, run the following commands:

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,

$ 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:

terraform destroy --auto-approve

Additional resources

Tip:

See the NGINX connfiguration overview topic to learn more about:


Last modified October 14, 2024