1. Packages
  2. Vultr
  3. API Docs
  4. FirewallRule
Vultr v2.21.1 published on Monday, Jul 22, 2024 by dirien

vultr.FirewallRule

Explore with Pulumi AI

vultr logo
Vultr v2.21.1 published on Monday, Jul 22, 2024 by dirien

    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",
    });
    
    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")
    
    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
    	})
    }
    
    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",
        });
    
    });
    
    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());
    
        }
    }
    
    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
    

    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 string
    The unique name of the resource.
    args FirewallRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args 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 string
    The unique name of the resource.
    args FirewallRuleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args FirewallRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args 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",
    });
    
    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"),
    })
    
    var firewallRuleResource = new FirewallRule("firewallRuleResource", FirewallRuleArgs.builder()
        .firewallGroupId("string")
        .ipType("string")
        .protocol("string")
        .subnet("string")
        .subnetSize(0)
        .notes("string")
        .port("string")
        .source("string")
        .build());
    
    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")
    
    const firewallRuleResource = new vultr.FirewallRule("firewallRuleResource", {
        firewallGroupId: "string",
        ipType: "string",
        protocol: "string",
        subnet: "string",
        subnetSize: 0,
        notes: "string",
        port: "string",
        source: "string",
    });
    
    type: vultr:FirewallRule
    properties:
        firewallGroupId: string
        ipType: string
        notes: string
        port: string
        protocol: string
        source: string
        subnet: string
        subnetSize: 0
    

    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

    The FirewallRule resource accepts the following input properties:

    FirewallGroupId string
    The firewall group that the firewall rule will belong to.
    IpType string
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    Protocol string
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    Subnet string
    IP address that you want to define for this firewall rule.
    SubnetSize int
    The number of bits for the subnet in CIDR notation. Example: 32.
    Notes string
    A simple note for a given firewall rule
    Port string
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    Source string
    Possible values ("", cloudflare)
    FirewallGroupId string
    The firewall group that the firewall rule will belong to.
    IpType string
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    Protocol string
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    Subnet string
    IP address that you want to define for this firewall rule.
    SubnetSize int
    The number of bits for the subnet in CIDR notation. Example: 32.
    Notes string
    A simple note for a given firewall rule
    Port string
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    Source string
    Possible values ("", cloudflare)
    firewallGroupId String
    The firewall group that the firewall rule will belong to.
    ipType String
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    protocol String
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    subnet String
    IP address that you want to define for this firewall rule.
    subnetSize Integer
    The number of bits for the subnet in CIDR notation. Example: 32.
    notes String
    A simple note for a given firewall rule
    port String
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    source String
    Possible values ("", cloudflare)
    firewallGroupId string
    The firewall group that the firewall rule will belong to.
    ipType string
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    protocol string
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    subnet string
    IP address that you want to define for this firewall rule.
    subnetSize number
    The number of bits for the subnet in CIDR notation. Example: 32.
    notes string
    A simple note for a given firewall rule
    port string
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    source string
    Possible values ("", cloudflare)
    firewall_group_id str
    The firewall group that the firewall rule will belong to.
    ip_type str
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    protocol str
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    subnet str
    IP address that you want to define for this firewall rule.
    subnet_size int
    The number of bits for the subnet in CIDR notation. Example: 32.
    notes str
    A simple note for a given firewall rule
    port str
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    source str
    Possible values ("", cloudflare)
    firewallGroupId String
    The firewall group that the firewall rule will belong to.
    ipType String
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    protocol String
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    subnet String
    IP address that you want to define for this firewall rule.
    subnetSize Number
    The number of bits for the subnet in CIDR notation. Example: 32.
    notes String
    A simple note for a given firewall rule
    port String
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    source 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)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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 string
    The firewall group that the firewall rule will belong to.
    IpType string
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    Notes string
    A simple note for a given firewall rule
    Port string
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    Protocol string
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    Source string
    Possible values ("", cloudflare)
    Subnet string
    IP address that you want to define for this firewall rule.
    SubnetSize int
    The number of bits for the subnet in CIDR notation. Example: 32.
    FirewallGroupId string
    The firewall group that the firewall rule will belong to.
    IpType string
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    Notes string
    A simple note for a given firewall rule
    Port string
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    Protocol string
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    Source string
    Possible values ("", cloudflare)
    Subnet string
    IP address that you want to define for this firewall rule.
    SubnetSize int
    The number of bits for the subnet in CIDR notation. Example: 32.
    firewallGroupId String
    The firewall group that the firewall rule will belong to.
    ipType String
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    notes String
    A simple note for a given firewall rule
    port String
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    protocol String
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    source String
    Possible values ("", cloudflare)
    subnet String
    IP address that you want to define for this firewall rule.
    subnetSize Integer
    The number of bits for the subnet in CIDR notation. Example: 32.
    firewallGroupId string
    The firewall group that the firewall rule will belong to.
    ipType string
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    notes string
    A simple note for a given firewall rule
    port string
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    protocol string
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    source string
    Possible values ("", cloudflare)
    subnet string
    IP address that you want to define for this firewall rule.
    subnetSize number
    The number of bits for the subnet in CIDR notation. Example: 32.
    firewall_group_id str
    The firewall group that the firewall rule will belong to.
    ip_type str
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    notes str
    A simple note for a given firewall rule
    port str
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    protocol str
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    source str
    Possible values ("", cloudflare)
    subnet str
    IP address that you want to define for this firewall rule.
    subnet_size int
    The number of bits for the subnet in CIDR notation. Example: 32.
    firewallGroupId String
    The firewall group that the firewall rule will belong to.
    ipType String
    The type of ip for this firewall rule. Possible values (v4, v6) Note they must be lowercase
    notes String
    A simple note for a given firewall rule
    port String
    TCP/UDP only. This field can be a specific port or a colon separated port range.
    protocol String
    The type of protocol for this firewall rule. Possible values (icmp, tcp, udp, gre, esp, ah) Note they must be lowercase
    source String
    Possible values ("", cloudflare)
    subnet String
    IP address that you want to define for this firewall rule.
    subnetSize 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
    

    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.
    vultr logo
    Vultr v2.21.1 published on Monday, Jul 22, 2024 by dirien