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

ionoscloud.compute.getServers

Explore with Pulumi AI

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

    The Servers data source can be used to search for and return existing servers based on filters used.

    Example Usage

    By Name

    import * as pulumi from "@pulumi/pulumi";
    import * as ionoscloud from "@pulumi/ionoscloud";
    
    const example = ionoscloud.compute.getServers({
        datacenterId: exampleIonoscloudDatacenter.id,
        filters: [{
            name: "name",
            value: "server_name_to_look_here",
        }],
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.compute.get_servers(datacenter_id=example_ionoscloud_datacenter["id"],
        filters=[{
            "name": "name",
            "value": "server_name_to_look_here",
        }])
    
    package main
    
    import (
    	"github.com/ionos-cloud/pulumi-ionoscloud/sdk/go/ionoscloud/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := compute.GetServers(ctx, &compute.GetServersArgs{
    			DatacenterId: exampleIonoscloudDatacenter.Id,
    			Filters: []compute.GetServersFilter{
    				{
    					Name:  "name",
    					Value: "server_name_to_look_here",
    				},
    			},
    		}, 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.Compute.GetServers.Invoke(new()
        {
            DatacenterId = exampleIonoscloudDatacenter.Id,
            Filters = new[]
            {
                new Ionoscloud.Compute.Inputs.GetServersFilterInputArgs
                {
                    Name = "name",
                    Value = "server_name_to_look_here",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ionoscloud.compute.ComputeFunctions;
    import com.pulumi.ionoscloud.compute.inputs.GetServersArgs;
    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 = ComputeFunctions.getServers(GetServersArgs.builder()
                .datacenterId(exampleIonoscloudDatacenter.id())
                .filters(GetServersFilterArgs.builder()
                    .name("name")
                    .value("server_name_to_look_here")
                    .build())
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ionoscloud:compute:getServers
          arguments:
            datacenterId: ${exampleIonoscloudDatacenter.id}
            filters:
              - name: name
                value: server_name_to_look_here
    

    By CPU Family

    import * as pulumi from "@pulumi/pulumi";
    import * as ionoscloud from "@pulumi/ionoscloud";
    
    const example = ionoscloud.compute.getServers({
        datacenterId: exampleIonoscloudDatacenter.id,
        filters: [{
            name: "cpu_family",
            value: "INTEL_XEON",
        }],
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.compute.get_servers(datacenter_id=example_ionoscloud_datacenter["id"],
        filters=[{
            "name": "cpu_family",
            "value": "INTEL_XEON",
        }])
    
    package main
    
    import (
    	"github.com/ionos-cloud/pulumi-ionoscloud/sdk/go/ionoscloud/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := compute.GetServers(ctx, &compute.GetServersArgs{
    			DatacenterId: exampleIonoscloudDatacenter.Id,
    			Filters: []compute.GetServersFilter{
    				{
    					Name:  "cpu_family",
    					Value: "INTEL_XEON",
    				},
    			},
    		}, 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.Compute.GetServers.Invoke(new()
        {
            DatacenterId = exampleIonoscloudDatacenter.Id,
            Filters = new[]
            {
                new Ionoscloud.Compute.Inputs.GetServersFilterInputArgs
                {
                    Name = "cpu_family",
                    Value = "INTEL_XEON",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ionoscloud.compute.ComputeFunctions;
    import com.pulumi.ionoscloud.compute.inputs.GetServersArgs;
    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 = ComputeFunctions.getServers(GetServersArgs.builder()
                .datacenterId(exampleIonoscloudDatacenter.id())
                .filters(GetServersFilterArgs.builder()
                    .name("cpu_family")
                    .value("INTEL_XEON")
                    .build())
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ionoscloud:compute:getServers
          arguments:
            datacenterId: ${exampleIonoscloudDatacenter.id}
            filters:
              - name: cpu_family
                value: INTEL_XEON
    

    By Name and Cores

    import * as pulumi from "@pulumi/pulumi";
    import * as ionoscloud from "@pulumi/ionoscloud";
    
    const example = ionoscloud.compute.getServers({
        datacenterId: exampleIonoscloudDatacenter.id,
        filters: [
            {
                name: "name",
                value: "test",
            },
            {
                name: "cores",
                value: "1",
            },
        ],
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.compute.get_servers(datacenter_id=example_ionoscloud_datacenter["id"],
        filters=[
            {
                "name": "name",
                "value": "test",
            },
            {
                "name": "cores",
                "value": "1",
            },
        ])
    
    package main
    
    import (
    	"github.com/ionos-cloud/pulumi-ionoscloud/sdk/go/ionoscloud/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := compute.GetServers(ctx, &compute.GetServersArgs{
    			DatacenterId: exampleIonoscloudDatacenter.Id,
    			Filters: []compute.GetServersFilter{
    				{
    					Name:  "name",
    					Value: "test",
    				},
    				{
    					Name:  "cores",
    					Value: "1",
    				},
    			},
    		}, 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.Compute.GetServers.Invoke(new()
        {
            DatacenterId = exampleIonoscloudDatacenter.Id,
            Filters = new[]
            {
                new Ionoscloud.Compute.Inputs.GetServersFilterInputArgs
                {
                    Name = "name",
                    Value = "test",
                },
                new Ionoscloud.Compute.Inputs.GetServersFilterInputArgs
                {
                    Name = "cores",
                    Value = "1",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ionoscloud.compute.ComputeFunctions;
    import com.pulumi.ionoscloud.compute.inputs.GetServersArgs;
    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 = ComputeFunctions.getServers(GetServersArgs.builder()
                .datacenterId(exampleIonoscloudDatacenter.id())
                .filters(            
                    GetServersFilterArgs.builder()
                        .name("name")
                        .value("test")
                        .build(),
                    GetServersFilterArgs.builder()
                        .name("cores")
                        .value("1")
                        .build())
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ionoscloud:compute:getServers
          arguments:
            datacenterId: ${exampleIonoscloudDatacenter.id}
            filters:
              - name: name
                value: test
              - name: cores
                value: '1'
    

    Using getServers

    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 getServers(args: GetServersArgs, opts?: InvokeOptions): Promise<GetServersResult>
    function getServersOutput(args: GetServersOutputArgs, opts?: InvokeOptions): Output<GetServersResult>
    def get_servers(datacenter_id: Optional[str] = None,
                    filters: Optional[Sequence[GetServersFilter]] = None,
                    opts: Optional[InvokeOptions] = None) -> GetServersResult
    def get_servers_output(datacenter_id: Optional[pulumi.Input[str]] = None,
                    filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetServersFilterArgs]]]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetServersResult]
    func GetServers(ctx *Context, args *GetServersArgs, opts ...InvokeOption) (*GetServersResult, error)
    func GetServersOutput(ctx *Context, args *GetServersOutputArgs, opts ...InvokeOption) GetServersResultOutput

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

    public static class GetServers 
    {
        public static Task<GetServersResult> InvokeAsync(GetServersArgs args, InvokeOptions? opts = null)
        public static Output<GetServersResult> Invoke(GetServersInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetServersResult> getServers(GetServersArgs args, InvokeOptions options)
    public static Output<GetServersResult> getServers(GetServersArgs args, InvokeOptions options)
    
    fn::invoke:
      function: ionoscloud:compute/getServers:getServers
      arguments:
        # arguments dictionary

    The following arguments are supported:

    DatacenterId string
    Name of an existing datacenter that the servers are a part of
    Filters List<Ionoscloud.GetServersFilter>

    One or more name/value pairs to filter off of. You can use most base fields in the server resource. These do NOT include nested fields in nics or volume nested fields.

    datacenter_id must be provided. If datacenter_id is missing , the datasource will return an error.

    NOTE: Lookup by filter is partial. Searching for a server using filter name and value test, will find all servers that have test in the name. For example, it will find servers named test, test1, testsomething.

    NOTE: You cannot search by image_name by providing an alias like ubuntu.

    DatacenterId string
    Name of an existing datacenter that the servers are a part of
    Filters []GetServersFilter

    One or more name/value pairs to filter off of. You can use most base fields in the server resource. These do NOT include nested fields in nics or volume nested fields.

    datacenter_id must be provided. If datacenter_id is missing , the datasource will return an error.

    NOTE: Lookup by filter is partial. Searching for a server using filter name and value test, will find all servers that have test in the name. For example, it will find servers named test, test1, testsomething.

    NOTE: You cannot search by image_name by providing an alias like ubuntu.

    datacenterId String
    Name of an existing datacenter that the servers are a part of
    filters List<GetServersFilter>

    One or more name/value pairs to filter off of. You can use most base fields in the server resource. These do NOT include nested fields in nics or volume nested fields.

    datacenter_id must be provided. If datacenter_id is missing , the datasource will return an error.

    NOTE: Lookup by filter is partial. Searching for a server using filter name and value test, will find all servers that have test in the name. For example, it will find servers named test, test1, testsomething.

    NOTE: You cannot search by image_name by providing an alias like ubuntu.

    datacenterId string
    Name of an existing datacenter that the servers are a part of
    filters GetServersFilter[]

    One or more name/value pairs to filter off of. You can use most base fields in the server resource. These do NOT include nested fields in nics or volume nested fields.

    datacenter_id must be provided. If datacenter_id is missing , the datasource will return an error.

    NOTE: Lookup by filter is partial. Searching for a server using filter name and value test, will find all servers that have test in the name. For example, it will find servers named test, test1, testsomething.

    NOTE: You cannot search by image_name by providing an alias like ubuntu.

    datacenter_id str
    Name of an existing datacenter that the servers are a part of
    filters Sequence[GetServersFilter]

    One or more name/value pairs to filter off of. You can use most base fields in the server resource. These do NOT include nested fields in nics or volume nested fields.

    datacenter_id must be provided. If datacenter_id is missing , the datasource will return an error.

    NOTE: Lookup by filter is partial. Searching for a server using filter name and value test, will find all servers that have test in the name. For example, it will find servers named test, test1, testsomething.

    NOTE: You cannot search by image_name by providing an alias like ubuntu.

    datacenterId String
    Name of an existing datacenter that the servers are a part of
    filters List<Property Map>

    One or more name/value pairs to filter off of. You can use most base fields in the server resource. These do NOT include nested fields in nics or volume nested fields.

    datacenter_id must be provided. If datacenter_id is missing , the datasource will return an error.

    NOTE: Lookup by filter is partial. Searching for a server using filter name and value test, will find all servers that have test in the name. For example, it will find servers named test, test1, testsomething.

    NOTE: You cannot search by image_name by providing an alias like ubuntu.

    getServers Result

    The following output properties are available:

    DatacenterId string
    Id string
    The provider-assigned unique ID for this managed resource.
    Servers List<Ionoscloud.GetServersServer>
    list of servers that matches the filters provided. For a full reference of all attributes returned, check out documentation
    Filters List<Ionoscloud.GetServersFilter>
    DatacenterId string
    Id string
    The provider-assigned unique ID for this managed resource.
    Servers []GetServersServer
    list of servers that matches the filters provided. For a full reference of all attributes returned, check out documentation
    Filters []GetServersFilter
    datacenterId String
    id String
    The provider-assigned unique ID for this managed resource.
    servers List<GetServersServer>
    list of servers that matches the filters provided. For a full reference of all attributes returned, check out documentation
    filters List<GetServersFilter>
    datacenterId string
    id string
    The provider-assigned unique ID for this managed resource.
    servers GetServersServer[]
    list of servers that matches the filters provided. For a full reference of all attributes returned, check out documentation
    filters GetServersFilter[]
    datacenter_id str
    id str
    The provider-assigned unique ID for this managed resource.
    servers Sequence[GetServersServer]
    list of servers that matches the filters provided. For a full reference of all attributes returned, check out documentation
    filters Sequence[GetServersFilter]
    datacenterId String
    id String
    The provider-assigned unique ID for this managed resource.
    servers List<Property Map>
    list of servers that matches the filters provided. For a full reference of all attributes returned, check out documentation
    filters List<Property Map>

    Supporting Types

    GetServersFilter

    Name string
    Value string
    Name string
    Value string
    name String
    value String
    name string
    value string
    name str
    value str
    name String
    value String

    GetServersServer

    GetServersServerCdrom

    cloudInit String
    cpuHotPlug Boolean
    cpuHotUnplug Boolean
    description String
    discScsiHotPlug Boolean
    discScsiHotUnplug Boolean
    discVirtioHotPlug Boolean
    discVirtioHotUnplug Boolean
    id String
    imageAliases List<String>
    imageType String
    licenceType String
    location String
    name String
    nicHotPlug Boolean
    nicHotUnplug Boolean
    public_ Boolean
    ramHotPlug Boolean
    ramHotUnplug Boolean
    size Double
    cloudInit string
    cpuHotPlug boolean
    cpuHotUnplug boolean
    description string
    discScsiHotPlug boolean
    discScsiHotUnplug boolean
    discVirtioHotPlug boolean
    discVirtioHotUnplug boolean
    id string
    imageAliases string[]
    imageType string
    licenceType string
    location string
    name string
    nicHotPlug boolean
    nicHotUnplug boolean
    public boolean
    ramHotPlug boolean
    ramHotUnplug boolean
    size number
    cloudInit String
    cpuHotPlug Boolean
    cpuHotUnplug Boolean
    description String
    discScsiHotPlug Boolean
    discScsiHotUnplug Boolean
    discVirtioHotPlug Boolean
    discVirtioHotUnplug Boolean
    id String
    imageAliases List<String>
    imageType String
    licenceType String
    location String
    name String
    nicHotPlug Boolean
    nicHotUnplug Boolean
    public Boolean
    ramHotPlug Boolean
    ramHotUnplug Boolean
    size Number

    GetServersServerLabel

    Id string
    Key string
    Value string
    Id string
    Key string
    Value string
    id String
    key String
    value String
    id string
    key string
    value string
    id str
    key str
    value str
    id String
    key String
    value String

    GetServersServerNic

    deviceNumber Integer
    dhcp Boolean
    firewallActive Boolean
    firewallRules List<GetServersServerNicFirewallRule>
    firewallType String
    id String
    ips List<String>
    ipv6CidrBlock String
    ipv6Ips List<String>
    lan Integer
    mac String
    name String
    pciSlot Integer
    securityGroupsIds List<String>
    dhcpv6 Boolean
    deviceNumber number
    dhcp boolean
    firewallActive boolean
    firewallRules GetServersServerNicFirewallRule[]
    firewallType string
    id string
    ips string[]
    ipv6CidrBlock string
    ipv6Ips string[]
    lan number
    mac string
    name string
    pciSlot number
    securityGroupsIds string[]
    dhcpv6 boolean
    deviceNumber Number
    dhcp Boolean
    firewallActive Boolean
    firewallRules List<Property Map>
    firewallType String
    id String
    ips List<String>
    ipv6CidrBlock String
    ipv6Ips List<String>
    lan Number
    mac String
    name String
    pciSlot Number
    securityGroupsIds List<String>
    dhcpv6 Boolean

    GetServersServerNicFirewallRule

    IcmpCode int
    IcmpType int
    Id string
    Name string
    PortRangeEnd int
    PortRangeStart int
    Protocol string
    SourceIp string
    SourceMac string
    TargetIp string
    Type string
    IcmpCode int
    IcmpType int
    Id string
    Name string
    PortRangeEnd int
    PortRangeStart int
    Protocol string
    SourceIp string
    SourceMac string
    TargetIp string
    Type string
    icmpCode Integer
    icmpType Integer
    id String
    name String
    portRangeEnd Integer
    portRangeStart Integer
    protocol String
    sourceIp String
    sourceMac String
    targetIp String
    type String
    icmpCode number
    icmpType number
    id string
    name string
    portRangeEnd number
    portRangeStart number
    protocol string
    sourceIp string
    sourceMac string
    targetIp string
    type string
    icmpCode Number
    icmpType Number
    id String
    name String
    portRangeEnd Number
    portRangeStart Number
    protocol String
    sourceIp String
    sourceMac String
    targetIp String
    type String

    GetServersServerVolume

    AvailabilityZone string
    BackupUnitId string
    BootServer string
    The UUID of the attached server.
    Bus string
    CpuHotPlug bool
    DeviceNumber int
    DiscVirtioHotPlug bool
    DiscVirtioHotUnplug bool
    DiskType string
    Id string
    ImageName string
    ImagePassword string
    LicenceType string
    Name string
    NicHotPlug bool
    NicHotUnplug bool
    PciSlot int
    RamHotPlug bool
    Size int
    SshKeys List<string>
    UserData string
    AvailabilityZone string
    BackupUnitId string
    BootServer string
    The UUID of the attached server.
    Bus string
    CpuHotPlug bool
    DeviceNumber int
    DiscVirtioHotPlug bool
    DiscVirtioHotUnplug bool
    DiskType string
    Id string
    ImageName string
    ImagePassword string
    LicenceType string
    Name string
    NicHotPlug bool
    NicHotUnplug bool
    PciSlot int
    RamHotPlug bool
    Size int
    SshKeys []string
    UserData string
    availabilityZone String
    backupUnitId String
    bootServer String
    The UUID of the attached server.
    bus String
    cpuHotPlug Boolean
    deviceNumber Integer
    discVirtioHotPlug Boolean
    discVirtioHotUnplug Boolean
    diskType String
    id String
    imageName String
    imagePassword String
    licenceType String
    name String
    nicHotPlug Boolean
    nicHotUnplug Boolean
    pciSlot Integer
    ramHotPlug Boolean
    size Integer
    sshKeys List<String>
    userData String
    availabilityZone string
    backupUnitId string
    bootServer string
    The UUID of the attached server.
    bus string
    cpuHotPlug boolean
    deviceNumber number
    discVirtioHotPlug boolean
    discVirtioHotUnplug boolean
    diskType string
    id string
    imageName string
    imagePassword string
    licenceType string
    name string
    nicHotPlug boolean
    nicHotUnplug boolean
    pciSlot number
    ramHotPlug boolean
    size number
    sshKeys string[]
    userData string
    availabilityZone String
    backupUnitId String
    bootServer String
    The UUID of the attached server.
    bus String
    cpuHotPlug Boolean
    deviceNumber Number
    discVirtioHotPlug Boolean
    discVirtioHotUnplug Boolean
    diskType String
    id String
    imageName String
    imagePassword String
    licenceType String
    name String
    nicHotPlug Boolean
    nicHotUnplug Boolean
    pciSlot Number
    ramHotPlug Boolean
    size Number
    sshKeys List<String>
    userData String

    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