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

ionoscloud.getServers

Explore with Pulumi AI

ionoscloud logo
ionoscloud 6.7.6 published on Monday, Apr 14, 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.getServers({
        datacenterId: ionoscloud_datacenter.example.id,
        filters: [{
            name: "name",
            value: "server_name_to_look_here",
        }],
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.get_servers(datacenter_id=ionoscloud_datacenter["example"]["id"],
        filters=[{
            "name": "name",
            "value": "server_name_to_look_here",
        }])
    
    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.GetServers(ctx, &ionoscloud.GetServersArgs{
    			DatacenterId: ionoscloud_datacenter.Example.Id,
    			Filters: []ionoscloud.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.GetServers.Invoke(new()
        {
            DatacenterId = ionoscloud_datacenter.Example.Id,
            Filters = new[]
            {
                new Ionoscloud.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.IonoscloudFunctions;
    import com.pulumi.ionoscloud.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 = IonoscloudFunctions.getServers(GetServersArgs.builder()
                .datacenterId(ionoscloud_datacenter.example().id())
                .filters(GetServersFilterArgs.builder()
                    .name("name")
                    .value("server_name_to_look_here")
                    .build())
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ionoscloud:getServers
          arguments:
            datacenterId: ${ionoscloud_datacenter.example.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.getServers({
        datacenterId: ionoscloud_datacenter.example.id,
        filters: [{
            name: "cpu_family",
            value: "INTEL_XEON",
        }],
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.get_servers(datacenter_id=ionoscloud_datacenter["example"]["id"],
        filters=[{
            "name": "cpu_family",
            "value": "INTEL_XEON",
        }])
    
    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.GetServers(ctx, &ionoscloud.GetServersArgs{
    			DatacenterId: ionoscloud_datacenter.Example.Id,
    			Filters: []ionoscloud.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.GetServers.Invoke(new()
        {
            DatacenterId = ionoscloud_datacenter.Example.Id,
            Filters = new[]
            {
                new Ionoscloud.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.IonoscloudFunctions;
    import com.pulumi.ionoscloud.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 = IonoscloudFunctions.getServers(GetServersArgs.builder()
                .datacenterId(ionoscloud_datacenter.example().id())
                .filters(GetServersFilterArgs.builder()
                    .name("cpu_family")
                    .value("INTEL_XEON")
                    .build())
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ionoscloud:getServers
          arguments:
            datacenterId: ${ionoscloud_datacenter.example.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.getServers({
        datacenterId: ionoscloud_datacenter.example.id,
        filters: [
            {
                name: "name",
                value: "test",
            },
            {
                name: "cores",
                value: "1",
            },
        ],
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.get_servers(datacenter_id=ionoscloud_datacenter["example"]["id"],
        filters=[
            {
                "name": "name",
                "value": "test",
            },
            {
                "name": "cores",
                "value": "1",
            },
        ])
    
    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.GetServers(ctx, &ionoscloud.GetServersArgs{
    			DatacenterId: ionoscloud_datacenter.Example.Id,
    			Filters: []ionoscloud.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.GetServers.Invoke(new()
        {
            DatacenterId = ionoscloud_datacenter.Example.Id,
            Filters = new[]
            {
                new Ionoscloud.Inputs.GetServersFilterInputArgs
                {
                    Name = "name",
                    Value = "test",
                },
                new Ionoscloud.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.IonoscloudFunctions;
    import com.pulumi.ionoscloud.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 = IonoscloudFunctions.getServers(GetServersArgs.builder()
                .datacenterId(ionoscloud_datacenter.example().id())
                .filters(            
                    GetServersFilterArgs.builder()
                        .name("name")
                        .value("test")
                        .build(),
                    GetServersFilterArgs.builder()
                        .name("cores")
                        .value("1")
                        .build())
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ionoscloud:getServers
          arguments:
            datacenterId: ${ionoscloud_datacenter.example.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,
                    id: Optional[str] = None,
                    timeouts: Optional[GetServersTimeouts] = 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,
                    id: Optional[pulumi.Input[str]] = None,
                    timeouts: Optional[pulumi.Input[GetServersTimeoutsArgs]] = 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:index/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<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.

    Id string
    Timeouts GetServersTimeouts
    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.

    Id string
    Timeouts GetServersTimeouts
    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.

    id String
    timeouts GetServersTimeouts
    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.

    id string
    timeouts GetServersTimeouts
    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.

    id str
    timeouts GetServersTimeouts
    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.

    id String
    timeouts Property Map

    getServers Result

    The following output properties are available:

    DatacenterId string
    Id string
    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>
    Timeouts GetServersTimeouts
    DatacenterId string
    Id string
    Servers []GetServersServer
    list of servers that matches the filters provided. For a full reference of all attributes returned, check out documentation
    Filters []GetServersFilter
    Timeouts GetServersTimeouts
    datacenterId String
    id String
    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>
    timeouts GetServersTimeouts
    datacenterId string
    id string
    servers GetServersServer[]
    list of servers that matches the filters provided. For a full reference of all attributes returned, check out documentation
    filters GetServersFilter[]
    timeouts GetServersTimeouts
    datacenter_id str
    id str
    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]
    timeouts GetServersTimeouts
    datacenterId String
    id String
    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>
    timeouts 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 double
    Dhcp bool
    Dhcpv6 bool
    FirewallActive bool
    FirewallRules List<GetServersServerNicFirewallRule>
    FirewallType string
    Id string
    Ips List<string>
    Ipv6CidrBlock string
    Ipv6Ips List<string>
    Lan double
    Mac string
    Name string
    PciSlot double
    SecurityGroupsIds List<string>
    DeviceNumber float64
    Dhcp bool
    Dhcpv6 bool
    FirewallActive bool
    FirewallRules []GetServersServerNicFirewallRule
    FirewallType string
    Id string
    Ips []string
    Ipv6CidrBlock string
    Ipv6Ips []string
    Lan float64
    Mac string
    Name string
    PciSlot float64
    SecurityGroupsIds []string
    deviceNumber Double
    dhcp Boolean
    dhcpv6 Boolean
    firewallActive Boolean
    firewallRules List<GetServersServerNicFirewallRule>
    firewallType String
    id String
    ips List<String>
    ipv6CidrBlock String
    ipv6Ips List<String>
    lan Double
    mac String
    name String
    pciSlot Double
    securityGroupsIds List<String>
    deviceNumber number
    dhcp boolean
    dhcpv6 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[]
    deviceNumber Number
    dhcp Boolean
    dhcpv6 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>

    GetServersServerNicFirewallRule

    IcmpCode double
    IcmpType double
    Id string
    Name string
    PortRangeEnd double
    PortRangeStart double
    Protocol string
    SourceIp string
    SourceMac string
    TargetIp string
    Type string
    IcmpCode float64
    IcmpType float64
    Id string
    Name string
    PortRangeEnd float64
    PortRangeStart float64
    Protocol string
    SourceIp string
    SourceMac string
    TargetIp string
    Type string
    icmpCode Double
    icmpType Double
    id String
    name String
    portRangeEnd Double
    portRangeStart Double
    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
    Bus string
    CpuHotPlug bool
    DeviceNumber double
    DiscVirtioHotPlug bool
    DiscVirtioHotUnplug bool
    DiskType string
    Id string
    ImageName string
    ImagePassword string
    LicenceType string
    Name string
    NicHotPlug bool
    NicHotUnplug bool
    PciSlot double
    RamHotPlug bool
    Size double
    SshKeys List<string>
    UserData string
    AvailabilityZone string
    BackupUnitId string
    BootServer string
    Bus string
    CpuHotPlug bool
    DeviceNumber float64
    DiscVirtioHotPlug bool
    DiscVirtioHotUnplug bool
    DiskType string
    Id string
    ImageName string
    ImagePassword string
    LicenceType string
    Name string
    NicHotPlug bool
    NicHotUnplug bool
    PciSlot float64
    RamHotPlug bool
    Size float64
    SshKeys []string
    UserData string
    availabilityZone String
    backupUnitId String
    bootServer String
    bus String
    cpuHotPlug Boolean
    deviceNumber Double
    discVirtioHotPlug Boolean
    discVirtioHotUnplug Boolean
    diskType String
    id String
    imageName String
    imagePassword String
    licenceType String
    name String
    nicHotPlug Boolean
    nicHotUnplug Boolean
    pciSlot Double
    ramHotPlug Boolean
    size Double
    sshKeys List<String>
    userData String
    availabilityZone string
    backupUnitId string
    bootServer string
    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
    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

    GetServersTimeouts

    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