getInstance

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

Example Usage

Coming soon!

Coming soon!

Coming soon!

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const foo = pulumi.output(aws.ec2.getInstance({
    filters: [
        {
            name: "image-id",
            values: ["ami-xxxxxxxx"],
        },
        {
            name: "tag:Name",
            values: ["instance-name-tag"],
        },
    ],
    instanceId: "i-instanceid",
}, { async: true }));

Using getInstance

function getInstance(args: GetInstanceArgs, opts?: InvokeOptions): Promise<GetInstanceResult>
def get_instance(filters: Optional[Sequence[GetInstanceFilter]] = None,
                 get_password_data: Optional[bool] = None,
                 get_user_data: Optional[bool] = None,
                 instance_id: Optional[str] = None,
                 instance_tags: Optional[Mapping[str, str]] = None,
                 tags: Optional[Mapping[str, str]] = None,
                 opts: Optional[InvokeOptions] = None) -> GetInstanceResult
func LookupInstance(ctx *Context, args *LookupInstanceArgs, opts ...InvokeOption) (*LookupInstanceResult, error)

Note: This function is named LookupInstance in the Go SDK.

public static class GetInstance {
    public static Task<GetInstanceResult> InvokeAsync(GetInstanceArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Filters List<GetInstanceFilter>
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].
GetPasswordData bool
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 bool
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.
InstanceId string
Specify the exact Instance ID with which to populate the data source.
InstanceTags Dictionary<string, string>
A map of tags, each pair of which must exactly match a pair on the desired Instance.
Tags Dictionary<string, string>
A map of tags assigned to the Instance.
Filters []GetInstanceFilter
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].
GetPasswordData bool
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 bool
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.
InstanceId string
Specify the exact Instance ID with which to populate the data source.
InstanceTags map[string]string
A map of tags, each pair of which must exactly match a pair on the desired Instance.
Tags map[string]string
A map of tags assigned to the Instance.
filters GetInstanceFilter[]
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].
getPasswordData boolean
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 boolean
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.
instanceId string
Specify the exact Instance ID with which to populate the data source.
instanceTags {[key: string]: string}
A map of tags, each pair of which must exactly match a pair on the desired Instance.
tags {[key: string]: string}
A map of tags assigned to the Instance.
filters Sequence[GetInstanceFilter]
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].
get_password_data bool
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.
get_user_data bool
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.
instance_id str
Specify the exact Instance ID with which to populate the data source.
instance_tags Mapping[str, str]
A map of tags, each pair of which must exactly match a pair on the desired Instance.
tags Mapping[str, str]
A map of tags assigned to the Instance.

getInstance Result

The following output properties are available:

