I have the following main.tf
provider "aws" { region = "us-west-1" } data "aws_ami" "this" { most_recent = true owners = [ "amazon" ] } resource aws_instance "this" { ami = data.aws_ami.this.id instance_type = "t2.micro" }
No any other file in place. When I do terraform, how terraform decide which AMI to and which subnet to use? for example, I intentionally take away the filters away for the AMI, what logic terraform uses to make the selection?
Regarding the subnet, I do have a default VPC. But somehow we deleted all the subnets and re-created 1 public subnet in the VPC. But somehow terraform apply complains:
│ Error: Error launching source instance: MissingInput: No subnets found for the default VPC ‘vpc-396c3451’. Please specify a subnet.
│ status code: 400, request id: 8693f184-0a49-4bee-80f0-2e9f96c2f8b1
│
│ with aws_instance.this,
│ on ec2.tf line 10, in resource “aws_instance” “this”:
│ 20: resource aws_instance “this” {
│
I do have a subnet, and not sure why terraform complains no subnet found. Can somehow have some idea how I trace the issue?