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

ionoscloud.getNsg

Explore with Pulumi AI

ionoscloud logo
ionoscloud 6.7.6 published on Monday, Apr 14, 2025 by ionos-cloud

    The NSG Data source can be used to search for and return an existing security group. If a single match is found, it will be returned. If your search results in multiple matches, an error will be returned. When this happens, please refine your search string so that it is specific enough to return only one result.

    Example Usage

    By ID

    import * as pulumi from "@pulumi/pulumi";
    import * as ionoscloud from "@pulumi/ionoscloud";
    
    const example = ionoscloud.getNsg({
        datacenterId: ionoscloud_datacenter.example.id,
        id: nsg_id,
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.get_nsg(datacenter_id=ionoscloud_datacenter["example"]["id"],
        id=nsg_id)
    
    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 {
    		_, err := ionoscloud.LookupNsg(ctx, &ionoscloud.LookupNsgArgs{
    			DatacenterId: ionoscloud_datacenter.Example.Id,
    			Id:           pulumi.StringRef(nsg_id),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ionoscloud = Pulumi.Ionoscloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Ionoscloud.GetNsg.Invoke(new()
        {
            DatacenterId = ionoscloud_datacenter.Example.Id,
            Id = nsg_id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ionoscloud.IonoscloudFunctions;
    import com.pulumi.ionoscloud.inputs.GetNsgArgs;
    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) {
            final var example = IonoscloudFunctions.getNsg(GetNsgArgs.builder()
                .datacenterId(ionoscloud_datacenter.example().id())
                .id(nsg_id)
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ionoscloud:getNsg
          arguments:
            datacenterId: ${ionoscloud_datacenter.example.id}
            id: ${nsg_id}
    

    By Name

    import * as pulumi from "@pulumi/pulumi";
    import * as ionoscloud from "@pulumi/ionoscloud";
    
    const example = ionoscloud.getNsg({
        datacenterId: ionoscloud_datacenter.example.id,
        name: "NSG Example",
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.get_nsg(datacenter_id=ionoscloud_datacenter["example"]["id"],
        name="NSG Example")
    
    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 {
    		_, err := ionoscloud.LookupNsg(ctx, &ionoscloud.LookupNsgArgs{
    			DatacenterId: ionoscloud_datacenter.Example.Id,
    			Name:         pulumi.StringRef("NSG Example"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ionoscloud = Pulumi.Ionoscloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Ionoscloud.GetNsg.Invoke(new()
        {
            DatacenterId = ionoscloud_datacenter.Example.Id,
            Name = "NSG Example",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ionoscloud.IonoscloudFunctions;
    import com.pulumi.ionoscloud.inputs.GetNsgArgs;
    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) {
            final var example = IonoscloudFunctions.getNsg(GetNsgArgs.builder()
                .datacenterId(ionoscloud_datacenter.example().id())
                .name("NSG Example")
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ionoscloud:getNsg
          arguments:
            datacenterId: ${ionoscloud_datacenter.example.id}
            name: NSG Example
    

    Using getNsg

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getNsg(args: GetNsgArgs, opts?: InvokeOptions): Promise<GetNsgResult>
    function getNsgOutput(args: GetNsgOutputArgs, opts?: InvokeOptions): Output<GetNsgResult>
    def get_nsg(datacenter_id: Optional[str] = None,
                id: Optional[str] = None,
                name: Optional[str] = None,
                timeouts: Optional[GetNsgTimeouts] = None,
                opts: Optional[InvokeOptions] = None) -> GetNsgResult
    def get_nsg_output(datacenter_id: Optional[pulumi.Input[str]] = None,
                id: Optional[pulumi.Input[str]] = None,
                name: Optional[pulumi.Input[str]] = None,
                timeouts: Optional[pulumi.Input[GetNsgTimeoutsArgs]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetNsgResult]
    func LookupNsg(ctx *Context, args *LookupNsgArgs, opts ...InvokeOption) (*LookupNsgResult, error)
    func LookupNsgOutput(ctx *Context, args *LookupNsgOutputArgs, opts ...InvokeOption) LookupNsgResultOutput

    > Note: This function is named LookupNsg in the Go SDK.

    public static class GetNsg 
    {
        public static Task<GetNsgResult> InvokeAsync(GetNsgArgs args, InvokeOptions? opts = null)
        public static Output<GetNsgResult> Invoke(GetNsgInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetNsgResult> getNsg(GetNsgArgs args, InvokeOptions options)
    public static Output<GetNsgResult> getNsg(GetNsgArgs args, InvokeOptions options)
    
    fn::invoke:
      function: ionoscloud:index/getNsg:getNsg
      arguments:
        # arguments dictionary

    The following arguments are supported:

    DatacenterId string
    Datacenter's UUID.
    Id string
    Id of an existing Network Security Group that you want to search for.
    Name string

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    Timeouts GetNsgTimeouts
    DatacenterId string
    Datacenter's UUID.
    Id string
    Id of an existing Network Security Group that you want to search for.
    Name string

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    Timeouts GetNsgTimeouts
    datacenterId String
    Datacenter's UUID.
    id String
    Id of an existing Network Security Group that you want to search for.
    name String

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    timeouts GetNsgTimeouts
    datacenterId string
    Datacenter's UUID.
    id string
    Id of an existing Network Security Group that you want to search for.
    name string

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    timeouts GetNsgTimeouts
    datacenter_id str
    Datacenter's UUID.
    id str
    Id of an existing Network Security Group that you want to search for.
    name str

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    timeouts GetNsgTimeouts
    datacenterId String
    Datacenter's UUID.
    id String
    Id of an existing Network Security Group that you want to search for.
    name String

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    timeouts Property Map

    getNsg Result

    The following output properties are available:

    DatacenterId string
    UUID of the Virtual Data Center
    Description string
    Description for the Network Security Group
    Id string
    UUID of the Network Security Group
    Name string
    The name of the Network Security Group
    RuleIds List<string>
    List of IDs for the Firewall Rules attached to this group
    Rules List<GetNsgRule>
    List of Firewall Rule objects attached to this group
    Timeouts GetNsgTimeouts
    DatacenterId string
    UUID of the Virtual Data Center
    Description string
    Description for the Network Security Group
    Id string
    UUID of the Network Security Group
    Name string
    The name of the Network Security Group
    RuleIds []string
    List of IDs for the Firewall Rules attached to this group
    Rules []GetNsgRule
    List of Firewall Rule objects attached to this group
    Timeouts GetNsgTimeouts
    datacenterId String
    UUID of the Virtual Data Center
    description String
    Description for the Network Security Group
    id String
    UUID of the Network Security Group
    name String
    The name of the Network Security Group
    ruleIds List<String>
    List of IDs for the Firewall Rules attached to this group
    rules List<GetNsgRule>
    List of Firewall Rule objects attached to this group
    timeouts GetNsgTimeouts
    datacenterId string
    UUID of the Virtual Data Center
    description string
    Description for the Network Security Group
    id string
    UUID of the Network Security Group
    name string
    The name of the Network Security Group
    ruleIds string[]
    List of IDs for the Firewall Rules attached to this group
    rules GetNsgRule[]
    List of Firewall Rule objects attached to this group
    timeouts GetNsgTimeouts
    datacenter_id str
    UUID of the Virtual Data Center
    description str
    Description for the Network Security Group
    id str
    UUID of the Network Security Group
    name str
    The name of the Network Security Group
    rule_ids Sequence[str]
    List of IDs for the Firewall Rules attached to this group
    rules Sequence[GetNsgRule]
    List of Firewall Rule objects attached to this group
    timeouts GetNsgTimeouts
    datacenterId String
    UUID of the Virtual Data Center
    description String
    Description for the Network Security Group
    id String
    UUID of the Network Security Group
    name String
    The name of the Network Security Group
    ruleIds List<String>
    List of IDs for the Firewall Rules attached to this group
    rules List<Property Map>
    List of Firewall Rule objects attached to this group
    timeouts Property Map

    Supporting Types

    GetNsgRule

    IcmpCode string
    IcmpType string
    Id string
    Id of an existing Network Security Group that you want to search for.
    Name string

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    PortRangeEnd double
    PortRangeStart double
    Protocol string
    SourceIp string
    SourceMac string
    TargetIp string
    Type string
    IcmpCode string
    IcmpType string
    Id string
    Id of an existing Network Security Group that you want to search for.
    Name string

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    PortRangeEnd float64
    PortRangeStart float64
    Protocol string
    SourceIp string
    SourceMac string
    TargetIp string
    Type string
    icmpCode String
    icmpType String
    id String
    Id of an existing Network Security Group that you want to search for.
    name String

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    portRangeEnd Double
    portRangeStart Double
    protocol String
    sourceIp String
    sourceMac String
    targetIp String
    type String
    icmpCode string
    icmpType string
    id string
    Id of an existing Network Security Group that you want to search for.
    name string

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    portRangeEnd number
    portRangeStart number
    protocol string
    sourceIp string
    sourceMac string
    targetIp string
    type string
    icmp_code str
    icmp_type str
    id str
    Id of an existing Network Security Group that you want to search for.
    name str

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    port_range_end float
    port_range_start float
    protocol str
    source_ip str
    source_mac str
    target_ip str
    type str
    icmpCode String
    icmpType String
    id String
    Id of an existing Network Security Group that you want to search for.
    name String

    Name of an existing Network Security Group that you want to search for.

    Either name, or id must be provided. If none, the datasource will return an error.

    portRangeEnd Number
    portRangeStart Number
    protocol String
    sourceIp String
    sourceMac String
    targetIp String
    type String

    GetNsgTimeouts

    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.
    ionoscloud logo
    ionoscloud 6.7.6 published on Monday, Apr 14, 2025 by ionos-cloud