From 129c4dd61c0dda9d9d0627ddce709dc1c133d3a2 Mon Sep 17 00:00:00 2001 From: Luke Browning Date: Sat, 29 Jul 2023 19:22:06 -0700 Subject: [PATCH] Add firewall_alias examples & docs --- docs/data-sources/firewall_alias.md | 31 ++++++++ docs/resources/firewall_alias.md | 74 +++++++++++++++++++ .../opnsense_firewall_alias/resource.tf | 35 +++++++++ templates/data-sources/firewall_alias.md.tmpl | 20 +++++ templates/resources/firewall_alias.md.tmpl | 24 ++++++ 5 files changed, 184 insertions(+) create mode 100644 docs/data-sources/firewall_alias.md create mode 100644 docs/resources/firewall_alias.md create mode 100644 examples/resources/opnsense_firewall_alias/resource.tf create mode 100644 templates/data-sources/firewall_alias.md.tmpl create mode 100644 templates/resources/firewall_alias.md.tmpl diff --git a/docs/data-sources/firewall_alias.md b/docs/data-sources/firewall_alias.md new file mode 100644 index 0000000..347a8ef --- /dev/null +++ b/docs/data-sources/firewall_alias.md @@ -0,0 +1,31 @@ +--- +page_title: "opnsense_firewall_alias Data Source - terraform-provider-opnsense" +subcategory: Firewall +description: |- + Aliases are named lists of networks, hosts or ports that can be used as one entity by selecting the alias name in the various supported sections of the firewall. These aliases are particularly useful to condense firewall rules and minimize changes. +--- + +# opnsense_firewall_alias (Data Source) + +Aliases are named lists of networks, hosts or ports that can be used as one entity by selecting the alias name in the various supported sections of the firewall. These aliases are particularly useful to condense firewall rules and minimize changes. + + +## Schema + +### Required + +- `id` (String) UUID of the resource. + +### Read-Only + +- `categories` (Set of String) Set of category IDs to apply. +- `content` (Set of String) The content of the alias. Enter ISO 3166-1 country codes when `type = "geoip"` (e.g. `["CA", "FR"]`). Enter `___network`, or alias when `type = "networkgroup"` (e.g. `["__wan_network", "otheralias"]`). Enter OpenVPN group when `type = "authgroup"` (e.g. `["admins"]`). Set to `[]` when `type = "external"`. +- `description` (String) Optional description here for your reference (not parsed). +- `enabled` (Boolean) Enable this firewall alias. +- `interface` (String) Choose on which interface this alias applies. Only applies (and must be set) when `type = "dynipv6host"`. +- `ip_protocol` (String) Select the Internet Protocol version this alias applies to. Available values: `IPv4`, `IPv6`. Only applies when `type = "asn"`, `type = "geoip"`, or `type = "external"`. +- `name` (String) The name must start with a letter or single underscore, be less than 32 characters and only consist of alphanumeric characters or underscores. Aliases can be nested using this name. +- `stats` (Boolean) Whether to maintain a set of counters for each table entry. +- `type` (String) The type of alias. +- `update_freq` (Number) The frequency that the list will be refreshed, in days (e.g. for 30 hours, enter `1.25`). Only applies (and must be set) when `type = "urltable"`. + diff --git a/docs/resources/firewall_alias.md b/docs/resources/firewall_alias.md new file mode 100644 index 0000000..164427e --- /dev/null +++ b/docs/resources/firewall_alias.md @@ -0,0 +1,74 @@ +--- +page_title: "opnsense_firewall_alias Resource - terraform-provider-opnsense" +subcategory: Firewall +description: |- + Aliases are named lists of networks, hosts or ports that can be used as one entity by selecting the alias name in the various supported sections of the firewall. These aliases are particularly useful to condense firewall rules and minimize changes. +--- + +# opnsense_firewall_alias (Resource) + +Aliases are named lists of networks, hosts or ports that can be used as one entity by selecting the alias name in the various supported sections of the firewall. These aliases are particularly useful to condense firewall rules and minimize changes. + +## Example Usage + +```terraform +// Network example +resource "opnsense_firewall_alias" "example_one" { + name = "example_one" + + type = "network" + content = [ + "10.8.0.1/24", + "10.8.0.2/24" + ] + + stats = true + description = "Example" +} + +// With category +resource "opnsense_firewall_category" "example_one" { + name = "example" + color = "ffaa00" +} + +resource "opnsense_firewall_alias" "example_two" { + name = "example_two" + + type = "geoip" + content = [ + "FR", + "CA", + ] + + categories = [ + opnsense_firewall_category.example_one.id + ] + + description = "Example two" +} +``` + + +## Schema + +### Required + +- `name` (String) The name must start with a letter or single underscore, be less than 32 characters and only consist of alphanumeric characters or underscores. Aliases can be nested using this name. +- `type` (String) The type of alias. + +### Optional + +- `categories` (Set of String) Set of category IDs to apply. Defaults to `[]`. +- `content` (Set of String) The content of the alias. Enter ISO 3166-1 country codes when `type = "geoip"` (e.g. `["CA", "FR"]`). Enter `___network`, or alias when `type = "networkgroup"` (e.g. `["__wan_network", "otheralias"]`). Enter OpenVPN group when `type = "authgroup"` (e.g. `["admins"]`). Set to `[]` when `type = "external"`. Defaults to `[]`. +- `description` (String) Optional description here for your reference (not parsed). +- `enabled` (Boolean) Enable this firewall alias. Defaults to `true`. +- `interface` (String) Choose on which interface this alias applies. Only applies (and must be set) when `type = "dynipv6host"`. Defaults to `""`. +- `ip_protocol` (String) Select the Internet Protocol version this alias applies to. Available values: `IPv4`, `IPv6`. Only applies when `type = "asn"`, `type = "geoip"`, or `type = "external"`. Defaults to `IPv4`. +- `stats` (Boolean) Whether to maintain a set of counters for each table entry. +- `update_freq` (Number) The frequency that the list will be refreshed, in days (e.g. for 30 hours, enter `1.25`). Only applies (and must be set) when `type = "urltable"`. Defaults to `-1`. + +### Read-Only + +- `id` (String) UUID of the resource. + diff --git a/examples/resources/opnsense_firewall_alias/resource.tf b/examples/resources/opnsense_firewall_alias/resource.tf new file mode 100644 index 0000000..4a7ca8c --- /dev/null +++ b/examples/resources/opnsense_firewall_alias/resource.tf @@ -0,0 +1,35 @@ +// Network example +resource "opnsense_firewall_alias" "example_one" { + name = "example_one" + + type = "network" + content = [ + "10.8.0.1/24", + "10.8.0.2/24" + ] + + stats = true + description = "Example" +} + +// With category +resource "opnsense_firewall_category" "example_one" { + name = "example" + color = "ffaa00" +} + +resource "opnsense_firewall_alias" "example_two" { + name = "example_two" + + type = "geoip" + content = [ + "FR", + "CA", + ] + + categories = [ + opnsense_firewall_category.example_one.id + ] + + description = "Example two" +} diff --git a/templates/data-sources/firewall_alias.md.tmpl b/templates/data-sources/firewall_alias.md.tmpl new file mode 100644 index 0000000..53266a4 --- /dev/null +++ b/templates/data-sources/firewall_alias.md.tmpl @@ -0,0 +1,20 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.RenderedProviderName}}" +subcategory: Firewall +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +{{ .SchemaMarkdown | trimspace }} + +{{ if .HasImport -}} +## Import + +Import is supported using the following syntax: + +{{ printf "{{codefile \"shell\" %q}}" .ImportFile }} +{{- end }} \ No newline at end of file diff --git a/templates/resources/firewall_alias.md.tmpl b/templates/resources/firewall_alias.md.tmpl new file mode 100644 index 0000000..91b15ff --- /dev/null +++ b/templates/resources/firewall_alias.md.tmpl @@ -0,0 +1,24 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.RenderedProviderName}}" +subcategory: Firewall +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile (printf "%s%s%s" "examples/resources/" .Name "/resource.tf") }} + +{{ .SchemaMarkdown | trimspace }} + +{{ if .HasImport -}} +## Import + +Import is supported using the following syntax: + +{{ printf "{{codefile \"shell\" %q}}" .ImportFile }} +{{- end }} \ No newline at end of file