Ami string
The ID of the AMI used to launch the instance.
Arn string
The ARN of the instance.
AssociatePublicIpAddress bool
Whether or not the Instance is associated with a public IP address or not (Boolean).
AvailabilityZone string
The availability zone of the Instance.
CreditSpecifications List<GetInstanceCreditSpecification>
The credit specification of the Instance.
DisableApiTermination bool
EbsBlockDevices List<GetInstanceEbsBlockDevice>
The EBS block device mappings of the Instance.
EbsOptimized bool
Whether the Instance is EBS optimized or not (Boolean).
EnclaveOptions List<GetInstanceEnclaveOption>
The enclave options of the Instance.
EphemeralBlockDevices List<GetInstanceEphemeralBlockDevice>
The ephemeral block device mappings of the Instance.
HostId string
The Id of the dedicated host the instance will be assigned to.
IamInstanceProfile string
The name of the instance profile associated with the Instance.
Id string
The provider-assigned unique ID for this managed resource.
InstanceState string
The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.
InstanceTags Dictionary<string, string>
InstanceType string
The type of the Instance.
KeyName string
The key name of the Instance.
MetadataOptions List<GetInstanceMetadataOption>
The metadata options of the Instance.
Monitoring bool
Whether detailed monitoring is enabled or disabled for the Instance (Boolean).
NetworkInterfaceId string
The ID of the network interface that was created with the Instance.
OutpostArn string
The Amazon Resource Name (ARN) of the Outpost.
PasswordData string
Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. See GetPasswordData for more information.
PlacementGroup string
The placement group of the Instance.
PrivateDns string
The private DNS name assigned to the Instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC.
PrivateIp string
The private IP address assigned to the Instance.
PublicDns string
The public DNS name assigned to the Instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC.
PublicIp string
The public IP address assigned to the Instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.
RootBlockDevices List<GetInstanceRootBlockDevice>
The root block device mappings of the Instance
SecondaryPrivateIps List<string>
The secondary private IPv4 addresses assigned to the instance’s primary network interface (eth0) in a VPC.
SecurityGroups List<string>
The associated security groups.
SourceDestCheck bool
Whether the network interface performs source/destination checking (Boolean).
SubnetId string
The VPC subnet ID.
Tags Dictionary<string, string>
A map of tags assigned to the Instance.
Tenancy string
The tenancy of the instance: dedicated, default, host.
UserData string
SHA-1 hash of User Data supplied to the Instance.
UserDataBase64 string
Base64 encoded contents of User Data supplied to the Instance. This attribute is only exported if get_user_data is true.
VpcSecurityGroupIds List<string>
The associated security groups in a non-default VPC.
Filters List<GetInstanceFilter>
GetPasswordData bool
GetUserData bool
InstanceId string
Ami string
The ID of the AMI used to launch the instance.
Arn string
The ARN of the instance.
AssociatePublicIpAddress bool
Whether or not the Instance is associated with a public IP address or not (Boolean).
AvailabilityZone string
The availability zone of the Instance.
CreditSpecifications []GetInstanceCreditSpecification
The credit specification of the Instance.
DisableApiTermination bool
EbsBlockDevices []GetInstanceEbsBlockDevice
The EBS block device mappings of the Instance.
EbsOptimized bool
Whether the Instance is EBS optimized or not (Boolean).
EnclaveOptions []GetInstanceEnclaveOption
The enclave options of the Instance.
EphemeralBlockDevices []GetInstanceEphemeralBlockDevice
The ephemeral block device mappings of the Instance.
HostId string
The Id of the dedicated host the instance will be assigned to.
IamInstanceProfile string
The name of the instance profile associated with the Instance.
Id string
The provider-assigned unique ID for this managed resource.
InstanceState string
The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.
InstanceTags map[string]string
InstanceType string
The type of the Instance.
KeyName string
The key name of the Instance.
MetadataOptions []GetInstanceMetadataOption
The metadata options of the Instance.
Monitoring bool
Whether detailed monitoring is enabled or disabled for the Instance (Boolean).
NetworkInterfaceId string
The ID of the network interface that was created with the Instance.
OutpostArn string
The Amazon Resource Name (ARN) of the Outpost.
PasswordData string
Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. See GetPasswordData for more information.
PlacementGroup string
The placement group of the Instance.
PrivateDns string
The private DNS name assigned to the Instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC.
PrivateIp string
The private IP address assigned to the Instance.
PublicDns string
The public DNS name assigned to the Instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC.
PublicIp string
The public IP address assigned to the Instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.
RootBlockDevices []GetInstanceRootBlockDevice
The root block device mappings of the Instance
SecondaryPrivateIps []string
The secondary private IPv4 addresses assigned to the instance’s primary network interface (eth0) in a VPC.
SecurityGroups []string
The associated security groups.
SourceDestCheck bool
Whether the network interface performs source/destination checking (Boolean).
SubnetId string
The VPC subnet ID.
Tags map[string]string
A map of tags assigned to the Instance.
Tenancy string
The tenancy of the instance: dedicated, default, host.
UserData string
SHA-1 hash of User Data supplied to the Instance.
UserDataBase64 string
Base64 encoded contents of User Data supplied to the Instance. This attribute is only exported if get_user_data is true.
VpcSecurityGroupIds []string
The associated security groups in a non-default VPC.
Filters []GetInstanceFilter
GetPasswordData bool
GetUserData bool
InstanceId string
ami string
The ID of the AMI used to launch the instance.
arn string
The ARN of the instance.
associatePublicIpAddress boolean
Whether or not the Instance is associated with a public IP address or not (Boolean).
availabilityZone string
The availability zone of the Instance.
creditSpecifications GetInstanceCreditSpecification[]
The credit specification of the Instance.
disableApiTermination boolean
ebsBlockDevices GetInstanceEbsBlockDevice[]
The EBS block device mappings of the Instance.
ebsOptimized boolean
Whether the Instance is EBS optimized or not (Boolean).
enclaveOptions GetInstanceEnclaveOption[]
The enclave options of the Instance.
ephemeralBlockDevices GetInstanceEphemeralBlockDevice[]
The ephemeral block device mappings of the Instance.
hostId string
The Id of the dedicated host the instance will be assigned to.
iamInstanceProfile string
The name of the instance profile associated with the Instance.
id string
The provider-assigned unique ID for this managed resource.
instanceState string
The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.
instanceTags {[key: string]: string}
instanceType string
The type of the Instance.
keyName string
The key name of the Instance.
metadataOptions GetInstanceMetadataOption[]
The metadata options of the Instance.
monitoring boolean
Whether detailed monitoring is enabled or disabled for the Instance (Boolean).
networkInterfaceId string
The ID of the network interface that was created with the Instance.
outpostArn string
The Amazon Resource Name (ARN) of the Outpost.
passwordData string
Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. See GetPasswordData for more information.
placementGroup string
The placement group of the Instance.
privateDns string
The private DNS name assigned to the Instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC.
privateIp string
The private IP address assigned to the Instance.
publicDns string
The public DNS name assigned to the Instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC.
publicIp string
The public IP address assigned to the Instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.
rootBlockDevices GetInstanceRootBlockDevice[]
The root block device mappings of the Instance
secondaryPrivateIps string[]
The secondary private IPv4 addresses assigned to the instance’s primary network interface (eth0) in a VPC.
securityGroups string[]
The associated security groups.
sourceDestCheck boolean
Whether the network interface performs source/destination checking (Boolean).
subnetId string
The VPC subnet ID.
tags {[key: string]: string}
A map of tags assigned to the Instance.
tenancy string
The tenancy of the instance: dedicated, default, host.
userData string
SHA-1 hash of User Data supplied to the Instance.
userDataBase64 string
Base64 encoded contents of User Data supplied to the Instance. This attribute is only exported if get_user_data is true.
vpcSecurityGroupIds string[]
The associated security groups in a non-default VPC.
filters GetInstanceFilter[]
getPasswordData boolean
getUserData boolean
instanceId string
ami str
The ID of the AMI used to launch the instance.
arn str
The ARN of the instance.
associate_public_ip_address bool
Whether or not the Instance is associated with a public IP address or not (Boolean).
availability_zone str
The availability zone of the Instance.
credit_specifications Sequence[GetInstanceCreditSpecification]
The credit specification of the Instance.
disable_api_termination bool
ebs_block_devices Sequence[GetInstanceEbsBlockDevice]
The EBS block device mappings of the Instance.
ebs_optimized bool
Whether the Instance is EBS optimized or not (Boolean).
enclave_options Sequence[GetInstanceEnclaveOption]
The enclave options of the Instance.
ephemeral_block_devices Sequence[GetInstanceEphemeralBlockDevice]
The ephemeral block device mappings of the Instance.
host_id str
The Id of the dedicated host the instance will be assigned to.
iam_instance_profile str
The name of the instance profile associated with the Instance.
id str
The provider-assigned unique ID for this managed resource.
instance_state str
The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.
instance_tags Mapping[str, str]
instance_type str
The type of the Instance.
key_name str
The key name of the Instance.
metadata_options Sequence[GetInstanceMetadataOption]
The metadata options of the Instance.
monitoring bool
Whether detailed monitoring is enabled or disabled for the Instance (Boolean).
network_interface_id str
The ID of the network interface that was created with the Instance.
outpost_arn str
The Amazon Resource Name (ARN) of the Outpost.
password_data str
Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. See GetPasswordData for more information.
placement_group str
The placement group of the Instance.
private_dns str
The private DNS name assigned to the Instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC.
private_ip str
The private IP address assigned to the Instance.
public_dns str
The public DNS name assigned to the Instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC.
public_ip str
The public IP address assigned to the Instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.
root_block_devices Sequence[GetInstanceRootBlockDevice]
The root block device mappings of the Instance
secondary_private_ips Sequence[str]
The secondary private IPv4 addresses assigned to the instance’s primary network interface (eth0) in a VPC.
security_groups Sequence[str]
The associated security groups.
source_dest_check bool
Whether the network interface performs source/destination checking (Boolean).
subnet_id str
The VPC subnet ID.
tags Mapping[str, str]
A map of tags assigned to the Instance.
tenancy str
The tenancy of the instance: dedicated, default, host.
user_data str
SHA-1 hash of User Data supplied to the Instance.
user_data_base64 str
Base64 encoded contents of User Data supplied to the Instance. This attribute is only exported if get_user_data is true.
vpc_security_group_ids Sequence[str]
The associated security groups in a non-default VPC.
filters Sequence[GetInstanceFilter]
get_password_data bool
get_user_data bool
instance_id str

