### Example: Reusable Key with Expiration
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/setupkey.md
Demonstrates how to create a reusable setup key with an expiration time, usage limit, and auto-assigned groups.
```APIDOC
## Example: Reusable Key with Expiration
Creates a reusable setup key with expiration and usage limits.
### Description
This example illustrates the creation of a reusable setup key, specifying its name, type, expiration, usage limit, and auto-assigned groups.
### Method
`POST` (Implicit)
### Endpoint
`/setupkeys` (Implicit)
### Parameters
#### Input Arguments (SetupKeyArgs)
- **name** (string) - Required - "Team Registration Key"
- **type** (SetupKeyType) - Required - `netbird.SetupKeyTypeReusable`
- **expiresIn** (int) - Required - `2592000` (30 days in seconds)
- **usageLimit** (int) - Optional - `50`
- **autoGroups** (array of strings) - Optional - `["team-group-id"]`
### Request Example
```go
key, err := netbird.NewSetupKey(ctx, "team-key", &netbird.SetupKeyArgs{
Name: pulumi.String("Team Registration Key"),
Type: netbird.SetupKeyTypeReusable,
ExpiresIn: pulumi.Int(2592000), // 30 days
UsageLimit: pulumi.Int(50),
AutoGroups: pulumi.StringArray{
pulumi.String("team-group-id"),
},
})
```
```
--------------------------------
### Example: One-Off Key for Single Peer
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/setupkey.md
Demonstrates how to create a one-off setup key that can only be used once to register a single peer, with a 1-day expiration.
```APIDOC
## Example: One-Off Key for Single Peer
Creates a one-off setup key for a single peer registration.
### Description
This example shows the creation of a one-off setup key with a specified name, type, and expiration.
### Method
`POST` (Implicit)
### Endpoint
`/setupkeys` (Implicit)
### Parameters
#### Input Arguments (SetupKeyArgs)
- **name** (string) - Required - "Single Peer Key"
- **type** (SetupKeyType) - Required - `netbird.SetupKeyTypeOneOff`
- **expiresIn** (int) - Required - `86400` (1 day in seconds)
### Request Example
```go
key, err := netbird.NewSetupKey(ctx, "one-time", &netbird.SetupKeyArgs{
Name: pulumi.String("Single Peer Key"),
Type: netbird.SetupKeyTypeOneOff,
ExpiresIn: pulumi.Int(86400), // 1 day
})
```
```
--------------------------------
### Basic Domain Configuration Example
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/reverseproxydomain.md
Example of setting up a basic reverse proxy domain. This associates 'web.internal.example.com' with a service identified by `service.ID()`.
```go
domain, err := netbird.NewReverseProxyDomain(ctx, "web", &netbird.ReverseProxyDomainArgs{
Domain: pulumi.String("web.internal.example.com"),
ServiceID: service.ID(),
})
```
--------------------------------
### Pulumi Go Setup and Deployment Commands
Source: https://github.com/mbrav/pulumi-netbird/blob/main/README.md
Commands to set up a Pulumi Go project for NetBird. Includes navigating to the example directory, initializing a stack, configuring credentials, and deploying resources.
```bash
cd examples/go
pulumi stack init test
pulumi config set netbird:token YOUR_TOKEN
pulumi config set netbird:url https://nb.domain:33073
pulumi up
```
--------------------------------
### Create Posture Check (Example)
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/posturecheck.md
Example of creating a new posture check policy with a name and checks configuration.
```go
check, err := netbird.NewPostureCheck(ctx, "antivirus-check", &netbird.PostureCheckArgs{
Name: pulumi.String("Antivirus Required"),
Checks: ..., // Provider-specific check configuration
})
```
--------------------------------
### Go SDK Example
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/index.md
Example demonstrating how to use the Go SDK to create NetBird resources. It includes creating a network and a group, and exporting their IDs.
```go
package main
import (
"github.com/mbrav/pulumi-netbird/sdk/go/netbird"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Create a network
net, err := netbird.NewNetwork(ctx, "prod-network", &netbird.NetworkArgs{
Name: pulumi.String("Production"),
Description: pulumi.String("Production network"),
})
if err != nil {
return err
}
// Create a group
group, err := netbird.NewGroup(ctx, "eng-group", &netbird.GroupArgs{
Name: pulumi.String("Engineering"),
})
if err != nil {
return err
}
ctx.Export("networkId", net.ID())
ctx.Export("groupId", group.ID())
return nil
})
}
```
--------------------------------
### Create a New Peer
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/peer.md
Example of creating a new peer resource with a name and SSH enabled status. Peers are typically registered via setup keys in practice.
```go
peer, err := netbird.NewPeer(ctx, "server-1", &netbird.PeerArgs{
Name: pulumi.String("Production Server 1"),
SSHEnabled: pulumi.Bool(true),
})
```
--------------------------------
### Pulumi Python Setup and Deployment Commands
Source: https://github.com/mbrav/pulumi-netbird/blob/main/README.md
Commands to set up a Pulumi Python project for NetBird. Includes navigating to the example directory, initializing a stack, configuring credentials, and deploying resources.
```bash
cd examples/python
pulumi stack init test
pulumi config set netbird:token YOUR_TOKEN
pulumi config set netbird:url https://nb.domain:33073
pulumi up
```
--------------------------------
### Network Resource with Groups Example
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/networkresource.md
Example demonstrating the creation of a network resource with an optional description and a list of group IDs for access control.
```go
resource, err := netbird.NewNetworkResource(ctx, "staging-subnet", &netbird.NetworkResourceArgs{
Name: pulumi.String("Staging Services"),
Description: pulumi.String("Staging environment subnet"),
NetworkID: network.ID(),
Address: pulumi.String("10.1.0.0/24"),
Enabled: pulumi.Bool(true),
GroupIDs: pulumi.StringArray{
pulumi.String("staging-eng-group"),
pulumi.String("staging-qa-group"),
},
})
```
--------------------------------
### Create User Example
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/user.md
Demonstrates how to create a new user with specified email, name, and role.
```go
user, err := netbird.NewUser(ctx, "engineer", &netbird.UserArgs{
Email: pulumi.String("engineer@example.com"),
Name: pulumi.String("John Engineer"),
Role: netbird.UserRoleUser,
})
```
--------------------------------
### Simple Accept Policy Example
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/policy.md
An example demonstrating how to create a simple policy that accepts all traffic.
```APIDOC
### Simple Accept Policy
```go
policy, err := netbird.NewPolicy(ctx, "allow-all", &netbird.PolicyArgs{
Name: pulumi.String("Allow All"),
Enabled: pulumi.Bool(true),
Rules: netbird.PolicyRuleArgsArray{
&netbird.PolicyRuleArgsArgs{
Name: pulumi.String("Allow All"),
Bidirectional: pulumi.Bool(true),
Action: netbird.RuleActionAccept,
Enabled: pulumi.Bool(true),
Protocol: netbird.ProtocolAll,
},
},
})
```
```
--------------------------------
### Create a Reusable Setup Key with Usage Limit
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/setupkey.md
Creates a reusable setup key that can be used multiple times by different peers. It includes a specific usage limit and can assign peers to predefined groups.
```go
key, err := netbird.NewSetupKey(ctx, "team-key", &netbird.SetupKeyArgs{
Name: pulumi.String("Team Registration Key"),
Type: netbird.SetupKeyTypeReusable,
ExpiresIn: pulumi.Int(2592000), // 30 days
UsageLimit: pulumi.Int(50),
AutoGroups: pulumi.StringArray{
pulumi.String("team-group-id"),
},
})
```
--------------------------------
### Create a One-Off Setup Key
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/setupkey.md
Generates a one-off setup key intended for single-use peer registration. This key has a specified expiration time.
```go
key, err := netbird.NewSetupKey(ctx, "one-time", &netbird.SetupKeyArgs{
Name: pulumi.String("Single Peer Key"),
Type: netbird.SetupKeyTypeOneOff,
ExpiresIn: pulumi.Int(86400), // 1 day
})
```
--------------------------------
### Pulumi YAML Example
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/index.md
Example of how to configure and declare NetBird resources using Pulumi YAML. It shows the setup for provider plugins and the creation of a Group and a Network resource.
```yaml
name: netbird-example
runtime: yaml
plugins:
providers:
- name: netbird
path: bin
config:
netbird:url: https://nb.domain:33073
netbird:token: ${NETBIRD_TOKEN}
resources:
my-group:
type: netbird:resource:Group
properties:
name: "Engineering"
peers: []
my-network:
type: netbird:resource:Network
properties:
name: "Production"
description: "Production network"
```
--------------------------------
### Basic Network Resource Example
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/networkresource.md
Example of creating a basic network resource with essential arguments like name, network ID, and address. The resource is enabled by default.
```go
resource, err := netbird.NewNetworkResource(ctx, "prod-subnet", &netbird.NetworkResourceArgs{
Name: pulumi.String("Production"),
NetworkID: network.ID(),
Address: pulumi.String("192.168.0.0/24"),
Enabled: pulumi.Bool(true),
})
```
--------------------------------
### Pulumi Python SDK Generation and Installation
Source: https://github.com/mbrav/pulumi-netbird/blob/main/README.md
Commands to generate and install the Pulumi Python SDK for NetBird. This involves running make commands and then installing the generated wheel file.
```bash
make provider
make sdk_python
pip install sdk/python/bin/dist/pulumi_netbird-0.0.25.tar.gz
```
--------------------------------
### Create an Ephemeral Setup Key
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/setupkey.md
Creates a reusable, ephemeral setup key that expires after 7 days and has a usage limit of 100. Ephemeral peers registered with this key will auto-expire.
```go
key, err := netbird.NewSetupKey(ctx, "ephemeral-key", &netbird.SetupKeyArgs{
Name: pulumi.String("Ephemeral Peers"),
Type: netbird.SetupKeyTypeReusable,
ExpiresIn: pulumi.Int(604800), // 7 days
Ephemeral: pulumi.Bool(true), // Peers auto-expire
UsageLimit: pulumi.Int(100),
})
```
--------------------------------
### Create Setup Key
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/setupkey.md
Creates a new NetBird setup key. The actual key string is returned upon creation and must be stored securely as it cannot be retrieved later. Dry-run behavior returns a preview state without the actual key.
```APIDOC
## Create Setup Key
Creates a new setup key for peer registration.
### Description
Creates a new setup key for peer registration.
### Method
`POST` (Implicit, as this is a resource creation operation in a Pulumi provider context)
### Endpoint
`/setupkeys` (Implicit, as this is a resource creation operation in a Pulumi provider context)
### Parameters
#### Input Arguments (SetupKeyArgs)
- **name** (string) - Required - Setup key display name
- **type** (SetupKeyType) - Required - Key type: 'one-off' (single use) or 'reusable'
- **expiresIn** (int) - Required - Time-to-live in seconds from creation (0 for no expiration if supported)
- **autoGroups** (array of strings) - Optional - Group IDs to auto-assign to peers created with this key
- **usageLimit** (int) - Optional - Maximum uses for reusable keys (0 = unlimited)
- **ephemeral** (bool) - Optional - Whether peers registered with this key are ephemeral (auto-expire)
- **allowExtraDnsLabels** (bool) - Optional - Allow peers to add extra DNS labels beyond the base name
### Request Example
```go
key, err := netbird.NewSetupKey(ctx, "initial-key", &netbird.SetupKeyArgs{
Name: pulumi.String("Initial Setup Key"),
Type: netbird.SetupKeyTypeReusable,
ExpiresIn: pulumi.Int(2592000), // 30 days in seconds
UsageLimit: pulumi.Int(10),
AutoGroups: pulumi.StringArray{
pulumi.String("initial-peers-group"),
},
})
```
### Response
#### Success Response
- **id** (string) - The unique identifier of the setup key
- **name** (string) - Setup key display name
- **type** (SetupKeyType) - Key type (one-off or reusable)
- **expiresIn** (int) - Expiration time in seconds
- **autoGroups** (array of strings) - Auto-assigned group IDs
- **usageLimit** (int) - Maximum uses (reusable only)
- **ephemeral** (bool) - Ephemeral peer status
- **allowExtraDnsLabels** (bool) - Extra DNS labels allowed
- **key** (string) - The actual setup key string (use for peer registration)
- **valid** (bool) - Whether the key is currently valid
- **revoked** (bool) - Whether the key has been revoked
- **usedTimes** (int) - Number of times the key has been used
- **lastUsed** (string) - ISO8601 timestamp of last use
- **expires** (string) - ISO8601 timestamp of expiration
- **state** (string) - Key state ("valid", "expired", etc.)
- **updatedAt** (string) - ISO8601 timestamp of last update
#### Response Example
(The actual response body will contain the state of the created setup key, including the `key` field which is only available immediately after creation.)
```
--------------------------------
### Create a Basic DNSZone
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/dnszone.md
Example of creating a simple DNSZone with only the required name, domain, and enabled fields.
```go
zone, err := netbird.NewDNSZone(ctx, "example", &netbird.DNSZoneArgs{
Name: pulumi.String("Example"),
Domain: pulumi.String("example.com"),
Enabled: pulumi.Bool(true),
})
```
--------------------------------
### Read Setup Key
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/setupkey.md
Fetches the current state of a setup key, including usage statistics and validity status. The `key` field is not returned in subsequent reads after creation.
```APIDOC
## Read Setup Key
Fetches the current state of a setup key, including usage statistics and validity status.
### Description
Fetches the current state of a setup key, including usage statistics and validity status.
### Method
`GET` (Implicit, as this is a resource read operation in a Pulumi provider context)
### Endpoint
`/setupkeys/{id}` (Implicit, as this is a resource read operation in a Pulumi provider context)
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the setup key to retrieve.
### Response
#### Success Response
- **id** (string) - The unique identifier of the setup key
- **name** (string) - Setup key display name
- **type** (SetupKeyType) - Key type (one-off or reusable)
- **expiresIn** (int) - Expiration time in seconds
- **autoGroups** (array of strings) - Auto-assigned group IDs
- **usageLimit** (int) - Maximum uses (reusable only)
- **ephemeral** (bool) - Ephemeral peer status
- **allowExtraDnsLabels** (bool) - Extra DNS labels allowed
- **valid** (bool) - Whether the key is currently valid
- **revoked** (bool) - Whether the key has been revoked
- **usedTimes** (int) - Number of times the key has been used
- **lastUsed** (string) - ISO8601 timestamp of last use
- **expires** (string) - ISO8601 timestamp of expiration
- **state** (string) - Key state ("valid", "expired", etc.)
- **updatedAt** (string) - ISO8601 timestamp of last update
#### Response Example
(The response body will contain the current state of the setup key. The `key` field will not be present.)
```
--------------------------------
### Create Basic ReverseProxyService
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/reverseproxyservice.md
Example of creating a basic reverse proxy service with a name, description, and enabled flag. Ensure service names are unique.
```go
service, err := netbird.NewReverseProxyService(ctx, "backend", &netbird.ReverseProxyServiceArgs{
Name: pulumi.String("Backend API"),
Description: pulumi.String("Backend REST API"),
Enabled: pulumi.Bool(true),
})
```
--------------------------------
### Basic Network Creation Example
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/network.md
Demonstrates the basic creation of a NetBird network. Exports the network ID upon successful creation.
```go
network, err := netbird.NewNetwork(ctx, "prod", &netbird.NetworkArgs{
Name: pulumi.String("Production Environment"),
})
if err != nil {
return err
}
ctx.Export("networkId", network.ID())
```
--------------------------------
### Create Group Example
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/group.md
Demonstrates how to create a new NetBird group with a name and a list of peers.
```go
group, err := netbird.NewGroup(ctx, "my-group", &netbird.GroupArgs{
Name: pulumi.String("Engineering"),
Peers: pulumi.StringArray{
pulumi.String("peer-id-1"),
pulumi.String("peer-id-2"),
},
})
```
--------------------------------
### SetupKeyType Enum
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/types.md
Enumeration for setup key types, indicating if a key is reusable or one-off.
```go
type SetupKeyType string
const (
SetupKeyTypeReusable SetupKeyType = "reusable"
SetupKeyTypeOneOff SetupKeyType = "one-off"
)
```
--------------------------------
### Regular User Example
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/user.md
Creates a new user with the 'user' role. This is suitable for standard team members.
```go
user, err := netbird.NewUser(ctx, "member", &netbird.UserArgs{
Email: pulumi.String("member@example.com"),
Name: pulumi.String("Team Member"),
Role: netbird.UserRoleUser,
})
```
--------------------------------
### Update Setup Key
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/setupkey.md
Updates an existing setup key's properties. Supported fields include name, type, expiresIn, usageLimit, ephemeral, and allowExtraDnsLabels.
```APIDOC
## Update Setup Key
Updates an existing setup key's properties.
### Description
Updates an existing setup key's properties. Changes to certain fields (name, type, expiresIn, usageLimit, ephemeral, allowExtraDnsLabels) are supported.
### Method
`PUT` or `PATCH` (Implicit, as this is a resource update operation in a Pulumi provider context)
### Endpoint
`/setupkeys/{id}` (Implicit, as this is a resource update operation in a Pulumi provider context)
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the setup key to update.
#### Request Body
- **name** (string) - Optional - New setup key display name
- **type** (SetupKeyType) - Optional - New key type: 'one-off' or 'reusable'
- **expiresIn** (int) - Optional - New time-to-live in seconds
- **autoGroups** (array of strings) - Optional - New group IDs to auto-assign
- **usageLimit** (int) - Optional - New maximum uses for reusable keys
- **ephemeral** (bool) - Optional - New ephemeral status
- **allowExtraDnsLabels** (bool) - Optional - New setting for extra DNS labels
### Response
#### Success Response
- **id** (string) - The unique identifier of the setup key
- **name** (string) - Updated setup key display name
- **type** (SetupKeyType) - Updated key type
- **expiresIn** (int) - Updated expiration time in seconds
- **autoGroups** (array of strings) - Updated auto-assigned group IDs
- **usageLimit** (int) - Updated maximum uses (reusable only)
- **ephemeral** (bool) - Updated ephemeral peer status
- **allowExtraDnsLabels** (bool) - Updated extra DNS labels allowed
- **valid** (bool) - Whether the key is currently valid
- **revoked** (bool) - Whether the key has been revoked
- **usedTimes** (int) - Number of times the key has been used
- **lastUsed** (string) - ISO8601 timestamp of last use
- **expires** (string) - ISO8601 timestamp of expiration
- **state** (string) - Key state ("valid", "expired", etc.)
- **updatedAt** (string) - ISO8601 timestamp of last update
#### Response Example
(The response body will contain the updated state of the setup key.)
```
--------------------------------
### Create a New Setup Key
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/setupkey.md
Creates a new NetBird setup key with specified properties like name, type, expiration, usage limit, and auto-assigned groups. The actual key string is returned upon creation and must be stored securely.
```go
key, err := netbird.NewSetupKey(ctx, "initial-key", &netbird.SetupKeyArgs{
Name: pulumi.String("Initial Setup Key"),
Type: netbird.SetupKeyTypeReusable,
ExpiresIn: pulumi.Int(2592000), // 30 days in seconds
UsageLimit: pulumi.Int(10),
AutoGroups: pulumi.StringArray{
pulumi.String("initial-peers-group"),
},
})
```
--------------------------------
### Create an A Record
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/dnsrecord.md
Example for creating an A record. The ZoneID should reference an existing DNS zone.
```go
record, err := netbird.NewDNSRecord(ctx, "www", &netbird.DNSRecordArgs{
ZoneID: zone.ID(),
Name: pulumi.String("www.example.com"),
Type: netbird.DNSRecordTypeA,
Content: pulumi.String("192.0.2.1"),
TTL: pulumi.Int(3600),
})
```
--------------------------------
### Admin User Example
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/user.md
Creates a new user with the 'admin' role. Ensure the email and name are appropriate for an administrator.
```go
user, err := netbird.NewUser(ctx, "admin", &netbird.UserArgs{
Email: pulumi.String("admin@example.com"),
Name: pulumi.String("Admin User"),
Role: netbird.UserRoleAdmin,
})
```
--------------------------------
### Install Pulumi NetBird Resource Plugin
Source: https://github.com/mbrav/pulumi-netbird/blob/main/README.md
Manually install the Pulumi NetBird resource plugin. Replace the version number with the desired release. The plugin will be downloaded from the specified GitHub repository.
```bash
pulumi plugin install resource netbird 0.1.0 --server github://api.github.com/mbrav/pulumi-netbird
```
--------------------------------
### Basic Posture Check Creation
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/posturecheck.md
Example of creating a basic posture check with a name and an optional description.
```go
check, err := netbird.NewPostureCheck(ctx, "security-baseline", &netbird.PostureCheckArgs{
Name: pulumi.String("Security Baseline"),
Description: pulumi.String("Basic security requirements"),
})
```
--------------------------------
### Create a CNAME Record
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/dnsrecord.md
Example for creating a CNAME record. The content must be a valid domain name.
```go
record, err := netbird.NewDNSRecord(ctx, "alias", &netbird.DNSRecordArgs{
ZoneID: zone.ID(),
Name: pulumi.String("alias.example.com"),
Type: netbird.DNSRecordTypeCNAME,
Content: pulumi.String("www.example.com"),
TTL: pulumi.Int(3600),
})
```
--------------------------------
### List Pulumi Provider Versions
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/errors.md
Display a list of installed Pulumi providers and their versions.
```bash
pulumi plugin list
```
--------------------------------
### Create a DNSZone with Distribution Groups
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/dnszone.md
Example of creating a DNSZone and assigning it to specific distribution groups for access control, also enabling it as a search domain.
```go
zone, err := netbird.NewDNSZone(ctx, "internal", &netbird.DNSZoneArgs{
Name: pulumi.String("Internal Services"),
Domain: pulumi.String("internal.example.com"),
Enabled: pulumi.Bool(true),
EnableSearchDomain: pulumi.Bool(true),
DistributionGroups: pulumi.StringArray{
pulumi.String("engineering-group-id"),
pulumi.String("devops-group-id"),
},
})
```
--------------------------------
### Delete Setup Key
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/setupkey.md
Revokes and removes a setup key from NetBird. Peers already registered with the key will remain connected.
```APIDOC
## Delete Setup Key
Revokes and removes a setup key from NetBird.
### Description
Revokes and removes a setup key from NetBird. Peers already registered with the key remain connected.
### Method
`DELETE` (Implicit, as this is a resource deletion operation in a Pulumi provider context)
### Endpoint
`/setupkeys/{id}` (Implicit, as this is a resource deletion operation in a Pulumi provider context)
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the setup key to delete.
### Response
#### Success Response (204 No Content)
This operation typically returns a 204 No Content status upon successful deletion, indicating no response body.
#### Response Example
(No response body is expected upon successful deletion.)
```
--------------------------------
### Create a Simple Accept All Policy
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/policy.md
Example of creating a simple NetBird policy that allows all traffic bidirectionally. This is useful for broad network access configurations.
```go
policy, err := netbird.NewPolicy(ctx, "allow-all", &netbird.PolicyArgs{
Name: pulumi.String("Allow All"),
Enabled: pulumi.Bool(true),
Rules: netbird.PolicyRuleArgsArray{
&netbird.PolicyRuleArgsArgs{
Name: pulumi.String("Allow All"),
Bidirectional: pulumi.Bool(true),
Action: netbird.RuleActionAccept,
Enabled: pulumi.Bool(true),
Protocol: netbird.ProtocolAll,
},
},
})
```
--------------------------------
### Check Pulumi Version
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/errors.md
Retrieve the currently installed version of the Pulumi CLI.
```bash
pulumi version
```
--------------------------------
### Create Peer
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/peer.md
Creates a new peer resource. While direct creation via Pulumi is possible, peers are usually registered using setup keys.
```APIDOC
## Create Peer
### Description
Creates a new peer resource. In practice, peers are typically registered through setup keys rather than directly created via Pulumi.
### Method
`NewPeer` (Pulumi SDK function)
### Parameters
#### Input Arguments (`PeerArgs`)
- **name** (string) - Required - Display name of the peer
- **sshEnabled** (bool) - Optional - Enable SSH server on the peer (defaults to `false`)
### Request Example
```go
peer, err := netbird.NewPeer(ctx, "server-1", &netbird.PeerArgs{
Name: pulumi.String("Production Server 1"),
SSHEnabled: pulumi.Bool(true),
})
```
### Output State (`PeerState`)
#### Success Response
- **id** (string) - The unique identifier of the peer
- **name** (string) - Display name of the peer
- **sshEnabled** (bool) - SSH server enabled status
### Response Example
(Pulumi SDK output, not a direct API response)
```go
// peer object contains the state of the created peer
```
```
--------------------------------
### Create an AAAA Record
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/dnsrecord.md
Example for creating an AAAA record for IPv6 addresses. The TTL must be a positive integer.
```go
record, err := netbird.NewDNSRecord(ctx, "www-ipv6", &netbird.DNSRecordArgs{
ZoneID: zone.ID(),
Name: pulumi.String("www.example.com"),
Type: netbird.DNSRecordTypeAAAA,
Content: pulumi.String("2001:db8::1"),
TTL: pulumi.Int(3600),
})
```
--------------------------------
### Create Basic Network Router with Masquerade
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/networkrouter.md
Creates a basic network router with masquerading enabled. This is useful for simple setups requiring NAT.
```go
router, err := netbird.NewNetworkRouter(ctx, "prod-router", &netbird.NetworkRouterArgs{
NetworkID: network.ID(),
Enabled: pulumi.Bool(true),
Masquerade: pulumi.Bool(true),
Metric: pulumi.Int(10),
})
```
--------------------------------
### Create a new DNS Record
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/dnsrecord.md
Example of creating a new DNS record for an A record type. Ensure the provider is configured with a valid NetBird token and URL.
```go
record, err := netbird.NewDNSRecord(ctx, "app-record", &netbird.DNSRecordArgs{
ZoneID: pulumi.String("zone-id"),
Name: pulumi.String("app.example.com"),
Type: netbird.DNSRecordTypeA,
Content: pulumi.String("192.0.2.1"),
TTL: pulumi.Int(3600),
})
```
--------------------------------
### Create a New NetBird Policy
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/policy.md
Example of creating a new NetBird policy with specific rules, such as allowing SSH access from a DevOps group to servers. This demonstrates setting name, enabled status, rules, protocol, ports, sources, and destinations.
```go
policy, err := netbird.NewPolicy(ctx, "allow-ssh", &netbird.PolicyArgs{
Name: pulumi.String("Allow SSH"),
Enabled: pulumi.Bool(true),
Rules: netbird.PolicyRuleArgsArray{
&netbird.PolicyRuleArgsArgs{
Name: pulumi.String("SSH from DevOps"),
Bidirectional: pulumi.Bool(false),
Action: netbird.RuleActionAccept,
Enabled: pulumi.Bool(true),
Protocol: netbird.ProtocolTCP,
Ports: pulumi.StringArray{pulumi.String("22")},
Sources: pulumi.StringArray{pulumi.String("devops-group-id")},
Destinations: pulumi.StringArray{pulumi.String("servers-group-id")},
},
},
})
```
--------------------------------
### Create a Primary DNS Nameserver Group
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/dns.md
Example of creating a primary DNS nameserver group using the NetBird provider. This configuration sets up a primary DNS resolver with a specific nameserver.
```go
dns, err := netbird.NewDNS(ctx, "primary-dns", &netbird.DNSArgs{
Name: pulumi.String("Primary DNS"),
Primary: pulumi.Bool(true),
Nameservers: netbird.NameserverArray{
&netbird.NameserverArgs{
IP: pulumi.String("8.8.8.8"),
Type: netbird.NameserverNsTypeUDP,
Port: pulumi.Int(53),
},
},
})
```
--------------------------------
### Self-Hosted NetBird Configuration
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/configuration.md
Configure the provider to use a self-hosted NetBird instance. Specify the custom URL for your instance. Ensure the token has the necessary permissions for your self-hosted setup.
```bash
pulumi config set netbird:url "https://netbird.yourdomain.com"
pulumi config set netbird:token "your-api-token" --secret
```
--------------------------------
### SetupKey Resource
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/README.md
Keys for registering new peers.
```APIDOC
## SetupKey Resource
### Description
Keys for registering new peers.
### Module Path
`netbird:resource:SetupKey`
```
--------------------------------
### Network Creation with Description
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/network.md
Shows how to create a NetBird network and include a descriptive string. This is useful for organizing and identifying networks.
```go
network, err := netbird.NewNetwork(ctx, "staging", &netbird.NetworkArgs{
Name: pulumi.String("Staging"),
Description: pulumi.String("Staging environment for testing"),
})
if err != nil {
return err
}
```
--------------------------------
### List Available SDK Versions with Go
Source: https://github.com/mbrav/pulumi-netbird/blob/main/README.md
Lists the available versions of the NetBird Pulumi Go SDK using the `go list` command. This helps in selecting the correct SDK version for your project.
```bash
go list -m -versions github.com/mbrav/pulumi-netbird/sdk
```
--------------------------------
### Create DNSSettings
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/dnssettings.md
Initializes the DNS settings by applying the desired settings. For a singleton resource, Create applies the settings and uses the fixed ID 'dns-settings'.
```APIDOC
## Create DNSSettings
### Description
Initializes the DNS settings by applying the desired settings. For a singleton resource, Create applies the settings and uses the fixed ID `dns-settings`.
### Method
CREATE (Implicit)
### Endpoint
`/dns-settings` (Singleton)
### Parameters
#### Input Arguments (DNSSettingsArgs)
- `disabledManagementGroups` (array of strings) - Optional - Group IDs whose DNS management is disabled. Defaults to `[]`.
### Request Example
```go
settings, err := netbird.NewDNSSettings(ctx, "global-dns", &netbird.DNSSettingsArgs{
DisabledManagementGroups: pulumi.StringArray{
pulumi.String("group-id-1"),
},
})
```
### Response
#### Success Response (200)
- `id` (string) - Fixed ID "dns-settings" (singleton resource)
- `disabledManagementGroups` (array of strings) - Group IDs with disabled DNS management
#### Response Example
```json
{
"id": "dns-settings",
"disabledManagementGroups": ["group-id-1"]
}
```
```
--------------------------------
### Define Policy Rule Port Range
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/types.md
Defines a port range for policy rules, specifying the start and end ports.
```go
type RulePortRange struct {
Start int // Start of port range
End int // End of port range
}
```
--------------------------------
### Deploy NetBird Environment with Pulumi YAML
Source: https://github.com/mbrav/pulumi-netbird/blob/main/README.md
Deploy a sample NetBird environment using Pulumi YAML. This command initiates the deployment process after configuration.
```bash
pulumi up
```
--------------------------------
### Pulumi.yaml Configuration
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/configuration.md
Example of how NetBird provider configuration, including a secret token, is represented within the `Pulumi.yaml` file. The token is stored in an encrypted format.
```yaml
config:
netbird:url: https://api.netbird.io
netbird:token:
secure: AAABAxxxxx... # This is encrypted by Pulumi
```
--------------------------------
### Go SDK Error Handling for Network Creation
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/errors.md
Demonstrates how to handle errors when creating a network resource using the Go SDK. It checks for errors after the NewNetwork call and prints a formatted error message.
```go
network, err := netbird.NewNetwork(ctx, "prod", &netbird.NetworkArgs{
Name: pulumi.String("Production"),
})
if err != nil {
// Handle error
fmt.Printf("Failed to create network: %v\n", err)
return err
}
```
--------------------------------
### Python SDK Error Handling for Network Creation
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/errors.md
Shows how to catch and handle exceptions during network resource creation with the Python SDK. It uses a try-except block to manage potential errors and prints a user-friendly message.
```python
try:
network = netbird.Network("prod", netbird.NetworkArgs(
name="Production",
))
except Exception as e:
print(f"Failed to create network: {e}")
raise
```
--------------------------------
### Build and Test Commands
Source: https://github.com/mbrav/pulumi-netbird/blob/main/README.md
View available build and test commands for the Pulumi NetBird provider. This command lists all supported make targets.
```bash
make help # View available build/test commands
```
--------------------------------
### Reference Other Resources (Go)
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/README.md
Shows how to reference an existing network resource when creating a new network resource, such as a subnet, by using its ID.
```go
networkResource, _ := netbird.NewNetworkResource(ctx, "subnet", &netbird.NetworkResourceArgs{
NetworkID: network.ID(), // Reference created network
Name: pulumi.String("Subnet 1"),
})
```
--------------------------------
### Peer Configuration with SSH Enabled
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/peer.md
Configures a peer resource with a display name and SSH enabled.
```go
peer, err := netbird.NewPeer(ctx, "bastion", &netbird.PeerArgs{
Name: pulumi.String("Bastion Host"),
SSHEnabled: pulumi.Bool(true),
})
```
--------------------------------
### Export Resource Attributes
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/README.md
Shows how to export important attributes of created NetBird resources, such as their IDs and sensitive values like setup keys. Exported values are accessible from the Pulumi CLI after deployment.
```go
ctx.Export("networkId", network.ID())
ctx.Export("groupId", group.ID())
ctx.Export("setupKeyValue", setupKey.Key)
```
--------------------------------
### NetBird Resources
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/index.md
The Pulumi NetBird Provider manages various NetBird resource types declaratively. These include DNS configurations, network structures, peer management, access policies, setup keys, and user accounts.
```APIDOC
## NetBird Resources
### Description
The provider manages the following NetBird resource types:
- **DNS** - DNS nameserver groups
- **DNSRecord** - Individual DNS records within zones
- **DNSSettings** - Global DNS settings (singleton)
- **DNSZone** - DNS zones for domain management
- **Group** - Collections of peers
- **Network** - Network containers
- **NetworkResource** - CIDR ranges and subnets within networks
- **NetworkRouter** - Routers within networks
- **Peer** - Individual peers/devices in the network
- **Policy** - Access control policies with rules
- **PostureCheck** - Device posture checks
- **ReverseProxyDomain** - Domain configurations for reverse proxy
- **ReverseProxyService** - Reverse proxy service configurations
- **SetupKey** - Keys for peer registration
- **User** - User accounts
### Resource State Management
Each resource supports standard Pulumi operations:
- **Create** - Provision a new resource
- **Read** - Fetch current state from NetBird
- **Update** - Modify existing resource
- **Delete** - Remove resource
- **Diff** - Detect changes between desired and actual state
- **Check** - Validate resource inputs before applying
All state is automatically managed by Pulumi and stored in the stack state file.
```
--------------------------------
### Create a NetBird Group in C#
Source: https://github.com/mbrav/pulumi-netbird/blob/main/docs/_index.md
This snippet illustrates creating a NetBird group named 'DevOps' with an empty peer list using the Pulumi NetBird provider in C#. Use the `Deployment.RunAsync` method and import the necessary namespaces.
```csharp
using Pulumi;
using Mbrav.PulumiNetbird.Resource;
return await Deployment.RunAsync(() =>
{
var devOpsGroup = new Group("group-devops", new GroupArgs
{
Name = "DevOps",
Peers = {},
});
});
```
--------------------------------
### Define DNSSettings Resource
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/dnssettings.md
Initializes the DNS settings by applying the desired settings. This is used for creating or updating the global DNS configuration.
```go
settings, err := netbird.NewDNSSettings(ctx, "global-dns", &netbird.DNSSettingsArgs{
DisabledManagementGroups: pulumi.StringArray{
pulumi.String("group-id-1"),
},
})
```
--------------------------------
### Pulumi Config Set Configuration
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/configuration.md
Configure NetBird provider settings using the `pulumi config set` command. Use the `--secret` flag for sensitive values like the API token. You can view current configuration with `pulumi config get`.
```bash
# Using config set
pulumi config set netbird:url "https://api.netbird.io"
pulumi config set netbird:token "your-api-token" --secret
# View current configuration
pulumi config get netbird:url
```
--------------------------------
### Define a Nameserver Configuration
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/types.md
Defines a nameserver for DNS resolution, specifying its IP address, type (UDP), and port.
```go
type Nameserver struct {
IP string // IP address of nameserver
Type NameserverNsType // Nameserver type
Port int // Nameserver port
}
```
--------------------------------
### Basic Peer Configuration
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/peer.md
Configures a basic peer resource with a display name and SSH disabled.
```go
peer, err := netbird.NewPeer(ctx, "workstation", &netbird.PeerArgs{
Name: pulumi.String("Developer Workstation"),
SSHEnabled: pulumi.Bool(false),
})
```
--------------------------------
### Create Network and Group (Go)
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/README.md
Defines a production network and an engineering group using the NetBird Pulumi provider in Go. Exports the IDs of the created network and group.
```go
package main
import (
"github.com/mbrav/pulumi-netbird/sdk/go/netbird"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
net, err := netbird.NewNetwork(ctx, "prod", &netbird.NetworkArgs{
Name: pulumi.String("Production"),
Description: pulumi.String("Production network"),
})
if err != nil {
return err
}
group, err := netbird.NewGroup(ctx, "eng", &netbird.GroupArgs{
Name: pulumi.String("Engineering"),
})
if err != nil {
return err
}
ctx.Export("networkId", net.ID())
ctx.Export("groupId", group.ID())
return nil
})
}
```
--------------------------------
### Create Primary DNS Nameserver Group
Source: https://github.com/mbrav/pulumi-netbird/blob/main/_autodocs/api-reference/dns.md
Use this snippet to create a primary DNS nameserver group. This group will be used as the default for all clients. Ensure that the `Nameservers` are correctly configured with IP addresses, types, and ports.
```go
primary, err := netbird.NewDNS(ctx, "primary", &netbird.DNSArgs{
Name: pulumi.String("Primary DNS"),
Primary: pulumi.Bool(true),
Enabled: pulumi.Bool(true),
Nameservers: netbird.NameserverArray{
&netbird.NameserverArgs{
IP: pulumi.String("8.8.8.8"),
Type: netbird.NameserverNsTypeUDP,
Port: pulumi.Int(53),
},
&netbird.NameserverArgs{
IP: pulumi.String("8.8.4.4"),
Type: netbird.NameserverNsTypeUDP,
Port: pulumi.Int(53),
},
},
})
```
--------------------------------
### Configure NetBird Provider via Pulumi CLI
Source: https://github.com/mbrav/pulumi-netbird/blob/main/docs/installation-configuration.md
Use this command to set configuration options for the NetBird provider via the Pulumi CLI. Replace `