@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
102 lines • 3.79 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInstancesOutput = exports.getInstances = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* 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])}));
* }
* });
* ```
*/
function getInstances(args, opts) {
args = args || {};
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {});
return pulumi.runtime.invoke("aws:ec2/getInstances:getInstances", {
"filters": args.filters,
"instanceStateNames": args.instanceStateNames,
"instanceTags": args.instanceTags,
"region": args.region,
}, opts);
}
exports.getInstances = 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.
*
* ## 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])}));
* }
* });
* ```
*/
function getInstancesOutput(args, opts) {
args = args || {};
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {});
return pulumi.runtime.invokeOutput("aws:ec2/getInstances:getInstances", {
"filters": args.filters,
"instanceStateNames": args.instanceStateNames,
"instanceTags": args.instanceTags,
"region": args.region,
}, opts);
}
exports.getInstancesOutput = getInstancesOutput;
//# sourceMappingURL=getInstances.js.map