getInstance

Use this data source to get the ID of an Amazon EC2 Instance for use in other resources.

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Ec2Functions;
import com.pulumi.aws.ec2.inputs.GetInstanceArgs;
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 foo = Ec2Functions.getInstance(GetInstanceArgs.builder()
.filters(
GetInstanceFilterArgs.builder()
.name("image-id")
.values("ami-xxxxxxxx")
.build(),
GetInstanceFilterArgs.builder()
.name("tag:Name")
.values("instance-name-tag")
.build())
.instanceId("i-instanceid")
.build());
}
}

Return

A collection of values returned by getInstance.

Parameters

argument

A collection of arguments for invoking getInstance.


suspend fun getInstance(filters: List<GetInstanceFilter>? = null, getPasswordData: Boolean? = null, getUserData: Boolean? = null, instanceId: String? = null, instanceTags: Map<String, String>? = null, tags: Map<String, String>? = null): GetInstanceResult

Return

A collection of values returned by getInstance.

Parameters

filters

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out 1.

getPasswordData

If true, wait for password data to become available and retrieve it. Useful for getting the administrator password for instances running Microsoft Windows. The password data is exported to the password_data attribute. See GetPasswordData for more information.

getUserData

Retrieve Base64 encoded User Data contents into the user_data_base64 attribute. A SHA-1 hash of the User Data contents will always be present in the user_data attribute. Defaults to false.

NOTE: At least one of filter, instance_tags, or instance_id must be specified. NOTE: If anything other than a single match is returned by the search, this call will fail. Ensure that your search is specific enough to return a single Instance ID only.

instanceId

Specify the exact Instance ID with which to populate the data source.

instanceTags

Map of tags, each pair of which must exactly match a pair on the desired Instance.

tags

Map of tags assigned to the Instance.

See also


suspend fun getInstance(argument: suspend GetInstancePlainArgsBuilder.() -> Unit): GetInstanceResult

Return

A collection of values returned by getInstance.

Parameters

argument

Builder for com.pulumi.aws.ec2.kotlin.inputs.GetInstancePlainArgs.

See also