1. Packages
  2. Ionoscloud
  3. API Docs
  4. nsg
  5. DatacenterNsgSelection
IonosCloud v0.2.3 published on Tuesday, May 13, 2025 by ionos-cloud

ionoscloud.nsg.DatacenterNsgSelection

Explore with Pulumi AI

ionoscloud logo
IonosCloud v0.2.3 published on Tuesday, May 13, 2025 by ionos-cloud

    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.compute.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 "@ionos-cloud/sdk-pulumi";
    
    const example = new ionoscloud.compute.Datacenter("example", {
        name: "Datacenter Default NSG Example",
        location: "de/fra",
    });
    const exampleNsg = new ionoscloud.nsg.Nsg("example", {
        name: "NSG",
        description: "NSG",
        datacenterId: example.id,
    });
    const exampleDatacenterNsgSelection = new ionoscloud.nsg.DatacenterNsgSelection("example", {
        datacenterId: example.id,
        nsgId: exampleNsg.id,
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.compute.Datacenter("example",
        name="Datacenter Default NSG Example",
        location="de/fra")
    example_nsg = ionoscloud.nsg.Nsg("example",
        name="NSG",
        description="NSG",
        datacenter_id=example.id)
    example_datacenter_nsg_selection = ionoscloud.nsg.DatacenterNsgSelection("example",
        datacenter_id=example.id,
        nsg_id=example_nsg.id)
    
    package main
    
    import (
    	"github.com/ionos-cloud/pulumi-ionoscloud/sdk/go/ionoscloud/compute"
    	"github.com/ionos-cloud/pulumi-ionoscloud/sdk/go/ionoscloud/nsg"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := compute.NewDatacenter(ctx, "example", &compute.DatacenterArgs{
    			Name:     pulumi.String("Datacenter Default NSG Example"),
    			Location: pulumi.String("de/fra"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleNsg, err := nsg.NewNsg(ctx, "example", &nsg.NsgArgs{
    			Name:         pulumi.String("NSG"),
    			Description:  pulumi.String("NSG"),
    			DatacenterId: example.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = nsg.NewDatacenterNsgSelection(ctx, "example", &nsg.DatacenterNsgSelectionArgs{
    			DatacenterId: example.ID(),
    			NsgId:        exampleNsg.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ionoscloud = Ionoscloud.Pulumi.Ionoscloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Ionoscloud.Compute.Datacenter("example", new()
        {
            Name = "Datacenter Default NSG Example",
            Location = "de/fra",
        });
    
        var exampleNsg = new Ionoscloud.Nsg.Nsg("example", new()
        {
            Name = "NSG",
            Description = "NSG",
            DatacenterId = example.Id,
        });
    
        var exampleDatacenterNsgSelection = new Ionoscloud.Nsg.DatacenterNsgSelection("example", new()
        {
            DatacenterId = example.Id,
            NsgId = exampleNsg.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ionoscloud.compute.Datacenter;
    import com.pulumi.ionoscloud.compute.DatacenterArgs;
    import com.pulumi.ionoscloud.nsg.Nsg;
    import com.pulumi.ionoscloud.nsg.NsgArgs;
    import com.pulumi.ionoscloud.nsg.DatacenterNsgSelection;
    import com.pulumi.ionoscloud.nsg.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 example = new Datacenter("example", DatacenterArgs.builder()
                .name("Datacenter Default NSG Example")
                .location("de/fra")
                .build());
    
            var exampleNsg = new Nsg("exampleNsg", NsgArgs.builder()
                .name("NSG")
                .description("NSG")
                .datacenterId(example.id())
                .build());
    
            var exampleDatacenterNsgSelection = new DatacenterNsgSelection("exampleDatacenterNsgSelection", DatacenterNsgSelectionArgs.builder()
                .datacenterId(example.id())
                .nsgId(exampleNsg.id())
                .build());
    
        }
    }
    
    resources:
      example:
        type: ionoscloud:compute:Datacenter
        properties:
          name: Datacenter Default NSG Example
          location: de/fra
      exampleNsg:
        type: ionoscloud:nsg:Nsg
        name: example
        properties:
          name: NSG
          description: NSG
          datacenterId: ${example.id}
      exampleDatacenterNsgSelection:
        type: ionoscloud:nsg:DatacenterNsgSelection
        name: example
        properties:
          datacenterId: ${example.id}
          nsgId: ${exampleNsg.id}
    

    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)
    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:nsg:DatacenterNsgSelection
    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 DatacenterNsgSelectionArgs
    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 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 string
    The unique name of the resource.
    args DatacenterNsgSelectionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DatacenterNsgSelectionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args 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.Nsg.DatacenterNsgSelection("datacenterNsgSelectionResource", new()
    {
        DatacenterId = "string",
        NsgId = "string",
    });
    
    example, err := nsg.NewDatacenterNsgSelection(ctx, "datacenterNsgSelectionResource", &nsg.DatacenterNsgSelectionArgs{
    	DatacenterId: pulumi.String("string"),
    	NsgId:        pulumi.String("string"),
    })
    
    var datacenterNsgSelectionResource = new DatacenterNsgSelection("datacenterNsgSelectionResource", DatacenterNsgSelectionArgs.builder()
        .datacenterId("string")
        .nsgId("string")
        .build());
    
    datacenter_nsg_selection_resource = ionoscloud.nsg.DatacenterNsgSelection("datacenterNsgSelectionResource",
        datacenter_id="string",
        nsg_id="string")
    
    const datacenterNsgSelectionResource = new ionoscloud.nsg.DatacenterNsgSelection("datacenterNsgSelectionResource", {
        datacenterId: "string",
        nsgId: "string",
    });
    
    type: ionoscloud:nsg:DatacenterNsgSelection
    properties:
        datacenterId: string
        nsgId: string
    

    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 string
    [string] The ID of a Virtual Data Center.
    NsgId string
    [string] The ID of a Network Security Group.
    DatacenterId string
    [string] The ID of a Virtual Data Center.
    NsgId string
    [string] The ID of a Network Security Group.
    datacenterId String
    [string] The ID of a Virtual Data Center.
    nsgId String
    [string] The ID of a Network Security Group.
    datacenterId string
    [string] The ID of a Virtual Data Center.
    nsgId string
    [string] The ID of a Network Security Group.
    datacenter_id str
    [string] The ID of a Virtual Data Center.
    nsg_id str
    [string] The ID of a Network Security Group.
    datacenterId String
    [string] The ID of a Virtual Data Center.
    nsgId String
    [string] The ID of a Network Security Group.

    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,
            nsg_id: Optional[str] = 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:nsg:DatacenterNsgSelection    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    DatacenterId string
    [string] The ID of a Virtual Data Center.
    NsgId string
    [string] The ID of a Network Security Group.
    DatacenterId string
    [string] The ID of a Virtual Data Center.
    NsgId string
    [string] The ID of a Network Security Group.
    datacenterId String
    [string] The ID of a Virtual Data Center.
    nsgId String
    [string] The ID of a Network Security Group.
    datacenterId string
    [string] The ID of a Virtual Data Center.
    nsgId string
    [string] The ID of a Network Security Group.
    datacenter_id str
    [string] The ID of a Virtual Data Center.
    nsg_id str
    [string] The ID of a Network Security Group.
    datacenterId String
    [string] The ID of a Virtual Data Center.
    nsgId String
    [string] The ID of a Network Security Group.

    Package Details

    Repository
    ionoscloud ionos-cloud/pulumi-ionoscloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the ionoscloud Terraform Provider.
    ionoscloud logo
    IonosCloud v0.2.3 published on Tuesday, May 13, 2025 by ionos-cloud