'Using default VPC id to retrieve specific subnet in terraform not working

I'm trying to get the subnet of my RDS module/resource that is deployed to the default VPC. The RDS instance is deployed to ap-southeast-2c.

My configuration file to retrieve the subnet is below.

data "aws_vpc" "default_vpc_data" {
  default = true
}

data "aws_subnet" "selected_subnet" {
  id                = data.aws_vpc.default_vpc_data.id
  availability_zone = "ap-southeast-2c"
}

I'm getting the following error when trying to apply the file.

Error: no matching EC2 Subnet found with data.aws_subnet.selected_subnet on glue_connections.tf line 17, in data "aws_subnet" "selected_subnet":

I'm not sure why this is happening?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source