hcloud.FirewallAttachment
Explore with Pulumi AI
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("test_server", {
name: "test-server",
serverType: "cx22",
image: "ubuntu-20.04",
});
const basicFirewall = new hcloud.Firewall("basic_firewall", {name: "basic_firewall"});
const fwRef = new hcloud.FirewallAttachment("fw_ref", {
firewallId: basicFirewall.id,
serverIds: [testServer.id],
});
import pulumi
import pulumi_hcloud as hcloud
test_server = hcloud.Server("test_server",
name="test-server",
server_type="cx22",
image="ubuntu-20.04")
basic_firewall = hcloud.Firewall("basic_firewall", name="basic_firewall")
fw_ref = hcloud.FirewallAttachment("fw_ref",
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, "test_server", &hcloud.ServerArgs{
Name: pulumi.String("test-server"),
ServerType: pulumi.String("cx22"),
Image: pulumi.String("ubuntu-20.04"),
})
if err != nil {
return err
}
basicFirewall, err := hcloud.NewFirewall(ctx, "basic_firewall", &hcloud.FirewallArgs{
Name: pulumi.String("basic_firewall"),
})
if err != nil {
return err
}
_, err = hcloud.NewFirewallAttachment(ctx, "fw_ref", &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("test_server", new()
{
Name = "test-server",
ServerType = "cx22",
Image = "ubuntu-20.04",
});
var basicFirewall = new HCloud.Firewall("basic_firewall", new()
{
Name = "basic_firewall",
});
var fwRef = new HCloud.FirewallAttachment("fw_ref", 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.FirewallArgs;
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()
.name("test-server")
.serverType("cx22")
.image("ubuntu-20.04")
.build());
var basicFirewall = new Firewall("basicFirewall", FirewallArgs.builder()
.name("basic_firewall")
.build());
var fwRef = new FirewallAttachment("fwRef", FirewallAttachmentArgs.builder()
.firewallId(basicFirewall.id())
.serverIds(testServer.id())
.build());
}
}
resources:
testServer:
type: hcloud:Server
name: test_server
properties:
name: test-server
serverType: cx22
image: ubuntu-20.04
basicFirewall:
type: hcloud:Firewall
name: basic_firewall
properties:
name: basic_firewall
fwRef:
type: hcloud:FirewallAttachment
name: fw_ref
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("test_server", {
name: "test-server",
serverType: "cx22",
image: "ubuntu-20.04",
labels: {
"firewall-attachment": "test-server",
},
});
const basicFirewall = new hcloud.Firewall("basic_firewall", {name: "basic_firewall"});
const fwRef = new hcloud.FirewallAttachment("fw_ref", {
firewallId: basicFirewall.id,
labelSelectors: ["firewall-attachment=test-server"],
});
import pulumi
import pulumi_hcloud as hcloud
test_server = hcloud.Server("test_server",
name="test-server",
server_type="cx22",
image="ubuntu-20.04",
labels={
"firewall-attachment": "test-server",
})
basic_firewall = hcloud.Firewall("basic_firewall", name="basic_firewall")
fw_ref = hcloud.FirewallAttachment("fw_ref",
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, "test_server", &hcloud.ServerArgs{
Name: pulumi.String("test-server"),
ServerType: pulumi.String("cx22"),
Image: pulumi.String("ubuntu-20.04"),
Labels: pulumi.StringMap{
"firewall-attachment": pulumi.String("test-server"),
},
})
if err != nil {
return err
}
basicFirewall, err := hcloud.NewFirewall(ctx, "basic_firewall", &hcloud.FirewallArgs{
Name: pulumi.String("basic_firewall"),
})
if err != nil {
return err
}
_, err = hcloud.NewFirewallAttachment(ctx, "fw_ref", &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("test_server", new()
{
Name = "test-server",
ServerType = "cx22",
Image = "ubuntu-20.04",
Labels =
{
{ "firewall-attachment", "test-server" },
},
});
var basicFirewall = new HCloud.Firewall("basic_firewall", new()
{
Name = "basic_firewall",
});
var fwRef = new HCloud.FirewallAttachment("fw_ref", 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.FirewallArgs;
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()
.name("test-server")
.serverType("cx22")
.image("ubuntu-20.04")
.labels(Map.of("firewall-attachment", "test-server"))
.build());
var basicFirewall = new Firewall("basicFirewall", FirewallArgs.builder()
.name("basic_firewall")
.build());
var fwRef = new FirewallAttachment("fwRef", FirewallAttachmentArgs.builder()
.firewallId(basicFirewall.id())
.labelSelectors("firewall-attachment=test-server")
.build());
}
}
resources:
testServer:
type: hcloud:Server
name: test_server
properties:
name: test-server
serverType: cx22
image: ubuntu-20.04
labels:
firewall-attachment: test-server
basicFirewall:
type: hcloud:Firewall
name: basic_firewall
properties:
name: basic_firewall
fwRef:
type: hcloud:FirewallAttachment
name: fw_ref
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.
Constructor 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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The FirewallAttachment resource accepts the following input properties:
- Firewall
Id int - ID of the firewall the resources should be attached to.
- Label
Selectors List<string> - List of label selectors used to select resources to attach to the firewall.
- Server
Ids List<int> - List of Server IDs to attach to the firewall.
- Firewall
Id int - ID of the firewall the resources should be attached to.
- Label
Selectors []string - List of label selectors used to select resources to attach to the firewall.
- Server
Ids []int - List of Server IDs to attach to the firewall.
- firewall
Id Integer - ID of the firewall the resources should be attached to.
- label
Selectors List<String> - List of label selectors used to select resources to attach to the firewall.
- server
Ids List<Integer> - List of Server IDs to attach to the firewall.
- firewall
Id number - ID of the firewall the resources should be attached to.
- label
Selectors string[] - List of label selectors used to select resources to attach to the firewall.
- server
Ids 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.
- firewall
Id Number - ID of the firewall the resources should be attached to.
- label
Selectors List<String> - List of label selectors used to select resources to attach to the firewall.
- server
Ids 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.
- Firewall
Id int - ID of the firewall the resources should be attached to.
- Label
Selectors List<string> - List of label selectors used to select resources to attach to the firewall.
- Server
Ids List<int> - List of Server IDs to attach to the firewall.
- Firewall
Id int - ID of the firewall the resources should be attached to.
- Label
Selectors []string - List of label selectors used to select resources to attach to the firewall.
- Server
Ids []int - List of Server IDs to attach to the firewall.
- firewall
Id Integer - ID of the firewall the resources should be attached to.
- label
Selectors List<String> - List of label selectors used to select resources to attach to the firewall.
- server
Ids List<Integer> - List of Server IDs to attach to the firewall.
- firewall
Id number - ID of the firewall the resources should be attached to.
- label
Selectors string[] - List of label selectors used to select resources to attach to the firewall.
- server
Ids 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.
- firewall
Id Number - ID of the firewall the resources should be attached to.
- label
Selectors List<String> - List of label selectors used to select resources to attach to the firewall.
- server
Ids 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.