firewall_rules
Creates, updates, deletes, gets or lists a firewall_rules resource.
Overview​
| Name | firewall_rules |
| Type | Resource |
| Id | ovh.ip.firewall_rules |
Fields​
The following fields are returned by SELECT queries:
- get
- list
successful operation
| Name | Datatype | Description |
|---|---|---|
action | string | Action on this rule (deny, permit) |
creation_date | string (date-time) | (wire: creationDate) |
destination | string | Destination ip for your rule |
destination_port | string | Destination port range for your rule. Only with TCP/UDP protocol (wire: destinationPort) |
fragments | boolean | Fragments option |
l_3_packet_length | string | IP packet's total length (wire: l3PacketLength) |
protocol | string | Network protocol (ah, esp, gre, icmp, ipv4, tcp, udp) |
rule | string | |
sequence | integer | |
source | string | Source ip for your rule |
source_port | string | Source port range for your rule. Only with TCP/UDP protocol (wire: sourcePort) |
state | string | Current state of your rule (creationPending, ok, removalPending) |
tcp_option | string | TCP option on your rule (wire: tcpOption) |
Rule on ip
| Name | Datatype | Description |
|---|---|---|
action | string | Action on this rule (deny, permit) |
creation_date | string (date-time) | (wire: creationDate) |
destination | string | Destination ip for your rule |
destination_port | string | Destination port range for your rule. Only with TCP/UDP protocol (wire: destinationPort) |
fragments | boolean | Fragments option |
l_3_packet_length | string | IP packet's total length (wire: l3PacketLength) |
protocol | string | Network protocol (ah, esp, gre, icmp, ipv4, tcp, udp) |
rule | string | |
sequence | integer | |
source | string | Source ip for your rule |
source_port | string | Source port range for your rule. Only with TCP/UDP protocol (wire: sourcePort) |
state | string | Current state of your rule (creationPending, ok, removalPending) |
tcp_option | string | TCP option on your rule (wire: tcpOption) |
Methods​
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | ip, ip_on_firewall, sequence | Get a rule. Returns the rule's action, protocol, source, destination, ports, TCP options, fragments option, packet length and state. | |
list | select | ip, ip_on_firewall | state, x_pagination_mode | List rules. Returns the sequence numbers of the address's firewall rules, filterable by state: creationPending, ok or removalPending. |
create | insert | ip, ip_on_firewall, action, protocol, sequence | Create a rule. Adds a permit or deny rule at sequence 0 to 19, matching protocol, source, ports or TCP options. | |
delete | delete | ip, ip_on_firewall, sequence | Delete a rule. Removes the rule at this sequence from the address's firewall, and returns the deleted rule. |
Parameters​
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
api_host | string | The OVHcloud API host. Selected by OVH_ENDPOINT (ovh-eu, ovh-ca or ovh-us; default ovh-eu). (default: api.eu.ovhcloud.com, x-stackQL-envVarSelector: {"envVar":"OVH_ENDPOINT","default":"ovh-eu","values":{"ovh-eu":"api.eu.ovhcloud.com","ovh-ca":"api.ca.ovhcloud.com","ovh-us":"api.us.ovhcloud.com"}}) |
ip | string (ip-block) | |
ip_on_firewall | string (ipv4) | (wire: ipOnFirewall) |
sequence | integer | |
state | string | Filter the value of state property (=) |
x_pagination_mode | string | Sent as CachedObjectList-Pages by default so the list returns the full objects rather than their identifiers. (wire: X-Pagination-Mode) |
SELECT examples​
- get
- list
Get a rule. Returns the rule's action, protocol, source, destination, ports, TCP options, fragments option, packet length and state.
SELECT
action,
creation_date,
destination,
destination_port,
fragments,
l_3_packet_length,
protocol,
rule,
sequence,
source,
source_port,
state,
tcp_option
FROM ovh.ip.firewall_rules
WHERE ip = '{{ ip }}' -- required
AND ip_on_firewall = '{{ ip_on_firewall }}' -- required
AND sequence = '{{ sequence }}' -- required
;
List rules. Returns the sequence numbers of the address's firewall rules, filterable by state: creationPending, ok or removalPending.
SELECT
action,
creation_date,
destination,
destination_port,
fragments,
l_3_packet_length,
protocol,
rule,
sequence,
source,
source_port,
state,
tcp_option
FROM ovh.ip.firewall_rules
WHERE ip = '{{ ip }}' -- required
AND ip_on_firewall = '{{ ip_on_firewall }}' -- required
AND state = '{{ state }}'
AND x_pagination_mode = '{{ x_pagination_mode }}'
;
INSERT examples​
- create
- Manifest
Create a rule. Adds a permit or deny rule at sequence 0 to 19, matching protocol, source, ports or TCP options.
INSERT INTO ovh.ip.firewall_rules (
action,
destination_port,
destination_port_range,
l_3_packet_length,
protocol,
sequence,
source,
source_port,
source_port_range,
tcp_option,
ip,
ip_on_firewall
)
SELECT
'{{ action }}' /* required */,
{{ destination_port }},
'{{ destination_port_range }}',
'{{ l_3_packet_length }}',
'{{ protocol }}' /* required */,
{{ sequence }} /* required */,
'{{ source }}',
{{ source_port }},
'{{ source_port_range }}',
'{{ tcp_option }}',
'{{ ip }}',
'{{ ip_on_firewall }}'
RETURNING
action,
creation_date,
destination,
destination_port,
fragments,
l_3_packet_length,
protocol,
rule,
sequence,
source,
source_port,
state,
tcp_option
;
# Description fields are for documentation purposes
- name: firewall_rules
props:
- name: ip
value: "{{ ip }}"
description: Required parameter for the firewall_rules resource.
- name: ip_on_firewall
value: "{{ ip_on_firewall }}"
description: Required parameter for the firewall_rules resource.
- name: action
value: "{{ action }}"
description: |
Action on this rule
valid_values: ['deny', 'permit']
- name: destination_port
value: {{ destination_port }}
description: |
Destination port for your rule. Only with TCP/UDP protocol
- name: destination_port_range
description: |
Destination port range for your rule. Only with TCP/UDP protocol. Cannot be set alongside destinationPort.
value:
from: {{ from }}
to: {{ to }}
- name: l_3_packet_length
description: |
IP packet's total length
value:
from: {{ from }}
to: {{ to }}
- name: protocol
value: "{{ protocol }}"
description: |
Network protocol
valid_values: ['ah', 'esp', 'gre', 'icmp', 'ipv4', 'tcp', 'udp']
- name: sequence
value: {{ sequence }}
description: |
Sequence number of your rule
valid_values: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19']
- name: source
value: "{{ source }}"
description: |
Source ip for your rule. Any if not set
- name: source_port
value: {{ source_port }}
description: |
Source port for your rule. Only with TCP/UDP protocol
- name: source_port_range
description: |
Source port range for your rule. Only with TCP/UDP protocol. Cannot be set alongside sourcePort.
value:
from: {{ from }}
to: {{ to }}
- name: tcp_option
description: |
Option on your rule. Can only be used with TCP protocol
value:
fragments: {{ fragments }}
option: "{{ option }}"
DELETE examples​
- delete
Delete a rule. Removes the rule at this sequence from the address's firewall, and returns the deleted rule.
DELETE FROM ovh.ip.firewall_rules
WHERE ip = '{{ ip }}' --required
AND ip_on_firewall = '{{ ip_on_firewall }}' --required
AND sequence = '{{ sequence }}' --required
;