# Security - Terraform Resources

import DocButton from '~/components/webkit/DocButton.vue';

<DocButton href="https://registry.terraform.io/providers/aziontech/azion/latest/docs/resources/firewall_main_setting" label="View in Terraform Registry" kind="secondary" size="medium" />

Protect your applications with Azion security resources. Manage firewall, WAF, and network lists through Terraform.

---

The security resources allow you to configure protection against threats, geolocation blocking, rate limiting, and much more.

### Available Resources

| Resource | Description |
|---------|-------------|
| [`azion_firewall_main_setting`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/resources/firewall_main_setting) | Firewall main settings |
| [`azion_firewall_functions_instance`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/resources/firewall_functions_instance) | Function instances in firewall |
| [`azion_waf_rule_set`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/resources/waf_rule_set) | WAF rule sets |
| [`azion_network_list`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/resources/network_list) | Network lists (IPs, CIDRs, countries) |

### Available Data Sources

| Data Source | Description |
|--------------|-------------|
| [`azion_firewall_main_settings`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/data-sources/firewall_main_settings) | Query firewall settings |
| [`azion_firewall_function_instances`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/data-sources/firewall_function_instances) | Query function instances |
| [`azion_network_lists`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/data-sources/network_lists) | Query network lists |
| [`azion_waf_rule_sets`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/data-sources/waf_rule_sets) | Query WAF rule sets |

---

## azion_firewall_main_setting

### Basic Example

```hcl
resource "azion_firewall_main_setting" "example" {
  name  = "my-firewall"
  active = true
  
  # Activated modules
}
```

### Main Arguments

| Argument | Type | Required | Description |
|-----------|------|----------|-------------|
| `name` | string | Yes | Firewall name |
| `active` | bool | No | Whether the firewall is active |

For the complete list of arguments, see the [Terraform Registry](https://registry.terraform.io/providers/aziontech/azion/latest/docs/resources/firewall_main_setting).

---

## azion_network_list

### Basic Example

```hcl
resource "azion_network_list" "blocked_ips" {
  name = "blocked-ips"
  list_type = "ip_cidr"
  
  # List of IPs/CIDRs
}
```

### Main Arguments

| Argument | Type | Required | Description |
|-----------|------|----------|-------------|
| `name` | string | Yes | List name |
| `list_type` | string | Yes | List type (ip_cidr, countries, asns) |

---

## azion_waf_rule_set

### Basic Example

```hcl
resource "azion_waf_rule_set" "example" {
  name = "my-waf-rules"
  
  # WAF configuration
}
```

---

## Complete Example

```hcl
terraform {
  required_providers {
    azion = {
      source  = "aziontech/azion"
      version = "2.0.0"
    }
  }
}

provider "azion" {
  api_token = var.api_token
}

# Create network list for blocked IPs
resource "azion_network_list" "blocked_ips" {
  name      = "blocked-ips"
  list_type = "ip_cidr"
}

# Create firewall
resource "azion_firewall_main_setting" "my_firewall" {
  name   = "my-firewall"
  active = true
  
  # Link to workload/application
}

# Create WAF rule set
resource "azion_waf_rule_set" "my_waf" {
  name = "my-waf"
  
  # WAF configuration
}

output "firewall_id" {
  value = azion_firewall_main_setting.my_firewall.id
}
```

---

## Related Resources

- [Applications](/en/documentation/products/terraform-provider/resources/applications/) - Manage applications
- [DNS](/en/documentation/products/terraform-provider/resources/dns/) - Manage DNS
- [Certificates](/en/documentation/products/terraform-provider/resources/certificates/) - Manage certificates
- [Migration Guide](/en/documentation/products/terraform-provider/terraform-migration-v3-to-v4/) - Migrate from v1.x to v2.0