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

ionoscloud.DatacenterNsgSelection

Explore with Pulumi AI

Links a Network Security Group to a IonosCloud datacenter. The datacenter can only have one linked NSG. To set a new NSG for the datacenter, the current one will be unlinked.

Example Usage

A Network Security Group can be linked to a ionoscloud.Datacenter with this resource. Deleting the resource will unlink the NSG from the datacenter.

Select an external volume

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

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

example_datacenter = ionoscloud.Datacenter("exampleDatacenter", location="de/fra")
example_nsg = ionoscloud.Nsg("exampleNsg",
    description="NSG",
    datacenter_id=example_datacenter.datacenter_id)
example_datacenter_nsg_selection = ionoscloud.DatacenterNsgSelection("exampleDatacenterNsgSelection",
    datacenter_id=example_datacenter.datacenter_id,
    nsg_id=example_nsg.nsg_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/fra"),
		})
		if err != nil {
			return err
		}
		exampleNsg, err := ionoscloud.NewNsg(ctx, "exampleNsg", &ionoscloud.NsgArgs{
			Description:  pulumi.String("NSG"),
			DatacenterId: exampleDatacenter.DatacenterId,
		})
		if err != nil {
			return err
		}
		_, err = ionoscloud.NewDatacenterNsgSelection(ctx, "exampleDatacenterNsgSelection", &ionoscloud.DatacenterNsgSelectionArgs{
			DatacenterId: exampleDatacenter.DatacenterId,
			NsgId:        exampleNsg.NsgId,
		})
		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/fra",
    });

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

    var exampleDatacenterNsgSelection = new Ionoscloud.DatacenterNsgSelection("exampleDatacenterNsgSelection", new()
    {
        DatacenterId = exampleDatacenter.DatacenterId,
        NsgId = exampleNsg.NsgId,
    });

});
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 com.pulumi.ionoscloud.DatacenterNsgSelection;
import com.pulumi.ionoscloud.DatacenterNsgSelectionArgs;
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/fra")
            .build());

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

        var exampleDatacenterNsgSelection = new DatacenterNsgSelection("exampleDatacenterNsgSelection", DatacenterNsgSelectionArgs.builder()
            .datacenterId(exampleDatacenter.datacenterId())
            .nsgId(exampleNsg.nsgId())
            .build());

    }
}
Copy
resources:
  exampleDatacenter:
    type: ionoscloud:Datacenter
    properties:
      location: de/fra
  exampleNsg:
    type: ionoscloud:Nsg
    properties:
      description: NSG
      datacenterId: ${exampleDatacenter.datacenterId}
  exampleDatacenterNsgSelection:
    type: ionoscloud:DatacenterNsgSelection
    properties:
      datacenterId: ${exampleDatacenter.datacenterId}
      nsgId: ${exampleNsg.nsgId}
Copy

Create DatacenterNsgSelection Resource

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

Constructor syntax

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

@overload
def DatacenterNsgSelection(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           datacenter_id: Optional[str] = None,
                           nsg_id: Optional[str] = None,
                           datacenter_nsg_selection_id: Optional[str] = None,
                           timeouts: Optional[DatacenterNsgSelectionTimeoutsArgs] = None)
func NewDatacenterNsgSelection(ctx *Context, name string, args DatacenterNsgSelectionArgs, opts ...ResourceOption) (*DatacenterNsgSelection, error)
public DatacenterNsgSelection(string name, DatacenterNsgSelectionArgs args, CustomResourceOptions? opts = null)
public DatacenterNsgSelection(String name, DatacenterNsgSelectionArgs args)
public DatacenterNsgSelection(String name, DatacenterNsgSelectionArgs args, CustomResourceOptions options)
type: ionoscloud:DatacenterNsgSelection
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. DatacenterNsgSelectionArgs
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. DatacenterNsgSelectionArgs
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. DatacenterNsgSelectionArgs
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. DatacenterNsgSelectionArgs
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. DatacenterNsgSelectionArgs
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 datacenterNsgSelectionResource = new Ionoscloud.DatacenterNsgSelection("datacenterNsgSelectionResource", new()
{
    DatacenterId = "string",
    NsgId = "string",
    DatacenterNsgSelectionId = "string",
    Timeouts = new Ionoscloud.Inputs.DatacenterNsgSelectionTimeoutsArgs
    {
        Create = "string",
        Default = "string",
        Delete = "string",
        Update = "string",
    },
});
Copy
example, err := ionoscloud.NewDatacenterNsgSelection(ctx, "datacenterNsgSelectionResource", &ionoscloud.DatacenterNsgSelectionArgs{
	DatacenterId:             pulumi.String("string"),
	NsgId:                    pulumi.String("string"),
	DatacenterNsgSelectionId: pulumi.String("string"),
	Timeouts: &ionoscloud.DatacenterNsgSelectionTimeoutsArgs{
		Create:  pulumi.String("string"),
		Default: pulumi.String("string"),
		Delete:  pulumi.String("string"),
		Update:  pulumi.String("string"),
	},
})
Copy
var datacenterNsgSelectionResource = new DatacenterNsgSelection("datacenterNsgSelectionResource", DatacenterNsgSelectionArgs.builder()
    .datacenterId("string")
    .nsgId("string")
    .datacenterNsgSelectionId("string")
    .timeouts(DatacenterNsgSelectionTimeoutsArgs.builder()
        .create("string")
        .default_("string")
        .delete("string")
        .update("string")
        .build())
    .build());
