NAT Gateway rule

nat_gateway_rule

This is a simple module that supports creating or removing NATGateway rules. This module has a dependency on ionoscloud >= 6.0.2

Example Syntax


name: Create NAT Gateway Rule
ionoscloudsdk.ionoscloud.nat_gateway_rule:
  datacenter: ''
  nat_gateway: ''
  name: 'AnsibleAutoTestNAT'
  type: SNAT
  protocol: TCP
  source_subnet: 10.0.1.0/24
  target_subnet: 10.0.1.0
  target_port_range:
    start: 10000
    end: 20000
  public_ip: ''
  wait: true
register: nat_gateway_rule_response


name: Update NAT Gateway Rule
ionoscloudsdk.ionoscloud.nat_gateway_rule:
  datacenter: ''
  nat_gateway: ''
  nat_gateway_rule: ''
  public_ip: ''
  name: 'AnsibleAutoTestNAT - UPDATED'
  type: SNAT
  protocol: TCP
  source_subnet: 10.0.1.0/24
  wait: true
  state: update
register: nat_gateway_rule_update_response


name: Delete NAT Gateway Rule
ionoscloudsdk.ionoscloud.nat_gateway_rule:
  datacenter: ''
  nat_gateway: ''
  nat_gateway_rule: ''
  state: absent

Returned object

{
    "changed": true,
    "failed": false,
    "action": "create",
    "nat_gateway_rule": {
        "href": "https://api.ionos.com/cloudapi/v6/datacenters/0406692b-b25f-4a58-8b41-e3b2d761447c/natgateways/abcc8593-a4a9-4ea0-b63c-04f95f395aa0/rules/42c85463-5b4f-485e-9e97-47dadc6d37ef",
        "id": "42c85463-5b4f-485e-9e97-47dadc6d37ef",
        "metadata": {
            "created_by": "<USER_EMAIL>",
            "created_by_user_id": "<USER_ID>",
            "created_date": "2023-05-31T11:53:14+00:00",
            "etag": "a0caa44599f8ef081cc93343a66c6738",
            "last_modified_by": "<USER_EMAIL>",
            "last_modified_by_user_id": "<USER_ID>",
            "last_modified_date": "2023-05-31T11:53:14+00:00",
            "state": "BUSY"
        },
        "properties": {
            "name": "AnsibleAutoTestNAT",
            "protocol": "TCP",
            "public_ip": "<IP1>",
            "source_subnet": "<SUBNET>",
            "target_port_range": {
                "end": 20000,
                "start": 10000
            },
            "target_subnet": "<SUBNET>",
            "type": "SNAT"
        },
        "type": "natgateway-rule"
    }
}

For more examples please check out the tests here.

state: present

  
name: Create NAT Gateway Rule
ionoscloudsdk.ionoscloud.nat_gateway_rule:
  datacenter: ''
  nat_gateway: ''
  name: 'AnsibleAutoTestNAT'
  type: SNAT
  protocol: TCP
  source_subnet: 10.0.1.0/24
  target_subnet: 10.0.1.0
  target_port_range:
    start: 10000
    end: 20000
  public_ip: ''
  wait: true
register: nat_gateway_rule_response

Available parameters for state present:

NameRequiredDescription

name str

True

The name of the NAT Gateway rule.

type str

True

Type of the NAT Gateway rule.

protocol str

False

Protocol of the NAT Gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.

source_subnet str

True

Source subnet of the NAT Gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.

public_ip str

True

Public IP address of the NAT Gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT Gateway resource

target_subnet str

False

Target or destination subnet of the NAT Gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.

target_port_range dict

False

Target port range of the NAT Gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port

datacenter str

True

The ID or name of the datacenter.

nat_gateway str

True

The ID or name of the NAT Gateway.

api_url str

False

The Ionos API base URL.

certificate_fingerprint str

False

The Ionos API certificate fingerprint.

username str

False

The Ionos username. Overrides the IONOS_USERNAME environment variable.

password str

False

The Ionos password. Overrides the IONOS_PASSWORD environment variable.

token str

False

The Ionos token. Overrides the IONOS_TOKEN environment variable.

wait bool

False

Wait for the resource to be created before returning. Default: True Options: [True, False]

wait_timeout int

False

How long before wait gives up, in seconds. Default: 600

state str

False

Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update']

state: absent

  
name: Delete NAT Gateway Rule
ionoscloudsdk.ionoscloud.nat_gateway_rule:
  datacenter: ''
  nat_gateway: ''
  nat_gateway_rule: ''
  state: absent

Available parameters for state absent:

NameRequiredDescription

name str

False

The name of the NAT Gateway rule.

datacenter str

True

The ID or name of the datacenter.

nat_gateway str

True

The ID or name of the NAT Gateway.

nat_gateway_rule str

True

The ID or name of the NAT Gateway rule.

api_url str

False

The Ionos API base URL.

certificate_fingerprint str

False

The Ionos API certificate fingerprint.

username str

False

The Ionos username. Overrides the IONOS_USERNAME environment variable.

password str

False

The Ionos password. Overrides the IONOS_PASSWORD environment variable.

token str

False

The Ionos token. Overrides the IONOS_TOKEN environment variable.

wait bool

False

Wait for the resource to be created before returning. Default: True Options: [True, False]

wait_timeout int

False

How long before wait gives up, in seconds. Default: 600

state str

False

Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update']

state: update

  
name: Update NAT Gateway Rule
ionoscloudsdk.ionoscloud.nat_gateway_rule:
  datacenter: ''
  nat_gateway: ''
  nat_gateway_rule: ''
  public_ip: ''
  name: 'AnsibleAutoTestNAT - UPDATED'
  type: SNAT
  protocol: TCP
  source_subnet: 10.0.1.0/24
  wait: true
  state: update
register: nat_gateway_rule_update_response

Available parameters for state update:

NameRequiredDescription

name str

False

The name of the NAT Gateway rule.

type str

False

Type of the NAT Gateway rule.

protocol str

False

Protocol of the NAT Gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.

source_subnet str

False

Source subnet of the NAT Gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.

public_ip str

False

Public IP address of the NAT Gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT Gateway resource

target_subnet str

False

Target or destination subnet of the NAT Gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.

target_port_range dict

False

Target port range of the NAT Gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port

datacenter str

True

The ID or name of the datacenter.

nat_gateway str

True

The ID or name of the NAT Gateway.

nat_gateway_rule str

True

The ID or name of the NAT Gateway rule.

api_url str

False

The Ionos API base URL.

certificate_fingerprint str

False

The Ionos API certificate fingerprint.

username str

False

The Ionos username. Overrides the IONOS_USERNAME environment variable.

password str

False

The Ionos password. Overrides the IONOS_PASSWORD environment variable.

token str

False

The Ionos token. Overrides the IONOS_TOKEN environment variable.

wait bool

False

Wait for the resource to be created before returning. Default: True Options: [True, False]

wait_timeout int

False

How long before wait gives up, in seconds. Default: 600

state str

False

Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update']

Last updated