# Create or upload using Terraform Type of document: How-to guide Product: F5 Application Delivery Service > Create, upload, and update NGINX configurations for F5 Application Delivery Service using Terraform. --- You can apply an NGINX configuration to your F5 Application Delivery Service deployment using the F5 ADS Terraform provider. ## Overview Use the `f5ads_configuration` resource in the [`F5Networks/f5ads` Terraform provider](https://registry.terraform.io/providers/F5Networks/f5ads/latest/docs) to manage NGINX configurations for F5 Application Delivery Service. Provide configuration files as base64-encoded content. Applying changes to the files creates a new configuration version. Creating a configuration doesn't attach it to a deployment. For Google Cloud deployments, follow [Create a deployment](/f5ads/google/deploy/create-deployment/deploy-terraform.md#create-a-deployment) to apply the configuration. ## Prerequisites For Google Cloud deployments, meet the following prerequisites: - Confirm that you meet the [F5 ADS for Google Cloud prerequisites](/f5ads/google/deploy/prerequisites.md). - Access to a Google Cloud project to manage your network resources. - Access to the F5 ADS Console to create client credentials. See [Automate access with client credentials](/f5ads/platform/client-credentials.md). - [Install Terraform](https://learn.hashicorp.com/tutorials/terraform/install). **Note:** The `F5Networks/f5ads` provider is in alpha (`0.1.0-alpha.7`). Pin this exact version in your `required_providers` block, since breaking changes can occur between alpha releases. Review the [NGINX configuration rules and limits](/f5ads/platform/nginx-configuration/configuration-rules.md) before you upload your files. ## Configure the provider If you already configured the provider, use the same Terraform working directory. Otherwise, add the `f5ads` provider to your Terraform configuration and pin it to the exact alpha version: ```hcl terraform { required_providers { f5ads = { source = "F5Networks/f5ads" version = "0.1.0-alpha.7" } } } provider "f5ads" { geo = "us" } ``` The provider needs your Application Delivery Service client credentials to authenticate. You can supply them in the provider block or with environment variables. To supply credentials in the provider block, replace the previous provider block with the following example: ```hcl provider "f5ads" { geo = "us" client_id = "your-client-id" client_secret = "your-client-secret" } ``` Alternatively, set the following environment variables: ```shell export F5ADS_GEO="us" export F5ADS_CLIENT_ID="your-client-id" export F5ADS_CLIENT_SECRET="your-client-secret" ``` ## Create a configuration The following example returns an HTTP 200 response on port 80. ```hcl locals { nginx_conf = <<-EOT user nginx; worker_processes auto; pid /run/nginx/nginx.pid; worker_rlimit_nofile 524288; events { worker_connections 150000; } http { server { listen 80 backlog=2048 default_server; http2 on; server_name _; location / { return 200 "Hello from F5 ADS!"; } } } EOT } resource "f5ads_configuration" "example" { name = "example-config" description = "Example F5 ADS configuration managed by Terraform." configs = [ { name = "/etc/nginx" files = [ { name = "nginx.conf" contents = base64encode(local.nginx_conf) }, ] }, ] lifecycle { create_before_destroy = true } } ``` Use these settings for your configuration files: - For the main NGINX configuration file, set the directory `name` to `/etc/nginx` and the file `name` to `nginx.conf`. The provider requires this destination path. - Base64-encode file contents with `base64encode()` for inline content or `filebase64()` for local files. - Set either `name` or `name_prefix`, but not both. For all arguments, see the [`f5ads_configuration` resource documentation](https://registry.terraform.io/providers/F5Networks/f5ads/latest/docs/resources/configuration). Add other files to `files`, or add directory entries to `configs`, as needed. Include every file that your NGINX configuration references. ## Apply the configuration ```shell terraform init terraform plan terraform apply ``` Terraform creates the configuration. ## Replace a configuration safely Changes to configuration files create a new version without replacing the resource. Changes to `name` or `name_prefix` replace the resource itself. For configurations referenced by a deployment, use the `create_before_destroy` Terraform lifecycle block so that Terraform creates a new configuration, updates the deployment, and then deletes the old configuration. Replace the resource definition in **Create a configuration** with this example, keeping the `locals` block: ```hcl resource "f5ads_configuration" "example" { name_prefix = "example-config" description = "NGINX configuration uploaded with Terraform." configs = [ { name = "/etc/nginx" files = [ { name = "nginx.conf" contents = base64encode(local.nginx_conf) }, ] }, ] lifecycle { create_before_destroy = true } } ``` Review the replacement plan before applying it.