1. Packages
  2. Hcloud Provider
  3. API Docs
  4. getFirewall
Hetzner Cloud v1.22.0 published on Wednesday, Feb 26, 2025 by Pulumi

hcloud.getFirewall

Explore with Pulumi AI

Hetzner Cloud v1.22.0 published on Wednesday, Feb 26, 2025 by Pulumi

Provides details about a specific Hetzner Cloud Firewall.

import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const sampleFirewall1 = hcloud.getFirewall({
    name: "sample-firewall-1",
});
const sampleFirewall2 = hcloud.getFirewall({
    id: 4711,
});
Copy
import pulumi
import pulumi_hcloud as hcloud

sample_firewall1 = hcloud.get_firewall(name="sample-firewall-1")
sample_firewall2 = hcloud.get_firewall(id=4711)
Copy
package main

import (
	"github.com/pulumi/pulumi-hcloud/sdk/go/hcloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := hcloud.LookupFirewall(ctx, &hcloud.LookupFirewallArgs{
			Name: pulumi.StringRef("sample-firewall-1"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = hcloud.LookupFirewall(ctx, &hcloud.LookupFirewallArgs{
			Id: pulumi.IntRef(4711),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using HCloud = Pulumi.HCloud;

return await Deployment.RunAsync(() => 
{
    var sampleFirewall1 = HCloud.GetFirewall.Invoke(new()
    {
        Name = "sample-firewall-1",
    });

    var sampleFirewall2 = HCloud.GetFirewall.Invoke(new()
    {
        Id = 4711,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcloud.HcloudFunctions;
import com.pulumi.hcloud.inputs.GetFirewallArgs;
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) {
        final var sampleFirewall1 = HcloudFunctions.getFirewall(GetFirewallArgs.builder()
            .name("sample-firewall-1")
            .build());

        final var sampleFirewall2 = HcloudFunctions.getFirewall(GetFirewallArgs.builder()
            .id("4711")
            .build());

    }
}
Copy
variables:
  sampleFirewall1:
    fn::invoke:
      function: hcloud:getFirewall
      arguments:
        name: sample-firewall-1
  sampleFirewall2:
    fn::invoke:
      function: hcloud:getFirewall
      arguments:
        id: '4711'
Copy

Using getFirewall

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getFirewall(args: GetFirewallArgs, opts?: InvokeOptions): Promise<GetFirewallResult>
function getFirewallOutput(args: GetFirewallOutputArgs, opts?: InvokeOptions): Output<GetFirewallResult>
Copy
def get_firewall(apply_tos: Optional[Sequence[GetFirewallApplyTo]] = None,
                 id: Optional[int] = None,
                 labels: Optional[Mapping[str, str]] = None,
                 most_recent: Optional[bool] = None,
                 name: Optional[str] = None,
                 rules: Optional[Sequence[GetFirewallRule]] = None,
                 with_selector: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetFirewallResult
def get_firewall_output(apply_tos: Optional[pulumi.Input[Sequence[pulumi.Input[GetFirewallApplyToArgs]]]] = None,
                 id: Optional[pulumi.Input[int]] = None,
                 labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                 most_recent: Optional[pulumi.Input[bool]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 rules: Optional[pulumi.Input[Sequence[pulumi.Input[GetFirewallRuleArgs]]]] = None,
                 with_selector: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetFirewallResult]
Copy
func LookupFirewall(ctx *Context, args *LookupFirewallArgs, opts ...InvokeOption) (*LookupFirewallResult, error)
func LookupFirewallOutput(ctx *Context, args *LookupFirewallOutputArgs, opts ...InvokeOption) LookupFirewallResultOutput
Copy

> Note: This function is named LookupFirewall in the Go SDK.

public static class GetFirewall 
{
    public static Task<GetFirewallResult> InvokeAsync(GetFirewallArgs args, InvokeOptions? opts = null)
    public static Output<GetFirewallResult> Invoke(GetFirewallInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetFirewallResult> getFirewall(GetFirewallArgs args, InvokeOptions options)
public static Output<GetFirewallResult> getFirewall(GetFirewallArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: hcloud:index/getFirewall:getFirewall
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

ApplyTos List<Pulumi.HCloud.Inputs.GetFirewallApplyTo>
Configuration of the Applied Resources
Id int
ID of the firewall.
Labels Dictionary<string, string>
(map) User-defined labels (key-value pairs)
MostRecent bool
Return most recent firewall if multiple are found.
Name string
Name of the firewall.
Rules List<Pulumi.HCloud.Inputs.GetFirewallRule>
(string) Configuration of a Rule from this Firewall.
WithSelector string
Label selector
ApplyTos []GetFirewallApplyTo
Configuration of the Applied Resources
Id int
ID of the firewall.
Labels map[string]string
(map) User-defined labels (key-value pairs)
MostRecent bool
Return most recent firewall if multiple are found.
Name string
Name of the firewall.
Rules []GetFirewallRule
(string) Configuration of a Rule from this Firewall.
WithSelector string
Label selector
applyTos List<GetFirewallApplyTo>
Configuration of the Applied Resources
id Integer
ID of the firewall.
labels Map<String,String>
(map) User-defined labels (key-value pairs)
mostRecent Boolean
Return most recent firewall if multiple are found.
name String
Name of the firewall.
rules List<GetFirewallRule>
(string) Configuration of a Rule from this Firewall.
withSelector String
Label selector
applyTos GetFirewallApplyTo[]
Configuration of the Applied Resources
id number
ID of the firewall.
labels {[key: string]: string}
(map) User-defined labels (key-value pairs)
mostRecent boolean
Return most recent firewall if multiple are found.
name string
Name of the firewall.
rules GetFirewallRule[]
(string) Configuration of a Rule from this Firewall.
withSelector string
Label selector
apply_tos Sequence[GetFirewallApplyTo]
Configuration of the Applied Resources
id int
ID of the firewall.
labels Mapping[str, str]
(map) User-defined labels (key-value pairs)
most_recent bool
Return most recent firewall if multiple are found.
name str
Name of the firewall.
rules Sequence[GetFirewallRule]
(string) Configuration of a Rule from this Firewall.
with_selector str
Label selector
applyTos List<Property Map>
Configuration of the Applied Resources
id Number
ID of the firewall.
labels Map<String>
(map) User-defined labels (key-value pairs)
mostRecent Boolean
Return most recent firewall if multiple are found.
name String
Name of the firewall.
rules List<Property Map>
(string) Configuration of a Rule from this Firewall.
withSelector String
Label selector

getFirewall Result

The following output properties are available:

Name string
(string) Name of the Firewall.
ApplyTos List<Pulumi.HCloud.Outputs.GetFirewallApplyTo>
Configuration of the Applied Resources
Id int
(int) Unique ID of the Firewall.
Labels Dictionary<string, string>
(map) User-defined labels (key-value pairs)
MostRecent bool
Rules List<Pulumi.HCloud.Outputs.GetFirewallRule>
(string) Configuration of a Rule from this Firewall.
WithSelector string
Name string
(string) Name of the Firewall.
ApplyTos []GetFirewallApplyTo
Configuration of the Applied Resources
Id int
(int) Unique ID of the Firewall.
Labels map[string]string
(map) User-defined labels (key-value pairs)
MostRecent bool
Rules []GetFirewallRule
(string) Configuration of a Rule from this Firewall.
WithSelector string
name String
(string) Name of the Firewall.
applyTos List<GetFirewallApplyTo>
Configuration of the Applied Resources
id Integer
(int) Unique ID of the Firewall.
labels Map<String,String>
(map) User-defined labels (key-value pairs)
mostRecent Boolean
rules List<GetFirewallRule>
(string) Configuration of a Rule from this Firewall.
withSelector String
name string
(string) Name of the Firewall.
applyTos GetFirewallApplyTo[]
Configuration of the Applied Resources
id number
(int) Unique ID of the Firewall.
labels {[key: string]: string}
(map) User-defined labels (key-value pairs)
mostRecent boolean
rules GetFirewallRule[]
(string) Configuration of a Rule from this Firewall.
withSelector string
name str
(string) Name of the Firewall.
apply_tos Sequence[GetFirewallApplyTo]
Configuration of the Applied Resources
id int
(int) Unique ID of the Firewall.
labels Mapping[str, str]
(map) User-defined labels (key-value pairs)
most_recent bool
rules Sequence[GetFirewallRule]
(string) Configuration of a Rule from this Firewall.
with_selector str
name String
(string) Name of the Firewall.
applyTos List<Property Map>
Configuration of the Applied Resources
id Number
(int) Unique ID of the Firewall.
labels Map<String>
(map) User-defined labels (key-value pairs)
mostRecent Boolean
rules List<Property Map>
(string) Configuration of a Rule from this Firewall.
withSelector String

Supporting Types

GetFirewallApplyTo

LabelSelector This property is required. string
(string) Label Selector to select servers the firewall is applied to. Empty if a server is directly referenced
Server This property is required. int
(int) ID of a server where the firewall is applied to. 0 if applied to a label_selector
LabelSelector This property is required. string
(string) Label Selector to select servers the firewall is applied to. Empty if a server is directly referenced
Server This property is required. int
(int) ID of a server where the firewall is applied to. 0 if applied to a label_selector
labelSelector This property is required. String
(string) Label Selector to select servers the firewall is applied to. Empty if a server is directly referenced
server This property is required. Integer
(int) ID of a server where the firewall is applied to. 0 if applied to a label_selector
labelSelector This property is required. string
(string) Label Selector to select servers the firewall is applied to. Empty if a server is directly referenced
server This property is required. number
(int) ID of a server where the firewall is applied to. 0 if applied to a label_selector
label_selector This property is required. str
(string) Label Selector to select servers the firewall is applied to. Empty if a server is directly referenced
server This property is required. int
(int) ID of a server where the firewall is applied to. 0 if applied to a label_selector
labelSelector This property is required. String
(string) Label Selector to select servers the firewall is applied to. Empty if a server is directly referenced
server This property is required. Number
(int) ID of a server where the firewall is applied to. 0 if applied to a label_selector

GetFirewallRule

Direction This property is required. string
(Required, string) Direction of the Firewall Rule. in, out
Description string
(Optional, string) Description of the firewall rule
DestinationIps List<string>
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is out)
Port string
(Required, string) Port of the Firewall Rule. Required when protocol is tcp or udp
Protocol string
(Required, string) Protocol of the Firewall Rule. tcp, icmp, udp, gre, esp
SourceIps List<string>
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is in)
Direction This property is required. string
(Required, string) Direction of the Firewall Rule. in, out
Description string
(Optional, string) Description of the firewall rule
DestinationIps []string
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is out)
Port string
(Required, string) Port of the Firewall Rule. Required when protocol is tcp or udp
Protocol string
(Required, string) Protocol of the Firewall Rule. tcp, icmp, udp, gre, esp
SourceIps []string
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is in)
direction This property is required. String
(Required, string) Direction of the Firewall Rule. in, out
description String
(Optional, string) Description of the firewall rule
destinationIps List<String>
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is out)
port String
(Required, string) Port of the Firewall Rule. Required when protocol is tcp or udp
protocol String
(Required, string) Protocol of the Firewall Rule. tcp, icmp, udp, gre, esp
sourceIps List<String>
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is in)
direction This property is required. string
(Required, string) Direction of the Firewall Rule. in, out
description string
(Optional, string) Description of the firewall rule
destinationIps string[]
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is out)
port string
(Required, string) Port of the Firewall Rule. Required when protocol is tcp or udp
protocol string
(Required, string) Protocol of the Firewall Rule. tcp, icmp, udp, gre, esp
sourceIps string[]
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is in)
direction This property is required. str
(Required, string) Direction of the Firewall Rule. in, out
description str
(Optional, string) Description of the firewall rule
destination_ips Sequence[str]
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is out)
port str
(Required, string) Port of the Firewall Rule. Required when protocol is tcp or udp
protocol str
(Required, string) Protocol of the Firewall Rule. tcp, icmp, udp, gre, esp
source_ips Sequence[str]
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is in)
direction This property is required. String
(Required, string) Direction of the Firewall Rule. in, out
description String
(Optional, string) Description of the firewall rule
destinationIps List<String>
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is out)
port String
(Required, string) Port of the Firewall Rule. Required when protocol is tcp or udp
protocol String
(Required, string) Protocol of the Firewall Rule. tcp, icmp, udp, gre, esp
sourceIps List<String>
(Required, List) List of CIDRs that are allowed within this Firewall Rule (when direction is in)

Package Details

Repository
Hetzner Cloud pulumi/pulumi-hcloud
License
Apache-2.0
Notes
This Pulumi package is based on the hcloud Terraform Provider.
Hetzner Cloud v1.22.0 published on Wednesday, Feb 26, 2025 by Pulumi