1. Packages
  2. Hetzner Cloud
  3. API Docs
  4. FirewallAttachment
Hetzner Cloud v1.18.1 published on Tuesday, Apr 9, 2024 by Pulumi

hcloud.FirewallAttachment

Explore with Pulumi AI

hcloud logo
Hetzner Cloud v1.18.1 published on Tuesday, Apr 9, 2024 by Pulumi

    Attaches resource to a Hetzner Cloud Firewall.

    Note: only one hcloud.FirewallAttachment per Firewall is allowed. Any resources that should be attached to that Firewall need to be specified in that hcloud.FirewallAttachment.

    Example Usage

    Attach Servers

    import * as pulumi from "@pulumi/pulumi";
    import * as hcloud from "@pulumi/hcloud";
    
    const testServer = new hcloud.Server("testServer", {
        serverType: "cx11",
        image: "ubuntu-20.04",
    });
    const basicFirewall = new hcloud.Firewall("basicFirewall", {});
    const fwRef = new hcloud.FirewallAttachment("fwRef", {
        firewallId: basicFirewall.id,
        serverIds: [testServer.id],
    });
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    test_server = hcloud.Server("testServer",
        server_type="cx11",
        image="ubuntu-20.04")
    basic_firewall = hcloud.Firewall("basicFirewall")
    fw_ref = hcloud.FirewallAttachment("fwRef",
        firewall_id=basic_firewall.id,
        server_ids=[test_server.id])
    
    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 {
    		testServer, err := hcloud.NewServer(ctx, "testServer", &hcloud.ServerArgs{
    			ServerType: pulumi.String("cx11"),
    			Image:      pulumi.String("ubuntu-20.04"),
    		})
    		if err != nil {
    			return err
    		}
    		basicFirewall, err := hcloud.NewFirewall(ctx, "basicFirewall", nil)
    		if err != nil {
    			return err
    		}
    		_, err = hcloud.NewFirewallAttachment(ctx, "fwRef", &hcloud.FirewallAttachmentArgs{
    			FirewallId: basicFirewall.ID(),
    			ServerIds: pulumi.IntArray{
    				testServer.ID(),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using HCloud = Pulumi.HCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var testServer = new HCloud.Server("testServer", new()
        {
            ServerType = "cx11",
            Image = "ubuntu-20.04",
        });
    
        var basicFirewall = new HCloud.Firewall("basicFirewall");
    
        var fwRef = new HCloud.FirewallAttachment("fwRef", new()
        {
            FirewallId = basicFirewall.Id,
            ServerIds = new[]
            {
                testServer.Id,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.hcloud.Server;
    import com.pulumi.hcloud.ServerArgs;
    import com.pulumi.hcloud.Firewall;
    import com.pulumi.hcloud.FirewallAttachment;
    import com.pulumi.hcloud.FirewallAttachmentArgs;
    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 testServer = new Server("testServer", ServerArgs.builder()        
                .serverType("cx11")
                .image("ubuntu-20.04")
                .build());
    
            var basicFirewall = new Firewall("basicFirewall");
    
            var fwRef = new FirewallAttachment("fwRef", FirewallAttachmentArgs.builder()        
                .firewallId(basicFirewall.id())
                .serverIds(testServer.id())
                .build());
    
        }
    }
    
    resources:
      testServer:
        type: hcloud:Server
        properties:
          serverType: cx11
          image: ubuntu-20.04
      basicFirewall:
        type: hcloud:Firewall
      fwRef:
        type: hcloud:FirewallAttachment
        properties:
          firewallId: ${basicFirewall.id}
          serverIds:
            - ${testServer.id}
    

    Attach Label Selectors

    import * as pulumi from "@pulumi/pulumi";
    import * as hcloud from "@pulumi/hcloud";
    
    const testServer = new hcloud.Server("testServer", {
        serverType: "cx11",
        image: "ubuntu-20.04",
        labels: {
            "firewall-attachment": "test-server",
        },
    });
    const basicFirewall = new hcloud.Firewall("basicFirewall", {});
    const fwRef = new hcloud.FirewallAttachment("fwRef", {
        firewallId: basicFirewall.id,
        labelSelectors: ["firewall-attachment=test-server"],
    });
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    test_server = hcloud.Server("testServer",
        server_type="cx11",
        image="ubuntu-20.04",
        labels={
            "firewall-attachment": "test-server",
        })
    basic_firewall = hcloud.Firewall("basicFirewall")
    fw_ref = hcloud.FirewallAttachment("fwRef",
        firewall_id=basic_firewall.id,
        label_selectors=["firewall-attachment=test-server"])
    
    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.NewServer(ctx, "testServer", &hcloud.ServerArgs{
    			ServerType: pulumi.String("cx11"),
    			Image:      pulumi.String("ubuntu-20.04"),
    			Labels: pulumi.Map{
    				"firewall-attachment": pulumi.Any("test-server"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		basicFirewall, err := hcloud.NewFirewall(ctx, "basicFirewall", nil)
    		if err != nil {
    			return err
    		}
    		_, err = hcloud.NewFirewallAttachment(ctx, "fwRef", &hcloud.FirewallAttachmentArgs{
    			FirewallId: basicFirewall.ID(),
    			LabelSelectors: pulumi.StringArray{
    				pulumi.String("firewall-attachment=test-server"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using HCloud = Pulumi.HCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var testServer = new HCloud.Server("testServer", new()
        {
            ServerType = "cx11",
            Image = "ubuntu-20.04",
            Labels = 
            {
                { "firewall-attachment", "test-server" },
            },
        });
    
        var basicFirewall = new HCloud.Firewall("basicFirewall");
    
        var fwRef = new HCloud.FirewallAttachment("fwRef", new()
        {
            FirewallId = basicFirewall.Id,
            LabelSelectors = new[]
            {
                "firewall-attachment=test-server",
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.hcloud.Server;
    import com.pulumi.hcloud.ServerArgs;
    import com.pulumi.hcloud.Firewall;
    import com.pulumi.hcloud.FirewallAttachment;
    import com.pulumi.hcloud.FirewallAttachmentArgs;
    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 testServer = new Server("testServer", ServerArgs.builder()        
                .serverType("cx11")
                .image("ubuntu-20.04")
                .labels(Map.of("firewall-attachment", "test-server"))
                .build());
    
            var basicFirewall = new Firewall("basicFirewall");
    
            var fwRef = new FirewallAttachment("fwRef", FirewallAttachmentArgs.builder()        
                .firewallId(basicFirewall.id())
                .labelSelectors("firewall-attachment=test-server")
                .build());
    
        }
    }
    
    resources:
      testServer:
        type: hcloud:Server
        properties:
          serverType: cx11
          image: ubuntu-20.04
          labels:
            firewall-attachment: test-server
      basicFirewall:
        type: hcloud:Firewall
      fwRef:
        type: hcloud:FirewallAttachment
        properties:
          firewallId: ${basicFirewall.id}
          labelSelectors:
            - firewall-attachment=test-server
    

    Create FirewallAttachment Resource

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

    Constructor syntax

    new FirewallAttachment(name: string, args: FirewallAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def FirewallAttachment(resource_name: str,
                           args: FirewallAttachmentArgs,
                           opts: Optional[ResourceOptions] = None)
    
    @overload
    def FirewallAttachment(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           firewall_id: Optional[int] = None,
                           label_selectors: Optional[Sequence[str]] = None,
                           server_ids: Optional[Sequence[int]] = None)
    func NewFirewallAttachment(ctx *Context, name string, args FirewallAttachmentArgs, opts ...ResourceOption) (*FirewallAttachment, error)
    public FirewallAttachment(string name, FirewallAttachmentArgs args, CustomResourceOptions? opts = null)
    public FirewallAttachment(String name, FirewallAttachmentArgs args)
    public FirewallAttachment(String name, FirewallAttachmentArgs args, CustomResourceOptions options)
    
    type: hcloud:FirewallAttachment
    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 FirewallAttachmentArgs
    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 FirewallAttachmentArgs
    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 FirewallAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args FirewallAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args FirewallAttachmentArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

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

    var firewallAttachmentResource = new HCloud.FirewallAttachment("firewallAttachmentResource", new()
    {
        FirewallId = 0,
        LabelSelectors = new[]
        {
            "string",
        },
        ServerIds = new[]
        {
            0,
        },
    });
    
    example, err := hcloud.NewFirewallAttachment(ctx, "firewallAttachmentResource", &hcloud.FirewallAttachmentArgs{
    	FirewallId: pulumi.Int(0),
    	LabelSelectors: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	ServerIds: pulumi.IntArray{
    		pulumi.Int(0),
    	},
    })
    
    var firewallAttachmentResource = new FirewallAttachment("firewallAttachmentResource", FirewallAttachmentArgs.builder()        
        .firewallId(0)
        .labelSelectors("string")
        .serverIds(0)
        .build());
    
    firewall_attachment_resource = hcloud.FirewallAttachment("firewallAttachmentResource",
        firewall_id=0,
        label_selectors=["string"],
        server_ids=[0])
    
    const firewallAttachmentResource = new hcloud.FirewallAttachment("firewallAttachmentResource", {
        firewallId: 0,
        labelSelectors: ["string"],
        serverIds: [0],
    });
    
    type: hcloud:FirewallAttachment
    properties:
        firewallId: 0
        labelSelectors:
            - string
        serverIds:
            - 0
    

    FirewallAttachment 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 FirewallAttachment resource accepts the following input properties:

    FirewallId int
    ID of the firewall the resources should be attached to.
    LabelSelectors List<string>
    List of label selectors used to select resources to attach to the firewall.
    ServerIds List<int>
    List of Server IDs to attach to the firewall.
    FirewallId int
    ID of the firewall the resources should be attached to.
    LabelSelectors []string
    List of label selectors used to select resources to attach to the firewall.
    ServerIds []int
    List of Server IDs to attach to the firewall.
    firewallId Integer
    ID of the firewall the resources should be attached to.
    labelSelectors List<String>
    List of label selectors used to select resources to attach to the firewall.
    serverIds List<Integer>
    List of Server IDs to attach to the firewall.
    firewallId number
    ID of the firewall the resources should be attached to.
    labelSelectors string[]
    List of label selectors used to select resources to attach to the firewall.
    serverIds number[]
    List of Server IDs to attach to the firewall.
    firewall_id int
    ID of the firewall the resources should be attached to.
    label_selectors Sequence[str]
    List of label selectors used to select resources to attach to the firewall.
    server_ids Sequence[int]
    List of Server IDs to attach to the firewall.
    firewallId Number
    ID of the firewall the resources should be attached to.
    labelSelectors List<String>
    List of label selectors used to select resources to attach to the firewall.
    serverIds List<Number>
    List of Server IDs to attach to the firewall.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the FirewallAttachment 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 FirewallAttachment Resource

    Get an existing FirewallAttachment 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?: FirewallAttachmentState, opts?: CustomResourceOptions): FirewallAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            firewall_id: Optional[int] = None,
            label_selectors: Optional[Sequence[str]] = None,
            server_ids: Optional[Sequence[int]] = None) -> FirewallAttachment
    func GetFirewallAttachment(ctx *Context, name string, id IDInput, state *FirewallAttachmentState, opts ...ResourceOption) (*FirewallAttachment, error)
    public static FirewallAttachment Get(string name, Input<string> id, FirewallAttachmentState? state, CustomResourceOptions? opts = null)
    public static FirewallAttachment get(String name, Output<String> id, FirewallAttachmentState 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:
    FirewallId int
    ID of the firewall the resources should be attached to.
    LabelSelectors List<string>
    List of label selectors used to select resources to attach to the firewall.
    ServerIds List<int>
    List of Server IDs to attach to the firewall.
    FirewallId int
    ID of the firewall the resources should be attached to.
    LabelSelectors []string
    List of label selectors used to select resources to attach to the firewall.
    ServerIds []int
    List of Server IDs to attach to the firewall.
    firewallId Integer
    ID of the firewall the resources should be attached to.
    labelSelectors List<String>
    List of label selectors used to select resources to attach to the firewall.
    serverIds List<Integer>
    List of Server IDs to attach to the firewall.
    firewallId number
    ID of the firewall the resources should be attached to.
    labelSelectors string[]
    List of label selectors used to select resources to attach to the firewall.
    serverIds number[]
    List of Server IDs to attach to the firewall.
    firewall_id int
    ID of the firewall the resources should be attached to.
    label_selectors Sequence[str]
    List of label selectors used to select resources to attach to the firewall.
    server_ids Sequence[int]
    List of Server IDs to attach to the firewall.
    firewallId Number
    ID of the firewall the resources should be attached to.
    labelSelectors List<String>
    List of label selectors used to select resources to attach to the firewall.
    serverIds List<Number>
    List of Server IDs to attach to the firewall.

    Package Details

    Repository
    Hetzner Cloud pulumi/pulumi-hcloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the hcloud Terraform Provider.
    hcloud logo
    Hetzner Cloud v1.18.1 published on Tuesday, Apr 9, 2024 by Pulumi