» alicloud_instances

The Instances data source list ECS instance resources according to their ID, name regex, image id, status and other fields.

» Example Usage

data "alicloud_instances" "instances_ds" {
  name_regex = "web_server"
  status     = "Running"

output "first_instance_id" {
  value = "${data.alicloud_instances.instances_ds.instances.0.id}"

output "instance_ids" {
  value = "${data.alicloud_instances.instances_ds.ids}"

» Argument Reference

The following arguments are supported:

  • ids - (Optional) A list of ECS instance IDs.
  • name_regex - (Optional) A regex string to filter results by instance name.
  • image_id - (Optional) The image ID of some ECS instance used.
  • status - (Optional) Instance status. Valid values: "Creating", "Starting", "Running", "Stopping" and "Stopped". If undefined, all statuses are considered.
  • vpc_id - (Optional) ID of the VPC linked to the instances.
  • vswitch_id - (Optional) ID of the VSwitch linked to the instances.
  • availability_zone - (Optional) Availability zone where instances are located.
  • resource_group_id - (Optional, ForceNew, Available in 1.57.0+) The Id of resource group which the instance belongs.
  • ram_role_name - (Optional, ForceNew, Available in 1.69.0+) The RAM role name which the instance attaches.
  • tags - (Optional) A map of tags assigned to the ECS instances. It must be in the format: data "alicloud_instances" "taggedInstances" { tags = { tagKey1 = "tagValue1", tagKey2 = "tagValue2" } }
  • output_file - (Optional) File name where to save data source results (after running terraform plan).

» Attributes Reference

The following attributes are exported in addition to the arguments listed above: