Terraform - Referencing a subnet from tfstate file
- 
 I am trying to create an EC2 instance by referencing a subnet already present in the environment. I would like to use the data from the .tfstatefile in S3.I found this in the terraform manual, but since I have multiple subnets, I am unsure how to specify a specific one https://www.terraform.io/docs/providers/terraform/d/remote_state.html resource "aws_instance" "test instance" { ami = "${data.aws_ami.ubuntu.id}" instance_type = var.test.ec2_instance_type key_name = var.key_pair_name subnet_id = data.terraform_remote_state.vpc.outputs.subnet_id tags { Name = "test-instance" } }
- 
 Ok. I figured it out. Using the output from above through trial and error this was my answer. subnet_id = data.terraform_remote_state.network_configuration.outputs.mysubnet_name_idIn this example your subnet is named mysubnet_name
- 
 Is any of this in a module? 
- 
 What does terraform state listshow?
- 
 @stacksofplates said in Terraform - Referencing a subnet from tfstate file: What does terraform state listshow?data.aws_ami.launch_configuration_ami data.terraform_remote_state.network_configuration aws_launch_configuration.ec2_private_launch_configuration aws_launch_configuration.ec2_public_launch_configuration aws_security_group.ec2_private_security_group aws_security_group.ec2_public_security_group aws_security_group.elb_security_group
- 
 Ok. I figured it out. Using the output from above through trial and error this was my answer. subnet_id = data.terraform_remote_state.network_configuration.outputs.mysubnet_name_idIn this example your subnet is named mysubnet_name

