1. Packages
  2. Ionoscloud Provider
  3. API Docs
  4. Nsg
ionoscloud 6.7.6 published on Monday, Apr 14, 2025 by ionos-cloud

ionoscloud.Nsg

Explore with Pulumi AI

Manages a Network Security Group on IonosCloud.

Example Usage

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

const exampleDatacenter = new ionoscloud.Datacenter("exampleDatacenter", {location: "de/txl"});
const exampleNsg = new ionoscloud.Nsg("exampleNsg", {
    description: "Example NSG Description",
    datacenterId: exampleDatacenter.datacenterId,
});
Copy
import pulumi
import pulumi_ionoscloud as ionoscloud

example_datacenter = ionoscloud.Datacenter("exampleDatacenter", location="de/txl")
example_nsg = ionoscloud.Nsg("exampleNsg",
    description="Example NSG Description",
    datacenter_id=example_datacenter.datacenter_id)
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ionoscloud/v6/ionoscloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleDatacenter, err := ionoscloud.NewDatacenter(ctx, "exampleDatacenter", &ionoscloud.DatacenterArgs{
			Location: pulumi.String("de/txl"),
		})
		if err != nil {
			return err
		}
		_, err = ionoscloud.NewNsg(ctx, "exampleNsg", &ionoscloud.NsgArgs{
			Description:  pulumi.String("Example NSG Description"),
			DatacenterId: exampleDatacenter.DatacenterId,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ionoscloud = Pulumi.Ionoscloud;

return await Deployment.RunAsync(() => 
{
    var exampleDatacenter = new Ionoscloud.Datacenter("exampleDatacenter", new()
    {
        Location = "de/txl",
    });

    var exampleNsg = new Ionoscloud.Nsg("exampleNsg", new()
    {
        Description = "Example NSG Description",
        DatacenterId = exampleDatacenter.DatacenterId,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ionoscloud.Datacenter;
import com.pulumi.ionoscloud.DatacenterArgs;
import com.pulumi.ionoscloud.Nsg;
import com.pulumi.ionoscloud.NsgArgs;
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 exampleDatacenter = new Datacenter("exampleDatacenter", DatacenterArgs.builder()
            .location("de/txl")
            .build());

        var exampleNsg = new Nsg("exampleNsg", NsgArgs.builder()
            .description("Example NSG Description")
            .datacenterId(exampleDatacenter.datacenterId())
            .build());

    }
}
Copy
resources:
  exampleDatacenter:
    type: ionoscloud:Datacenter
    properties:
      location: de/txl
  exampleNsg:
    type: ionoscloud:Nsg
    properties:
      description: Example NSG Description
      datacenterId: ${exampleDatacenter.datacenterId}
Copy

Create Nsg Resource

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

Constructor syntax

new Nsg(name: string, args: NsgArgs, opts?: CustomResourceOptions);
@overload
def Nsg(resource_name: str,
        args: NsgArgs,
        opts: Optional[ResourceOptions] = None)

@overload
def Nsg(resource_name: str,
        opts: Optional[ResourceOptions] = None,
        datacenter_id: Optional[str] = None,
        description: Optional[str] = None,
        name: Optional[str] = None,
        nsg_id: Optional[str] = None,
        timeouts: Optional[NsgTimeoutsArgs] = None)
func NewNsg(ctx *Context, name string, args NsgArgs, opts ...ResourceOption) (*Nsg, error)
public Nsg(string name, NsgArgs args, CustomResourceOptions? opts = null)
public Nsg(String name, NsgArgs args)
public Nsg(String name, NsgArgs args, CustomResourceOptions options)
type: ionoscloud:Nsg
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. NsgArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. NsgArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. NsgArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. NsgArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. NsgArgs
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 nsgResource = new Ionoscloud.Nsg("nsgResource", new()
{
    DatacenterId = "string",
    Description = "string",
    Name = "string",
    NsgId = "string",
    Timeouts = new Ionoscloud.Inputs.NsgTimeoutsArgs
    {
        Create = "string",
        Default = "string",
        Delete = "string",
        Update = "string",
    },
});
Copy
example, err := ionoscloud.NewNsg(ctx, "nsgResource", &ionoscloud.NsgArgs{
	DatacenterId: pulumi.String("string"),
	Description:  pulumi.String("string"),
	Name:         pulumi.String("string"),
	NsgId:        pulumi.String("string"),
	Timeouts: &ionoscloud.NsgTimeoutsArgs{
		Create:  pulumi.String("string"),
		Default: pulumi.String("string"),
		Delete:  pulumi.String("string"),
		Update:  pulumi.String("string"),
	},
})
Copy
var nsgResource = new Nsg("nsgResource", NsgArgs.builder()
    .datacenterId("string")
    .description("string")
    .name("string")
    .nsgId("string")
    .timeouts(NsgTimeoutsArgs.builder()
        .create("string")
        .default_("string")
        .delete("string")
        .update("string")
        .build())
    .build());
Copy
nsg_resource = ionoscloud.Nsg("nsgResource",
    datacenter_id="string",
    description="string",
    name="string",
    nsg_id="string",
    timeouts={
        "create": "string",
        "default": "string",
        "delete": "string",
        "update": "string",
    })
Copy
const nsgResource = new ionoscloud.Nsg("nsgResource", {
    datacenterId: "string",
    description: "string",
    name: "string",
    nsgId: "string",
    timeouts: {
        create: "string",
        "default": "string",
        "delete": "string",
        update: "string",
    },
});
Copy
type: ionoscloud:Nsg
properties:
    datacenterId: string
    description: string
    name: string
    nsgId: string
    timeouts:
        create: string
        default: string
        delete: string
        update: string
Copy

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

DatacenterId This property is required. string
[string] The ID of a Virtual Data Center.
Description This property is required. string
[string] Description for the Network Security Group.
Name string
[string] The name of the Network Security Group.
NsgId string
Timeouts NsgTimeouts
DatacenterId This property is required. string
[string] The ID of a Virtual Data Center.
Description This property is required. string
[string] Description for the Network Security Group.
Name string
[string] The name of the Network Security Group.
NsgId string
Timeouts NsgTimeoutsArgs
datacenterId This property is required. String
[string] The ID of a Virtual Data Center.
description This property is required. String
[string] Description for the Network Security Group.
name String
[string] The name of the Network Security Group.
nsgId String
timeouts NsgTimeouts
datacenterId This property is required. string
[string] The ID of a Virtual Data Center.
description This property is required. string
[string] Description for the Network Security Group.
name string
[string] The name of the Network Security Group.
nsgId string
timeouts NsgTimeouts
datacenter_id This property is required. str
[string] The ID of a Virtual Data Center.
description This property is required. str
[string] Description for the Network Security Group.
name str
[string] The name of the Network Security Group.
nsg_id str
timeouts NsgTimeoutsArgs
datacenterId This property is required. String
[string] The ID of a Virtual Data Center.
description This property is required. String
[string] Description for the Network Security Group.
name String
[string] The name of the Network Security Group.
nsgId String
timeouts Property Map

Outputs

All input properties are implicitly available as output properties. Additionally, the Nsg resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
RuleIds List<string>
List of Firewall Rules that are part of the Network Security Group
Id string
The provider-assigned unique ID for this managed resource.
RuleIds []string
List of Firewall Rules that are part of the Network Security Group
id String
The provider-assigned unique ID for this managed resource.
ruleIds List<String>
List of Firewall Rules that are part of the Network Security Group
id string
The provider-assigned unique ID for this managed resource.
ruleIds string[]
List of Firewall Rules that are part of the Network Security Group
id str
The provider-assigned unique ID for this managed resource.
rule_ids Sequence[str]
List of Firewall Rules that are part of the Network Security Group
id String
The provider-assigned unique ID for this managed resource.
ruleIds List<String>
List of Firewall Rules that are part of the Network Security Group

Look up Existing Nsg Resource

Get an existing Nsg 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?: NsgState, opts?: CustomResourceOptions): Nsg
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        datacenter_id: Optional[str] = None,
        description: Optional[str] = None,
        name: Optional[str] = None,
        nsg_id: Optional[str] = None,
        rule_ids: Optional[Sequence[str]] = None,
        timeouts: Optional[NsgTimeoutsArgs] = None) -> Nsg
func GetNsg(ctx *Context, name string, id IDInput, state *NsgState, opts ...ResourceOption) (*Nsg, error)
public static Nsg Get(string name, Input<string> id, NsgState? state, CustomResourceOptions? opts = null)
public static Nsg get(String name, Output<String> id, NsgState state, CustomResourceOptions options)
resources:  _:    type: ionoscloud:Nsg    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
DatacenterId string
[string] The ID of a Virtual Data Center.
Description string
[string] Description for the Network Security Group.
Name string
[string] The name of the Network Security Group.
NsgId string
RuleIds List<string>
List of Firewall Rules that are part of the Network Security Group
Timeouts NsgTimeouts
DatacenterId string
[string] The ID of a Virtual Data Center.
Description string
[string] Description for the Network Security Group.
Name string
[string] The name of the Network Security Group.
NsgId string
RuleIds []string
List of Firewall Rules that are part of the Network Security Group
Timeouts NsgTimeoutsArgs
datacenterId String
[string] The ID of a Virtual Data Center.
description String
[string] Description for the Network Security Group.
name String
[string] The name of the Network Security Group.
nsgId String
ruleIds List<String>
List of Firewall Rules that are part of the Network Security Group
timeouts NsgTimeouts
datacenterId string
[string] The ID of a Virtual Data Center.
description string
[string] Description for the Network Security Group.
name string
[string] The name of the Network Security Group.
nsgId string
ruleIds string[]
List of Firewall Rules that are part of the Network Security Group
timeouts NsgTimeouts
datacenter_id str
[string] The ID of a Virtual Data Center.
description str
[string] Description for the Network Security Group.
name str
[string] The name of the Network Security Group.
nsg_id str
rule_ids Sequence[str]
List of Firewall Rules that are part of the Network Security Group
timeouts NsgTimeoutsArgs
datacenterId String
[string] The ID of a Virtual Data Center.
description String
[string] Description for the Network Security Group.
name String
[string] The name of the Network Security Group.
nsgId String
ruleIds List<String>
List of Firewall Rules that are part of the Network Security Group
timeouts Property Map

Supporting Types

NsgTimeouts
, NsgTimeoutsArgs

Create string
Default string
Delete string
Update string
Create string
Default string
Delete string
Update string
create String
default_ String
delete String
update String
create string
default string
delete string
update string
create String
default String
delete String
update String

Import

Resource Server can be imported using the resource id and the datacenter id, e.g.

$ pulumi import ionoscloud:index/nsg:Nsg mynsg datacenter uuid/nsg uuid
Copy

Or by using an import block. Here is an example that allows you to import the default created nsg into terraform.

hcl

resource “ionoscloud_datacenter” “example” {

name = “Datacenter NSG Example”

location = “de/txl”

}

import {

to = ionoscloud_nsg.imported

id = “datacenter uuid/default nsg uuid”

}

resource “ionoscloud_nsg” “imported_default” { # Imported here

datacenter_id = ionoscloud_datacenter.example.id

}

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
ionoscloud ionos-cloud/terraform-provider-ionoscloud
License
Notes
This Pulumi package is based on the ionoscloud Terraform Provider.