1. Packages
  2. Vultr
  3. API Docs
  4. FirewallRule
Vultr v2.23.1 published on Tuesday, Dec 10, 2024 by dirien

vultr.FirewallRule

Explore with Pulumi AI

Provides a Vultr Firewall Rule resource. This can be used to create, read, modify, and delete Firewall rules.

Example Usage

Create a Firewall Rule

import * as pulumi from "@pulumi/pulumi";
import * as vultr from "@ediri/vultr";

const myFirewallgroup = new vultr.FirewallGroup("myFirewallgroup", {description: "base firewall"});
const myFirewallrule = new vultr.FirewallRule("myFirewallrule", {
    firewallGroupId: myFirewallgroup.id,
    protocol: "tcp",
    ipType: "v4",
    subnet: "0.0.0.0",
    subnetSize: 0,
    port: "8090",
    notes: "my firewall rule",
});
Copy
import pulumi
import ediri_vultr as vultr

my_firewallgroup = vultr.FirewallGroup("myFirewallgroup", description="base firewall")
my_firewallrule = vultr.FirewallRule("myFirewallrule",
    firewall_group_id=my_firewallgroup.id,
    protocol="tcp",
    ip_type="v4",
    subnet="0.0.0.0",
    subnet_size=0,
    port="8090",
    notes="my firewall rule")
Copy
package main