Supporting Types

GetInstanceCreditSpecification

CpuCredits string
CpuCredits string
cpuCredits string

GetInstanceEbsBlockDevice

DeleteOnTermination bool
If the root block device will be deleted on termination.
DeviceName string
The physical name of the device.
Encrypted bool
If the EBS volume is encrypted.
Iops int
0 If the volume is not a provisioned IOPS image, otherwise the supported IOPS count.
KmsKeyId string
SnapshotId string
The ID of the snapshot.
Tags Dictionary<string, string>
A map of tags assigned to the Instance.
Throughput int
The throughput of the volume, in MiB/s.
VolumeId string
VolumeSize int
The size of the volume, in GiB.
VolumeType string
The type of the volume.
DeleteOnTermination bool
If the root block device will be deleted on termination.
DeviceName string
The physical name of the device.
Encrypted bool
If the EBS volume is encrypted.
Iops int
0 If the volume is not a provisioned IOPS image, otherwise the supported IOPS count.
KmsKeyId string
SnapshotId string
The ID of the snapshot.
Tags map[string]string
A map of tags assigned to the Instance.
Throughput int
The throughput of the volume, in MiB/s.
VolumeId string
VolumeSize int
The size of the volume, in GiB.
VolumeType string
The type of the volume.
deleteOnTermination boolean
If the root block device will be deleted on termination.
deviceName string
The physical name of the device.
encrypted boolean
If the EBS volume is encrypted.
iops number
0 If the volume is not a provisioned IOPS image, otherwise the supported IOPS count.
kmsKeyId string
snapshotId string
The ID of the snapshot.
tags {[key: string]: string}
A map of tags assigned to the Instance.
throughput number
The throughput of the volume, in MiB/s.
volumeId string
volumeSize number
The size of the volume, in GiB.
volumeType string
The type of the volume.
delete_on_termination bool
If the root block device will be deleted on termination.
device_name str
The physical name of the device.
encrypted bool
If the EBS volume is encrypted.
iops int
0 If the volume is not a provisioned IOPS image, otherwise the supported IOPS count.
kms_key_id str
snapshot_id str
The ID of the snapshot.
tags Mapping[str, str]
A map of tags assigned to the Instance.
throughput int
The throughput of the volume, in MiB/s.
volume_id str
volume_size int
The size of the volume, in GiB.
volume_type str
The type of the volume.

