Civo

v2.3.0 published on Tuesday, Oct 4, 2022 by Pulumi

getInstances

Get information on instances for use in other resources, with the ability to filter and sort the results. If no filters are specified, all instances will be returned.

Note: You can use the civo.Instance data source to obtain metadata about a single instance if you already know the id, unique hostname, or unique tag to retrieve.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Civo = Pulumi.Civo;

return await Deployment.RunAsync(() => 
{
    var small_size = Civo.GetInstances.Invoke(new()
    {
        Region = "NYC1",
        Filters = new[]
        {
            new Civo.Inputs.GetInstancesFilterInputArgs
            {
                Key = "size",
                Values = new[]
                {
                    g3.Small,
                },
            },
        },
    });

});

Coming soon!

package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.civo.CivoFunctions;
import com.pulumi.civo.inputs.GetInstancesArgs;
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 small-size = CivoFunctions.getInstances(GetInstancesArgs.builder()
            .region("NYC1")
            .filters(GetInstancesFilterArgs.builder()
                .key("size")
                .values(g3.small())
                .build())
            .build());

    }
}
import pulumi
import pulumi_civo as civo

small_size = civo.get_instances(region="NYC1",
    filters=[civo.GetInstancesFilterArgs(
        key="size",
        values=[g3["small"]],
    )])
import * as pulumi from "@pulumi/pulumi";
import * as civo from "@pulumi/civo";

const small-size = civo.getInstances({
    region: "NYC1",
    filters: [{
        key: "size",
        values: [g3.small],
    }],
});
variables:
  small-size:
    Fn::Invoke:
      Function: civo:getInstances
      Arguments:
        region: NYC1
        filters:
          - key: size
            values:
              - ${g3.small}

Using getInstances

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 getInstances(args: GetInstancesArgs, opts?: InvokeOptions): Promise<GetInstancesResult>
function getInstancesOutput(args: GetInstancesOutputArgs, opts?: InvokeOptions): Output<GetInstancesResult>
def get_instances(filters: Optional[Sequence[GetInstancesFilter]] = None,
                  region: Optional[str] = None,
                  sorts: Optional[Sequence[GetInstancesSort]] = None,
                  opts: Optional[InvokeOptions] = None) -> GetInstancesResult
def get_instances_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetInstancesFilterArgs]]]] = None,
                  region: Optional[pulumi.Input[str]] = None,
                  sorts: Optional[pulumi.Input[Sequence[pulumi.Input[GetInstancesSortArgs]]]] = None,
                  opts: Optional[InvokeOptions] = None) -> Output[GetInstancesResult]
func GetInstances(ctx *Context, args *GetInstancesArgs, opts ...InvokeOption) (*GetInstancesResult, error)
func GetInstancesOutput(ctx *Context, args *GetInstancesOutputArgs, opts ...InvokeOption) GetInstancesResultOutput

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