Copy
datacenter_nsg_selection_resource = ionoscloud.DatacenterNsgSelection("datacenterNsgSelectionResource",
    datacenter_id="string",
    nsg_id="string",
    datacenter_nsg_selection_id="string",
    timeouts={
        "create": "string",
        "default": "string",
        "delete": "string",
        "update": "string",
    })
Copy
const datacenterNsgSelectionResource = new ionoscloud.DatacenterNsgSelection("datacenterNsgSelectionResource", {
    datacenterId: "string",
    nsgId: "string",
    datacenterNsgSelectionId: "string",
    timeouts: {
        create: "string",
        "default": "string",
        "delete": "string",
        update: "string",
    },
});
Copy
type: ionoscloud:DatacenterNsgSelection
properties:
    datacenterId: string
    datacenterNsgSelectionId: string
    nsgId: string
    timeouts:
        create: string
        default: string
        delete: string
        update: string
Copy

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

DatacenterId This property is required. string
[string] The ID of a Virtual Data Center.
NsgId This property is required. string
[string] The ID of a Network Security Group.
DatacenterNsgSelectionId string
Timeouts DatacenterNsgSelectionTimeouts
DatacenterId This property is required. string
[string] The ID of a Virtual Data Center.
NsgId This property is required. string
[string] The ID of a Network Security Group.
DatacenterNsgSelectionId string
Timeouts DatacenterNsgSelectionTimeoutsArgs
datacenterId This property is required. String
[string] The ID of a Virtual Data Center.
nsgId This property is required. String
[string] The ID of a Network Security Group.
datacenterNsgSelectionId String
timeouts DatacenterNsgSelectionTimeouts
datacenterId This property is required. string
[string] The ID of a Virtual Data Center.
nsgId This property is required. string
[string] The ID of a Network Security Group.
datacenterNsgSelectionId string
timeouts DatacenterNsgSelectionTimeouts
datacenter_id This property is required. str
[string] The ID of a Virtual Data Center.
nsg_id This property is required. str
[string] The ID of a Network Security Group.
datacenter_nsg_selection_id str
timeouts DatacenterNsgSelectionTimeoutsArgs
datacenterId This property is required. String
[string] The ID of a Virtual Data Center.
nsgId This property is required. String
[string] The ID of a Network Security Group.
datacenterNsgSelectionId String
timeouts Property Map

Outputs

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

Get an existing DatacenterNsgSelection 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?: DatacenterNsgSelectionState, opts?: CustomResourceOptions): DatacenterNsgSelection
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        datacenter_id: Optional[str] = None,
        datacenter_nsg_selection_id: Optional[str] = None,
        nsg_id: Optional[str] = None,
        timeouts: Optional[DatacenterNsgSelectionTimeoutsArgs] = None) -> DatacenterNsgSelection
func GetDatacenterNsgSelection(ctx *Context, name string, id IDInput, state *DatacenterNsgSelectionState, opts ...ResourceOption) (*DatacenterNsgSelection, error)
public static DatacenterNsgSelection Get(string name, Input<string> id, DatacenterNsgSelectionState? state, CustomResourceOptions? opts = null)
public static DatacenterNsgSelection get(String name, Output<String> id, DatacenterNsgSelectionState state, CustomResourceOptions options)
resources:  _:    type: ionoscloud:DatacenterNsgSelection    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.
DatacenterNsgSelectionId string
NsgId string
[string] The ID of a Network Security Group.
Timeouts DatacenterNsgSelectionTimeouts
DatacenterId string
[string] The ID of a Virtual Data Center.
DatacenterNsgSelectionId string
NsgId string
[string] The ID of a Network Security Group.
Timeouts DatacenterNsgSelectionTimeoutsArgs
datacenterId String
[string] The ID of a Virtual Data Center.
datacenterNsgSelectionId String
nsgId String
[string] The ID of a Network Security Group.
timeouts DatacenterNsgSelectionTimeouts
datacenterId string
[string] The ID of a Virtual Data Center.
datacenterNsgSelectionId string
nsgId string
[string] The ID of a Network Security Group.
timeouts DatacenterNsgSelectionTimeouts
datacenter_id str
[string] The ID of a Virtual Data Center.
datacenter_nsg_selection_id str
nsg_id str
[string] The ID of a Network Security Group.
timeouts DatacenterNsgSelectionTimeoutsArgs
datacenterId String
[string] The ID of a Virtual Data Center.
datacenterNsgSelectionId String
nsgId String
[string] The ID of a Network Security Group.
timeouts Property Map

Supporting Types

DatacenterNsgSelectionTimeouts
, DatacenterNsgSelectionTimeoutsArgs

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

Package Details

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