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
import * as pulumi from "@pulumi/pulumi";
import * as civo from "@pulumi/civo";
const small_size = civo.getInstances({
region: "LON1",
filters: [{
key: "size",
values: [g3.small],
}],
});
import pulumi
import pulumi_civo as civo
small_size = civo.get_instances(region="LON1",
filters=[{
"key": "size",
"values": [g3["small"]],
}])
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/civo/civo"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := civo.GetInstances(ctx, &civo.GetInstancesArgs{
Region: pulumi.StringRef("LON1"),
Filters: []civo.GetInstancesFilter{
{
Key: "size",
Values: interface{}{
g3.Small,
},
},
},
}, nil);
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Civo = Pulumi.Civo;
return await Deployment.RunAsync(() =>
{
var small_size = Civo.GetInstances.Invoke(new()
{
Region = "LON1",
Filters = new[]
{
new Civo.Inputs.GetInstancesFilterInputArgs
{
Key = "size",
Values = new[]
{
g3.Small,
},
},
},
});
});
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("LON1")
.filters(GetInstancesFilterArgs.builder()
.key("size")
.values(g3.small())
.build())
.build());
}
}
variables:
small-size:
fn::invoke:
function: civo:getInstances
arguments:
region: LON1
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,
id: Optional[str] = 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,
id: Optional[pulumi.Input[str]] = 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)
public static Output<GetInstancesResult> getInstances(GetInstancesArgs args, InvokeOptions options)
fn::invoke:
function: civo:index/getInstances:getInstances
arguments:
# arguments dictionaryThe following arguments are supported:
- Filters
List<Get
Instances Filter> - One or more key/value pairs on which to filter results
- Id string
- The ID of this resource.
- Region string
- If used, all instances will be from the provided region
- Sorts
List<Get
Instances Sort> - One or more key/direction pairs on which to sort results
- Filters
[]Get
Instances Filter - One or more key/value pairs on which to filter results
- Id string
- The ID of this resource.
- Region string
- If used, all instances will be from the provided region
- Sorts
[]Get
Instances Sort - One or more key/direction pairs on which to sort results
- filters
List<Get
Instances Filter> - One or more key/value pairs on which to filter results
- id String
- The ID of this resource.
- region String
- If used, all instances will be from the provided region
- sorts
List<Get
Instances Sort> - One or more key/direction pairs on which to sort results
- filters
Get
Instances Filter[] - One or more key/value pairs on which to filter results
- id string
- The ID of this resource.
- region string
- If used, all instances will be from the provided region
- sorts
Get
Instances Sort[] - One or more key/direction pairs on which to sort results
- filters
Sequence[Get
Instances Filter] - One or more key/value pairs on which to filter results
- id str
- The ID of this resource.
- region str
- If used, all instances will be from the provided region
- sorts
Sequence[Get
Instances Sort] - 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
- id String
- The ID of this resource.
- 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 ID of this resource.
- Instances
List<Get
Instances Instance> - Filters
List<Get
Instances Filter> - 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<Get
Instances Sort> - One or more key/direction pairs on which to sort results
- Id string
- The ID of this resource.
- Instances
[]Get
Instances Instance - Filters
[]Get
Instances Filter - One or more key/value pairs on which to filter results
- Region string
- If used, all instances will be from the provided region
- Sorts
[]Get
Instances Sort - One or more key/direction pairs on which to sort results
- id String
- The ID of this resource.
- instances
List<Get
Instances Instance> - filters
List<Get
Instances Filter> - 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<Get
Instances Sort> - One or more key/direction pairs on which to sort results
- id string
- The ID of this resource.
- instances
Get
Instances Instance[] - filters
Get
Instances Filter[] - One or more key/value pairs on which to filter results
- region string
- If used, all instances will be from the provided region
- sorts
Get
Instances Sort[] - One or more key/direction pairs on which to sort results
- id str
- The ID of this resource.
- instances
Sequence[Get
Instances Instance] - filters
Sequence[Get
Instances Filter] - 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[Get
Instances Sort] - One or more key/direction pairs on which to sort results
- id String
- The ID of this 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
instanceswhich keys has value that matches one of the values provided here - All bool
- Set to
trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set. - Match
By string - One of
exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas 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
instanceswhich keys has value that matches one of the values provided here - All bool
- Set to
trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set. - Match
By string - One of
exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas 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
instanceswhich keys has value that matches one of the values provided here - all Boolean
- Set to
trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set. - match
By String - One of
exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas 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
instanceswhich keys has value that matches one of the values provided here - all boolean
- Set to
trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set. - match
By string - One of
exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas 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
instanceswhich keys has value that matches one of the values provided here - all bool
- Set to
trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set. - match_
by str - One of
exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas 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
instanceswhich keys has value that matches one of the values provided here - all Boolean
- Set to
trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set. - match
By String - One of
exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas substrings to find within the string field.
GetInstancesInstance
- Cpu
Cores double - Created
At string - Disk
Gb double - Firewall
Id string - Hostname string
- Id string
- Initial
Password string - Initial
User string - Network
Id string - Notes string
- Private
Ip string - Pseudo
Ip string - Public
Ip string - Ram
Mb double - Region string
- Reverse
Dns string - Script string
- Size string
- Sshkey
Id string - Status string
- List<string>
- Template string
- Cpu
Cores float64 - Created
At string - Disk
Gb float64 - Firewall
Id string - Hostname string
- Id string
- Initial
Password string - Initial
User string - Network
Id string - Notes string
- Private
Ip string - Pseudo
Ip string - Public
Ip string - Ram
Mb float64 - Region string
- Reverse
Dns string - Script string
- Size string
- Sshkey
Id string - Status string
- []string
- Template string
- cpu
Cores Double - created
At String - disk
Gb Double - firewall
Id String - hostname String
- id String
- initial
Password String - initial
User String - network
Id String - notes String
- private
Ip String - pseudo
Ip String - public
Ip String - ram
Mb Double - region String
- reverse
Dns String - script String
- size String
- sshkey
Id String - status String
- List<String>
- template String
- cpu
Cores number - created
At string - disk
Gb number - firewall
Id string - hostname string
- id string
- initial
Password string - initial
User string - network
Id string - notes string
- private
Ip string - pseudo
Ip string - public
Ip string - ram
Mb number - region string
- reverse
Dns string - script string
- size string
- sshkey
Id string - status string
- string[]
- template string
- cpu_
cores float - created_
at str - disk_
gb float - firewall_
id str - hostname str
- id str
- initial_
password str - initial_
user str - network_
id str - notes str
- private_
ip str - pseudo_
ip str - public_
ip str - ram_
mb float - region str
- reverse_
dns str - script str
- size str
- sshkey_
id str - status str
- Sequence[str]
- template str
- cpu
Cores Number - created
At String - disk
Gb Number - firewall
Id String - hostname String
- id String
- initial
Password String - initial
User String - network
Id String - notes String
- private
Ip String - pseudo
Ip String - public
Ip String - ram
Mb Number - region String
- reverse
Dns String - script String
- size String
- sshkey
Id String - status String
- 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
ascordesc.
- 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
ascordesc.
- 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
ascordesc.
- 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
ascordesc.
- 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
ascordesc.
- 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
ascordesc.
Package Details
- Repository
- Civo civo/terraform-provider-civo
- License
- Notes
- This Pulumi package is based on the
civoTerraform Provider.