public static class GetInstances 
{
    public static Task<GetInstancesResult> InvokeAsync(GetInstancesArgs args, InvokeOptions? opts = null)
    public static Output<GetInstancesResult> Invoke(GetInstancesInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetInstancesResult> getInstances(GetInstancesArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: civo:index/getInstances:getInstances
  arguments:
    # arguments dictionary

The following arguments are supported:

Filters List<GetInstancesFilter>

One or more key/value pairs on which to filter results

Region string

If used, all instances will be from the provided region

Sorts List<GetInstancesSort>

One or more key/direction pairs on which to sort results

Filters []GetInstancesFilter

One or more key/value pairs on which to filter results

Region string

If used, all instances will be from the provided region

Sorts []GetInstancesSort

One or more key/direction pairs on which to sort results

filters List<GetInstancesFilter>

One or more key/value pairs on which to filter results

region String

If used, all instances will be from the provided region

sorts List<GetInstancesSort>

One or more key/direction pairs on which to sort results

filters GetInstancesFilter[]

One or more key/value pairs on which to filter results

region string

If used, all instances will be from the provided region

sorts GetInstancesSort[]

One or more key/direction pairs on which to sort results

filters Sequence[GetInstancesFilter]

One or more key/value pairs on which to filter results

region str

If used, all instances will be from the provided region

sorts Sequence[GetInstancesSort]

One or more key/direction pairs on which to sort results

filters List<Property Map>

One or more key/value pairs on which to filter results

region String

If used, all instances will be from the provided region

sorts List<Property Map>

One or more key/direction pairs on which to sort results

getInstances Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

Instances List<GetInstancesInstance>
Filters List<GetInstancesFilter>

One or more key/value pairs on which to filter results

Region string

If used, all instances will be from the provided region

Sorts List<GetInstancesSort>

One or more key/direction pairs on which to sort results

Id string

The provider-assigned unique ID for this managed resource.

Instances []GetInstancesInstance
Filters []GetInstancesFilter

One or more key/value pairs on which to filter results

Region string

If used, all instances will be from the provided region

Sorts []GetInstancesSort

One or more key/direction pairs on which to sort results

id String

The provider-assigned unique ID for this managed resource.

instances List<GetInstancesInstance>
filters List<GetInstancesFilter>

One or more key/value pairs on which to filter results

region String

If used, all instances will be from the provided region

sorts List<GetInstancesSort>

One or more key/direction pairs on which to sort results

id string

The provider-assigned unique ID for this managed resource.

instances GetInstancesInstance[]
filters GetInstancesFilter[]

One or more key/value pairs on which to filter results

region string

If used, all instances will be from the provided region

sorts GetInstancesSort[]

One or more key/direction pairs on which to sort results

id str

The provider-assigned unique ID for this managed resource.

instances Sequence[GetInstancesInstance]
filters Sequence[GetInstancesFilter]

One or more key/value pairs on which to filter results

region str

If used, all instances will be from the provided region

sorts Sequence[GetInstancesSort]

One or more key/direction pairs on which to sort results

id String

The provider-assigned unique ID for this managed resource.

instances List<Property Map>
filters List<Property Map>

One or more key/value pairs on which to filter results

region String

If used, all instances will be from the provided region

sorts List<Property Map>

One or more key/direction pairs on which to sort results

Supporting Types

GetInstancesFilter

Key string

Filter instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, tags, template.

Values List<string>

Only retrieves instances which keys has value that matches one of the values provided here

All bool

Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

MatchBy string

One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

Key string

Filter instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, tags, template.

Values []string

Only retrieves instances which keys has value that matches one of the values provided here

All bool

Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

MatchBy string

One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

key String

Filter instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, tags, template.

values List<String>

Only retrieves instances which keys has value that matches one of the values provided here

all Boolean

Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

matchBy String

One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

key string

Filter instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, tags, template.

values string[]

Only retrieves instances which keys has value that matches one of the values provided here

all boolean

Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

matchBy string

One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

key str

Filter instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, tags, template.

values Sequence[str]

Only retrieves instances which keys has value that matches one of the values provided here

all bool

Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

match_by str

One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

key String

Filter instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, tags, template.

values List<String>

Only retrieves instances which keys has value that matches one of the values provided here

all Boolean

Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

matchBy String

One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

GetInstancesInstance

CpuCores int
CreatedAt string
DiskGb int
FirewallId string
Hostname string
Id string

The ID of this resource.

InitialPassword string
InitialUser string
NetworkId string
Notes string
PrivateIp string
PseudoIp string
PublicIp string
RamMb int
Region string

If used, all instances will be from the provided region

ReverseDns string
Script string
Size string
SshkeyId string
Status string
Tags List<string>
Template string
CpuCores int
CreatedAt string
DiskGb int
FirewallId string
Hostname string
Id string

The ID of this resource.

InitialPassword string
InitialUser string
NetworkId string
Notes string
PrivateIp string
PseudoIp string
PublicIp string
RamMb int
Region string

If used, all instances will be from the provided region

ReverseDns string
Script string
Size string
SshkeyId string
Status string
Tags []string
Template string
cpuCores Integer
createdAt String
diskGb Integer
firewallId String
hostname String
id String

The ID of this resource.

initialPassword String
initialUser String
networkId String
notes String
privateIp String
pseudoIp String
publicIp String
ramMb Integer
region String

If used, all instances will be from the provided region

reverseDns String
script String
size String
sshkeyId String
status String
tags List<String>
template String
cpuCores number
createdAt string
diskGb number
firewallId string
hostname string
id string

The ID of this resource.

initialPassword string
initialUser string
networkId string
notes string
privateIp string
pseudoIp string
publicIp string
ramMb number
region string

If used, all instances will be from the provided region

reverseDns string
script string
size string
sshkeyId string
status string
tags string[]
template string
cpu_cores int
created_at str
disk_gb int
firewall_id str
hostname str
id str

The ID of this resource.

initial_password str
initial_user str
network_id str
notes str
private_ip str
pseudo_ip str
public_ip str
ram_mb int
region str

If used, all instances will be from the provided region

reverse_dns str
script str
size str
sshkey_id str
status str
tags Sequence[str]
template str
cpuCores Number
createdAt String
diskGb Number
firewallId String
hostname String
id String

The ID of this resource.

initialPassword String
initialUser String
networkId String
notes String
privateIp String
pseudoIp String
publicIp String
ramMb Number
region String

If used, all instances will be from the provided region

reverseDns String
script String
size String
sshkeyId String
status String
tags List<String>
template String

GetInstancesSort

Key string

Sort instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, template.

Direction string

The sort direction. This may be either asc or desc.

Key string

Sort instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, template.

Direction string

The sort direction. This may be either asc or desc.

key String

Sort instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, template.

direction String

The sort direction. This may be either asc or desc.

key string

Sort instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, template.

direction string

The sort direction. This may be either asc or desc.

key str

Sort instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, template.

direction str

The sort direction. This may be either asc or desc.

key String

Sort instances by this key. This may be one of cpu_cores, created_at, disk_gb, firewall_id, hostname, id, initial_password, initial_user, network_id, notes, private_ip, pseudo_ip, public_ip, ram_mb, region, reverse_dns, script, size, sshkey_id, status, template.

direction String

The sort direction. This may be either asc or desc.

Package Details

Repository
https://github.com/pulumi/pulumi-civo
License
Apache-2.0
Notes

This Pulumi package is based on the civo Terraform Provider.