import (
	"github.com/dirien/pulumi-vultr/sdk/v2/go/vultr"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myFirewallgroup, err := vultr.NewFirewallGroup(ctx, "myFirewallgroup", &vultr.FirewallGroupArgs{
			Description: pulumi.String("base firewall"),
		})
		if err != nil {
			return err
		}
		_, err = vultr.NewFirewallRule(ctx, "myFirewallrule", &vultr.FirewallRuleArgs{
			FirewallGroupId: myFirewallgroup.ID(),
			Protocol:        pulumi.String("tcp"),
			IpType:          pulumi.String("v4"),
			Subnet:          pulumi.String("0.0.0.0"),
			SubnetSize:      pulumi.Int(0),
			Port:            pulumi.String("8090"),
			Notes:           pulumi.String("my firewall rule"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Vultr = ediri.Vultr;

return await Deployment.RunAsync(() => 
{
    var myFirewallgroup = new Vultr.FirewallGroup("myFirewallgroup", new()
    {
        Description = "base firewall",
    });

    var myFirewallrule = new Vultr.FirewallRule("myFirewallrule", new()
    {
        FirewallGroupId = myFirewallgroup.Id,
        Protocol = "tcp",
        IpType = "v4",
        Subnet = "0.0.0.0",
        SubnetSize = 0,
        Port = "8090",
        Notes = "my firewall rule",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vultr.FirewallGroup;
import com.pulumi.vultr.FirewallGroupArgs;
import com.pulumi.vultr.FirewallRule;
import com.pulumi.vultr.FirewallRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var myFirewallgroup = new FirewallGroup("myFirewallgroup", FirewallGroupArgs.builder()
            .description("base firewall")
            .build());

        var myFirewallrule = new FirewallRule("myFirewallrule", FirewallRuleArgs.builder()
            .firewallGroupId(myFirewallgroup.id())
            .protocol("tcp")
            .ipType("v4")
            .subnet("0.0.0.0")
            .subnetSize(0)
            .port("8090")
            .notes("my firewall rule")
            .build());

    }
}
Copy
resources:
  myFirewallgroup:
    type: vultr:FirewallGroup
    properties:
      description: base firewall
  myFirewallrule:
    type: vultr:FirewallRule
    properties:
      firewallGroupId: ${myFirewallgroup.id}
      protocol: tcp
      ipType: v4
      subnet: 0.0.0.0
      subnetSize: 0
      port: '8090'
      notes: my firewall rule
Copy

Create FirewallRule Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new FirewallRule(name: string, args: FirewallRuleArgs, opts?: CustomResourceOptions);
@overload
def FirewallRule(resource_name: str,
                 args: FirewallRuleArgs,
                 opts: Optional[ResourceOptions] = None)

@overload
def FirewallRule(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 firewall_group_id: Optional[str] = None,
                 ip_type: Optional[str] = None,
                 protocol: Optional[str] = None,
                 subnet: Optional[str] = None,
                 subnet_size: Optional[int] = None,
                 notes: Optional[str] = None,
                 port: Optional[str] = None,
                 source: Optional[str] = None)
func NewFirewallRule(ctx *Context, name string, args FirewallRuleArgs, opts ...ResourceOption) (*FirewallRule, error)
public FirewallRule(string name, FirewallRuleArgs args, CustomResourceOptions? opts = null)
public FirewallRule(String name, FirewallRuleArgs args)
public FirewallRule(String name, FirewallRuleArgs args, CustomResourceOptions options)
type: vultr:FirewallRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. FirewallRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. FirewallRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. FirewallRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. FirewallRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. FirewallRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var firewallRuleResource = new Vultr.FirewallRule("firewallRuleResource", new()
{
    FirewallGroupId = "string",
    IpType = "string",
    Protocol = "string",
    Subnet = "string",
    SubnetSize = 0,
    Notes = "string",
    Port = "string",
    Source = "string",
});
Copy
example, err := vultr.NewFirewallRule(ctx, "firewallRuleResource", &vultr.FirewallRuleArgs{
	FirewallGroupId: pulumi.String("string"),
	IpType:          pulumi.String("string"),
	Protocol:        pulumi.String("string"),
	Subnet:          pulumi.String("string"),
	SubnetSize:      pulumi.Int(0),
	Notes:           pulumi.String("string"),
	Port:            pulumi.String("string"),
	Source:          pulumi.String("string"),
})
Copy
var firewallRuleResource = new FirewallRule("firewallRuleResource", FirewallRuleArgs.builder()
    .firewallGroupId("string")
    .ipType("string")
    .protocol("string")
    .subnet("string")
    .subnetSize(0)
    .notes("string")
    .port("string")
    .source("string")
    .build());
Copy
firewall_rule_resource = vultr.FirewallRule("firewallRuleResource",
    firewall_group_id="string",
    ip_type="string",
    protocol="string",
    subnet="string",
    subnet_size=0,
    notes="string",
    port="string",
    source="string")
Copy
const firewallRuleResource = new vultr.FirewallRule("firewallRuleResource", {
    firewallGroupId: "string",
    ipType: "string",
    protocol: "string",
    subnet: "string",
    subnetSize: 0,
    notes: "string",
    port: "string",
    source: "string",
});
Copy
type: vultr:FirewallRule
properties:
    firewallGroupId: string
    ipType: string
    notes: string
    port: string
    protocol: string
    source: string
    subnet: string
    subnetSize: 0
Copy

FirewallRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The FirewallRule resource accepts the following input properties:

FirewallGroupId
This property is required.
Changes to this property will trigger replacement.
string
The firewall group that the firewall rule will belong to.
IpType
This property is required.
Changes to this property will trigger replacement.
string
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
Protocol
This property is required.
Changes to this property will trigger replacement.
string
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
Subnet
This property is required.
Changes to this property will trigger replacement.
string
IP address that you want to define for this firewall rule.
SubnetSize
This property is required.
Changes to this property will trigger replacement.
int
The number of bits for the subnet in CIDR notation. Example: 32.
Notes Changes to this property will trigger replacement. string
A simple note for a given firewall rule
Port Changes to this property will trigger replacement. string
TCP/UDP only. This field can be a specific port or a colon separated port range.
Source Changes to this property will trigger replacement. string
Possible values ("", cloudflare)
FirewallGroupId
This property is required.
Changes to this property will trigger replacement.
string
The firewall group that the firewall rule will belong to.
IpType
This property is required.
Changes to this property will trigger replacement.
string
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
Protocol
This property is required.
Changes to this property will trigger replacement.
string
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
Subnet
This property is required.
Changes to this property will trigger replacement.
string
IP address that you want to define for this firewall rule.
SubnetSize
This property is required.
Changes to this property will trigger replacement.
int
The number of bits for the subnet in CIDR notation. Example: 32.
Notes Changes to this property will trigger replacement. string
A simple note for a given firewall rule
Port Changes to this property will trigger replacement. string
TCP/UDP only. This field can be a specific port or a colon separated port range.
Source Changes to this property will trigger replacement. string
Possible values ("", cloudflare)
firewallGroupId
This property is required.
Changes to this property will trigger replacement.
String
The firewall group that the firewall rule will belong to.
ipType
This property is required.
Changes to this property will trigger replacement.
String
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
protocol
This property is required.
Changes to this property will trigger replacement.
String
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
subnet
This property is required.
Changes to this property will trigger replacement.
String
IP address that you want to define for this firewall rule.
subnetSize
This property is required.
Changes to this property will trigger replacement.
Integer
The number of bits for the subnet in CIDR notation. Example: 32.
notes Changes to this property will trigger replacement. String
A simple note for a given firewall rule
port Changes to this property will trigger replacement. String
TCP/UDP only. This field can be a specific port or a colon separated port range.
source Changes to this property will trigger replacement. String
Possible values ("", cloudflare)
firewallGroupId
This property is required.
Changes to this property will trigger replacement.
string
The firewall group that the firewall rule will belong to.
ipType
This property is required.
Changes to this property will trigger replacement.
string
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
protocol
This property is required.
Changes to this property will trigger replacement.
string
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
subnet
This property is required.
Changes to this property will trigger replacement.
string
IP address that you want to define for this firewall rule.
subnetSize
This property is required.
Changes to this property will trigger replacement.
number
The number of bits for the subnet in CIDR notation. Example: 32.
notes Changes to this property will trigger replacement. string
A simple note for a given firewall rule
port Changes to this property will trigger replacement. string
TCP/UDP only. This field can be a specific port or a colon separated port range.
source Changes to this property will trigger replacement. string
Possible values ("", cloudflare)
firewall_group_id
This property is required.
Changes to this property will trigger replacement.
str
The firewall group that the firewall rule will belong to.
ip_type
This property is required.
Changes to this property will trigger replacement.
str
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
protocol
This property is required.
Changes to this property will trigger replacement.
str
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
subnet
This property is required.
Changes to this property will trigger replacement.
str
IP address that you want to define for this firewall rule.
subnet_size
This property is required.
Changes to this property will trigger replacement.
int
The number of bits for the subnet in CIDR notation. Example: 32.
notes Changes to this property will trigger replacement. str
A simple note for a given firewall rule
port Changes to this property will trigger replacement. str
TCP/UDP only. This field can be a specific port or a colon separated port range.
source Changes to this property will trigger replacement. str
Possible values ("", cloudflare)
firewallGroupId
This property is required.
Changes to this property will trigger replacement.
String
The firewall group that the firewall rule will belong to.
ipType
This property is required.
Changes to this property will trigger replacement.
String
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
protocol
This property is required.
Changes to this property will trigger replacement.
String
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
subnet
This property is required.
Changes to this property will trigger replacement.
String
IP address that you want to define for this firewall rule.
subnetSize
This property is required.
Changes to this property will trigger replacement.
Number
The number of bits for the subnet in CIDR notation. Example: 32.
notes Changes to this property will trigger replacement. String
A simple note for a given firewall rule
port Changes to this property will trigger replacement. String
TCP/UDP only. This field can be a specific port or a colon separated port range.
source Changes to this property will trigger replacement. String
Possible values ("", cloudflare)

Outputs

All input properties are implicitly available as output properties. Additionally, the FirewallRule resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing FirewallRule Resource

Get an existing FirewallRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: FirewallRuleState, opts?: CustomResourceOptions): FirewallRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        firewall_group_id: Optional[str] = None,
        ip_type: Optional[str] = None,
        notes: Optional[str] = None,
        port: Optional[str] = None,
        protocol: Optional[str] = None,
        source: Optional[str] = None,
        subnet: Optional[str] = None,
        subnet_size: Optional[int] = None) -> FirewallRule
func GetFirewallRule(ctx *Context, name string, id IDInput, state *FirewallRuleState, opts ...ResourceOption) (*FirewallRule, error)
public static FirewallRule Get(string name, Input<string> id, FirewallRuleState? state, CustomResourceOptions? opts = null)
public static FirewallRule get(String name, Output<String> id, FirewallRuleState state, CustomResourceOptions options)
resources:  _:    type: vultr:FirewallRule    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
FirewallGroupId Changes to this property will trigger replacement. string
The firewall group that the firewall rule will belong to.
IpType Changes to this property will trigger replacement. string
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
Notes Changes to this property will trigger replacement. string
A simple note for a given firewall rule
Port Changes to this property will trigger replacement. string
TCP/UDP only. This field can be a specific port or a colon separated port range.
Protocol Changes to this property will trigger replacement. string
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
Source Changes to this property will trigger replacement. string
Possible values ("", cloudflare)
Subnet Changes to this property will trigger replacement. string
IP address that you want to define for this firewall rule.
SubnetSize Changes to this property will trigger replacement. int
The number of bits for the subnet in CIDR notation. Example: 32.
FirewallGroupId Changes to this property will trigger replacement. string
The firewall group that the firewall rule will belong to.
IpType Changes to this property will trigger replacement. string
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
Notes Changes to this property will trigger replacement. string
A simple note for a given firewall rule
Port Changes to this property will trigger replacement. string
TCP/UDP only. This field can be a specific port or a colon separated port range.
Protocol Changes to this property will trigger replacement. string
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
Source Changes to this property will trigger replacement. string
Possible values ("", cloudflare)
Subnet Changes to this property will trigger replacement. string
IP address that you want to define for this firewall rule.
SubnetSize Changes to this property will trigger replacement. int
The number of bits for the subnet in CIDR notation. Example: 32.
firewallGroupId Changes to this property will trigger replacement. String
The firewall group that the firewall rule will belong to.
ipType Changes to this property will trigger replacement. String
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
notes Changes to this property will trigger replacement. String
A simple note for a given firewall rule
port Changes to this property will trigger replacement. String
TCP/UDP only. This field can be a specific port or a colon separated port range.
protocol Changes to this property will trigger replacement. String
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
source Changes to this property will trigger replacement. String
Possible values ("", cloudflare)
subnet Changes to this property will trigger replacement. String
IP address that you want to define for this firewall rule.
subnetSize Changes to this property will trigger replacement. Integer
The number of bits for the subnet in CIDR notation. Example: 32.
firewallGroupId Changes to this property will trigger replacement. string
The firewall group that the firewall rule will belong to.
ipType Changes to this property will trigger replacement. string
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
notes Changes to this property will trigger replacement. string
A simple note for a given firewall rule
port Changes to this property will trigger replacement. string
TCP/UDP only. This field can be a specific port or a colon separated port range.
protocol Changes to this property will trigger replacement. string
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
source Changes to this property will trigger replacement. string
Possible values ("", cloudflare)
subnet Changes to this property will trigger replacement. string
IP address that you want to define for this firewall rule.
subnetSize Changes to this property will trigger replacement. number
The number of bits for the subnet in CIDR notation. Example: 32.
firewall_group_id Changes to this property will trigger replacement. str
The firewall group that the firewall rule will belong to.
ip_type Changes to this property will trigger replacement. str
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
notes Changes to this property will trigger replacement. str
A simple note for a given firewall rule
port Changes to this property will trigger replacement. str
TCP/UDP only. This field can be a specific port or a colon separated port range.
protocol Changes to this property will trigger replacement. str
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
source Changes to this property will trigger replacement. str
Possible values ("", cloudflare)
subnet Changes to this property will trigger replacement. str
IP address that you want to define for this firewall rule.
subnet_size Changes to this property will trigger replacement. int
The number of bits for the subnet in CIDR notation. Example: 32.
firewallGroupId Changes to this property will trigger replacement. String
The firewall group that the firewall rule will belong to.
ipType Changes to this property will trigger replacement. String
The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
notes Changes to this property will trigger replacement. String
A simple note for a given firewall rule
port Changes to this property will trigger replacement. String
TCP/UDP only. This field can be a specific port or a colon separated port range.
protocol Changes to this property will trigger replacement. String
The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
source Changes to this property will trigger replacement. String
Possible values ("", cloudflare)
subnet Changes to this property will trigger replacement. String
IP address that you want to define for this firewall rule.
subnetSize Changes to this property will trigger replacement. Number
The number of bits for the subnet in CIDR notation. Example: 32.

Import

Firewall Rules can be imported using the Firewall Group ID and Firewall Rule ID, e.g.

$ pulumi import vultr:index/firewallRule:FirewallRule my_rule b6a859c5-b299-49dd-8888-b1abbc517d08,1
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
vultr dirien/pulumi-vultr
License
Apache-2.0
Notes
This Pulumi package is based on the vultr Terraform Provider.