AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.10.0 published on Monday, Jul 11, 2022 by Pulumi

getInstances

Use this data source to get IDs or IPs of Amazon EC2 instances to be referenced elsewhere, e.g., to allow easier migration from another management solution or to make it easier for an operator to connect through bastion host(s).

Note: It’s strongly discouraged to use this data source for querying ephemeral instances (e.g., managed via autoscaling group), as the output may change at any time and you’d need to re-run apply every time an instance comes up or dies.

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,
                  instance_state_names: Optional[Sequence[str]] = None,
                  instance_tags: Optional[Mapping[str, str]] = None,
                  opts: Optional[InvokeOptions] = None) -> GetInstancesResult
def get_instances_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetInstancesFilterArgs]]]] = None,
                  instance_state_names: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                  instance_tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = 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: aws:ec2/getInstances:getInstances
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Filters List<Pulumi.Aws.Ec2.Inputs.GetInstancesFilter>

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-instances in the AWS CLI reference][1].

InstanceStateNames List<string>

A list of instance states that should be applicable to the desired instances. The permitted values are: pending, running, shutting-down, stopped, stopping, terminated. The default value is running.

InstanceTags Dictionary<string, string>

A map of tags, each pair of which must exactly match a pair on desired instances.

Filters []GetInstancesFilter

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-instances in the AWS CLI reference][1].

InstanceStateNames []string

A list of instance states that should be applicable to the desired instances. The permitted values are: pending, running, shutting-down, stopped, stopping, terminated. The default value is running.

InstanceTags map[string]string

A map of tags, each pair of which must exactly match a pair on desired instances.

filters List<GetInstancesFilter>

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-instances in the AWS CLI reference][1].

instanceStateNames List<String>

A list of instance states that should be applicable to the desired instances. The permitted values are: pending, running, shutting-down, stopped, stopping, terminated. The default value is running.

instanceTags Map<String,String>

A map of tags, each pair of which must exactly match a pair on desired instances.

filters GetInstancesFilter[]

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-instances in the AWS CLI reference][1].

instanceStateNames string[]

A list of instance states that should be applicable to the desired instances. The permitted values are: pending, running, shutting-down, stopped, stopping, terminated. The default value is running.

instanceTags {[key: string]: string}

A map of tags, each pair of which must exactly match a pair on desired instances.

filters Sequence[GetInstancesFilter]

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-instances in the AWS CLI reference][1].

instance_state_names Sequence[str]

A list of instance states that should be applicable to the desired instances. The permitted values are: pending, running, shutting-down, stopped, stopping, terminated. The default value is running.

instance_tags Mapping[str, str]

A map of tags, each pair of which must exactly match a pair on desired instances.

filters List<Property Map>

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-instances in the AWS CLI reference][1].

instanceStateNames List<String>

A list of instance states that should be applicable to the desired instances. The permitted values are: pending, running, shutting-down, stopped, stopping, terminated. The default value is running.

instanceTags Map<String>

A map of tags, each pair of which must exactly match a pair on desired instances.

getInstances Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

Ids List<string>

IDs of instances found through the filter

InstanceTags Dictionary<string, string>
PrivateIps List<string>

Private IP addresses of instances found through the filter

PublicIps List<string>

Public IP addresses of instances found through the filter

Filters List<Pulumi.Aws.Ec2.Outputs.GetInstancesFilter>
InstanceStateNames List<string>
Id string

The provider-assigned unique ID for this managed resource.

Ids []string

IDs of instances found through the filter

InstanceTags map[string]string
PrivateIps []string

Private IP addresses of instances found through the filter

PublicIps []string

Public IP addresses of instances found through the filter

Filters []GetInstancesFilter
InstanceStateNames []string
id String

The provider-assigned unique ID for this managed resource.

ids List<String>

IDs of instances found through the filter

instanceTags Map<String,String>
privateIps List<String>

Private IP addresses of instances found through the filter

publicIps List<String>

Public IP addresses of instances found through the filter

filters List<GetInstancesFilter>
instanceStateNames List<String>
id string

The provider-assigned unique ID for this managed resource.

ids string[]

IDs of instances found through the filter

instanceTags {[key: string]: string}
privateIps string[]

Private IP addresses of instances found through the filter

publicIps string[]

Public IP addresses of instances found through the filter

filters GetInstancesFilter[]
instanceStateNames string[]
id str

The provider-assigned unique ID for this managed resource.

ids Sequence[str]

IDs of instances found through the filter

instance_tags Mapping[str, str]
private_ips Sequence[str]

Private IP addresses of instances found through the filter

public_ips Sequence[str]

Public IP addresses of instances found through the filter

filters Sequence[GetInstancesFilter]
instance_state_names Sequence[str]
id String

The provider-assigned unique ID for this managed resource.

ids List<String>

IDs of instances found through the filter

instanceTags Map<String>
privateIps List<String>

Private IP addresses of instances found through the filter

publicIps List<String>

Public IP addresses of instances found through the filter

filters List<Property Map>
instanceStateNames List<String>

Supporting Types

GetInstancesFilter

Name string
Values List<string>
Name string
Values []string
name String
values List<String>
name string
values string[]
name str
values Sequence[str]
name String
values List<String>

Package Details

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

This Pulumi package is based on the aws Terraform Provider.