Firewall

Provides a Hetzner Cloud Firewall to represent a Firewall in the Hetzner Cloud.

Example Usage

using Pulumi;
using HCloud = Pulumi.HCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var myfirewall = new HCloud.Firewall("myfirewall", new HCloud.FirewallArgs
        {
            Rules = 
            {
                new HCloud.Inputs.FirewallRuleArgs
                {
                    Direction = "in",
                    Protocol = "icmp",
                    SourceIps = 
                    {
                        "0.0.0.0/0",
                        "::/0",
                    },
                },
            },
        });
        var node1 = new HCloud.Server("node1", new HCloud.ServerArgs
        {
            Image = "debian-9",
            ServerType = "cx11",
            FirewallIds = 
            {
                myfirewall.Id,
            },
        });
    }

}

Coming soon!

import pulumi
import pulumi_hcloud as hcloud

myfirewall = hcloud.Firewall("myfirewall", rules=[hcloud.FirewallRuleArgs(
    direction="in",
    protocol="icmp",
    source_ips=[
        "0.0.0.0/0",
        "::/0",
    ],
)])
node1 = hcloud.Server("node1",
    image="debian-9",
    server_type="cx11",
    firewall_ids=[myfirewall.id])
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const myfirewall = new hcloud.Firewall("myfirewall", {rules: [{
    direction: "in",
    protocol: "icmp",
    sourceIps: [
        "0.0.0.0/0",
        "::/0",
    ],
}]});
const node1 = new hcloud.Server("node1", {
    image: "debian-9",
    serverType: "cx11",
    firewallIds: [myfirewall.id],
});

Create a Firewall Resource

new Firewall(name: string, args?: FirewallArgs, opts?: CustomResourceOptions);
@overload
def Firewall(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             labels: Optional[Mapping[str, Any]] = None,
             name: Optional[str] = None,
             rules: Optional[Sequence[FirewallRuleArgs]] = None)
@overload
def Firewall(resource_name: str,
             args: Optional[FirewallArgs] = None,
             opts: Optional[ResourceOptions] = None)
func NewFirewall(ctx *Context, name string, args *FirewallArgs, opts ...ResourceOption) (*Firewall, error)
public Firewall(string name, FirewallArgs? args = null, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args FirewallArgs
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 FirewallArgs
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 FirewallArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args FirewallArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Firewall Resource Properties

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

Inputs

The Firewall resource accepts the following input properties:

Labels Dictionary<string, object>
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Firewall.
Rules List<Pulumi.HCloud.Inputs.FirewallRuleArgs>
Configuration of a Rule from this Firewall.
Labels map[string]interface{}
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Firewall.
Rules []FirewallRule
Configuration of a Rule from this Firewall.
labels {[key: string]: any}
User-defined labels (key-value pairs) should be created with.
name string
Name of the Firewall.
rules FirewallRuleArgs[]
Configuration of a Rule from this Firewall.
labels Mapping[str, Any]
User-defined labels (key-value pairs) should be created with.
name str
Name of the Firewall.
rules Sequence[FirewallRuleArgs]
Configuration of a Rule from this Firewall.

Outputs

All input properties are implicitly available as output properties. Additionally, the Firewall 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 str
The provider-assigned unique ID for this managed resource.

Look up an Existing Firewall Resource

Get an existing Firewall 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?: FirewallState, opts?: CustomResourceOptions): Firewall
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        labels: Optional[Mapping[str, Any]] = None,
        name: Optional[str] = None,
        rules: Optional[Sequence[FirewallRuleArgs]] = None) -> Firewall
func GetFirewall(ctx *Context, name string, id IDInput, state *FirewallState, opts ...ResourceOption) (*Firewall, error)
public static Firewall Get(string name, Input<string> id, FirewallState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

Labels Dictionary<string, object>
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Firewall.
Rules List<Pulumi.HCloud.Inputs.FirewallRuleArgs>
Configuration of a Rule from this Firewall.
Labels map[string]interface{}
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Firewall.
Rules []FirewallRule
Configuration of a Rule from this Firewall.
labels {[key: string]: any}
User-defined labels (key-value pairs) should be created with.
name string
Name of the Firewall.
rules FirewallRuleArgs[]
Configuration of a Rule from this Firewall.
labels Mapping[str, Any]
User-defined labels (key-value pairs) should be created with.
name str
Name of the Firewall.
rules Sequence[FirewallRuleArgs]
Configuration of a Rule from this Firewall.

Supporting Types

FirewallRule

Direction string
Direction of the Firewall Rule. in
Protocol string
Protocol of the Firewall Rule. tcp, icmp, udp
DestinationIps List<string>
Port string
Port of the Firewall Rule. Required when protocol is tcp or udp
SourceIps List<string>
List of CIDRs that are allowed within this Firewall Rule
Direction string
Direction of the Firewall Rule. in
Protocol string
Protocol of the Firewall Rule. tcp, icmp, udp
DestinationIps []string
Port string
Port of the Firewall Rule. Required when protocol is tcp or udp
SourceIps []string
List of CIDRs that are allowed within this Firewall Rule
direction string
Direction of the Firewall Rule. in
protocol string
Protocol of the Firewall Rule. tcp, icmp, udp
destinationIps string[]
port string
Port of the Firewall Rule. Required when protocol is tcp or udp
sourceIps string[]
List of CIDRs that are allowed within this Firewall Rule
direction str
Direction of the Firewall Rule. in
protocol str
Protocol of the Firewall Rule. tcp, icmp, udp
destination_ips Sequence[str]
port str
Port of the Firewall Rule. Required when protocol is tcp or udp
source_ips Sequence[str]
List of CIDRs that are allowed within this Firewall Rule

Import

Firewalls can be imported using its id

 $ pulumi import hcloud:index/firewall:Firewall myfw <id>

Package Details

Repository
https://github.com/pulumi/pulumi-hcloud
License
Apache-2.0
Notes
This Pulumi package is based on the hcloud Terraform Provider.