UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

163 lines (162 loc) 5.99 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * 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. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = aws.ec2.getInstances({ * instanceTags: { * Role: "HardWorker", * }, * filters: [{ * name: "instance.group-id", * values: ["sg-12345678"], * }], * instanceStateNames: [ * "running", * "stopped", * ], * }); * const testEip: aws.ec2.Eip[] = []; * test.then(test => test.ids).length.apply(rangeBody => { * for (const range = {value: 0}; range.value < rangeBody; range.value++) { * testEip.push(new aws.ec2.Eip(`test-${range.value}`, {instance: test.then(test => test.ids[range.value])})); * } * }); * ``` */ export declare function getInstances(args?: GetInstancesArgs, opts?: pulumi.InvokeOptions): Promise<GetInstancesResult>; /** * A collection of arguments for invoking getInstances. */ export interface GetInstancesArgs { /** * One or more filters to apply to the search. * If multiple `filter` blocks are provided, they all must be true. * For a full reference of filter names, see [describe-instances in the AWS CLI reference][1]. * See `filter` Block below. */ filters?: inputs.ec2.GetInstancesFilter[]; /** * 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`. */ instanceStateNames?: string[]; /** * Map of tags, each pair of which must * exactly match a pair on desired instances. */ instanceTags?: { [key: string]: string; }; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ region?: string; } /** * A collection of values returned by getInstances. */ export interface GetInstancesResult { readonly filters?: outputs.ec2.GetInstancesFilter[]; /** * The provider-assigned unique ID for this managed resource. */ readonly id: string; /** * IDs of instances found through the filter */ readonly ids: string[]; readonly instanceStateNames?: string[]; readonly instanceTags: { [key: string]: string; }; /** * IPv6 addresses of instances found through the filter */ readonly ipv6Addresses: string[]; /** * Private IP addresses of instances found through the filter */ readonly privateIps: string[]; /** * Public IP addresses of instances found through the filter */ readonly publicIps: string[]; readonly region: string; } /** * 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. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = aws.ec2.getInstances({ * instanceTags: { * Role: "HardWorker", * }, * filters: [{ * name: "instance.group-id", * values: ["sg-12345678"], * }], * instanceStateNames: [ * "running", * "stopped", * ], * }); * const testEip: aws.ec2.Eip[] = []; * test.then(test => test.ids).length.apply(rangeBody => { * for (const range = {value: 0}; range.value < rangeBody; range.value++) { * testEip.push(new aws.ec2.Eip(`test-${range.value}`, {instance: test.then(test => test.ids[range.value])})); * } * }); * ``` */ export declare function getInstancesOutput(args?: GetInstancesOutputArgs, opts?: pulumi.InvokeOutputOptions): pulumi.Output<GetInstancesResult>; /** * A collection of arguments for invoking getInstances. */ export interface GetInstancesOutputArgs { /** * One or more filters to apply to the search. * If multiple `filter` blocks are provided, they all must be true. * For a full reference of filter names, see [describe-instances in the AWS CLI reference][1]. * See `filter` Block below. */ filters?: pulumi.Input<pulumi.Input<inputs.ec2.GetInstancesFilterArgs>[]>; /** * 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`. */ instanceStateNames?: pulumi.Input<pulumi.Input<string>[]>; /** * Map of tags, each pair of which must * exactly match a pair on desired instances. */ instanceTags?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ region?: pulumi.Input<string>; }