Below terraform code showing most of the details of instances in a region. Even subnet id showing but not vpc id.
provider “aws” {
region = “us-west-1”
}data “aws_instances” “instances” {
instance_state_names = [“running”, “stopped”,“pending”, “shutting-down”, “stopping”] #, “terminated”]
}data “aws_instance” “this” {
for_each = toset(data.aws_instances.instances.ids)
instance_id = each.key
}
output “instance_arns” {
value = data.aws_instance.this[*]
}
How to retrieve vpc id also?