GetInstanceEnclaveOption

Enabled bool
Whether Nitro Enclaves are enabled.
Enabled bool
Whether Nitro Enclaves are enabled.
enabled boolean
Whether Nitro Enclaves are enabled.
enabled bool
Whether Nitro Enclaves are enabled.

GetInstanceEphemeralBlockDevice

DeviceName string
The physical name of the device.
NoDevice bool
Whether the specified device included in the device mapping was suppressed or not (Boolean).
VirtualName string
The virtual device name.
DeviceName string
The physical name of the device.
NoDevice bool
Whether the specified device included in the device mapping was suppressed or not (Boolean).
VirtualName string
The virtual device name.
deviceName string
The physical name of the device.
noDevice boolean
Whether the specified device included in the device mapping was suppressed or not (Boolean).
virtualName string
The virtual device name.
device_name str
The physical name of the device.
no_device bool
Whether the specified device included in the device mapping was suppressed or not (Boolean).
virtual_name str
The virtual device name.

GetInstanceFilter

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

GetInstanceMetadataOption

HttpEndpoint string
The state of the metadata service: enabled, disabled.
HttpPutResponseHopLimit int
The desired HTTP PUT response hop limit for instance metadata requests.
HttpTokens string
If session tokens are required: optional, required.
HttpEndpoint string
The state of the metadata service: enabled, disabled.
HttpPutResponseHopLimit int
The desired HTTP PUT response hop limit for instance metadata requests.
HttpTokens string
If session tokens are required: optional, required.
httpEndpoint string
The state of the metadata service: enabled, disabled.
httpPutResponseHopLimit number
The desired HTTP PUT response hop limit for instance metadata requests.
httpTokens string
If session tokens are required: optional, required.
http_endpoint str
The state of the metadata service: enabled, disabled.
http_put_response_hop_limit int
The desired HTTP PUT response hop limit for instance metadata requests.
http_tokens str
If session tokens are required: optional, required.

GetInstanceRootBlockDevice

DeleteOnTermination bool
If the root block device will be deleted on termination.
DeviceName string
The physical name of the device.
Encrypted bool
If the EBS volume is encrypted.
Iops int
0 If the volume is not a provisioned IOPS image, otherwise the supported IOPS count.
KmsKeyId string
Tags Dictionary<string, string>
A map of tags assigned to the Instance.
Throughput int
The throughput of the volume, in MiB/s.
VolumeId string
VolumeSize int
The size of the volume, in GiB.
VolumeType string
The type of the volume.
DeleteOnTermination bool
If the root block device will be deleted on termination.
DeviceName string
The physical name of the device.
Encrypted bool
If the EBS volume is encrypted.
Iops int
0 If the volume is not a provisioned IOPS image, otherwise the supported IOPS count.
KmsKeyId string
Tags map[string]string
A map of tags assigned to the Instance.
Throughput int
The throughput of the volume, in MiB/s.
VolumeId string
VolumeSize int
The size of the volume, in GiB.
VolumeType string
The type of the volume.
deleteOnTermination boolean
If the root block device will be deleted on termination.
deviceName string
The physical name of the device.
encrypted boolean
If the EBS volume is encrypted.
iops number
0 If the volume is not a provisioned IOPS image, otherwise the supported IOPS count.
kmsKeyId string
tags {[key: string]: string}
A map of tags assigned to the Instance.
throughput number
The throughput of the volume, in MiB/s.
volumeId string
volumeSize number
The size of the volume, in GiB.
volumeType string
The type of the volume.
delete_on_termination bool
If the root block device will be deleted on termination.
device_name str
The physical name of the device.
encrypted bool
If the EBS volume is encrypted.
iops int
0 If the volume is not a provisioned IOPS image, otherwise the supported IOPS count.
kms_key_id str
tags Mapping[str, str]
A map of tags assigned to the Instance.
throughput int
The throughput of the volume, in MiB/s.
volume_id str
volume_size int
The size of the volume, in GiB.
volume_type str
The type of the volume.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.