- Newest
- Most votes
- Most comments
Hi Ojeyinka,
how many subnets are you passing in the aws_db_subnet_group resource?
Make sure you pass at least 2 subnets
resource "aws_db_subnet_group" "default" {
name = "main"
subnet_ids = [aws_subnet.frontend.id, aws_subnet.backend.id]
tags = {
Name = "My DB subnet group"
}
}
Hope it helps, and if it does I 'd appreciate answer to be accepted so that community can benefit for clarity when searching for similar issues, thanks!
I think there is an error in the subnet you are trying to create in the RDS Subnet Group.
- please check if the subnets configured in the subnet group are 2AZ or more.
- if it is configured with more than 2AZ, please check if each subnet is in an available AZ.
The following command will tell you if it is available or not
aws ec2 describe-availability-zones --region eu-west-1
@takakuni, Thank you for the response. This is my entire code block resource "aws_db_subnet_group" "ACS-rds" { name = "acs-rds" subnet_ids = var.private_subnets
tags = merge( var.tags, { Name = "ACS-database" }, ) }
create the RDS instance with the subnets group
resource "aws_db_instance" "ACS-rds" { allocated_storage = 20 storage_type = "gp2" engine = "mysql" engine_version = "5.7" instance_class = "db.t2.micro" name = "daviddb" username = var.db-username password = var.db-password parameter_group_name = "default.mysql5.7" db_subnet_group_name = aws_db_subnet_group.ACS-rds.name skip_final_snapshot = true vpc_security_group_ids = var.db-sg multi_az = "true" }
Hi @Oluwasegun,
I believe the part that corresponds to var.private_subnets
contains the subnet IDs in list form.
The subnet group requires at least two Availability Zones to be in use by a group of subnets.
From the error code, I think var.private_subnets consists only of eu-west-1c.
Try the following command for the subnet ID to check the Availability Zone.
aws ec2 describe-subnets --subnet-ids YOUR_SUBNET_ID --query [Subnets[].AvailabilityZone,Subnets[].SubnetId]
Relevant content
- asked 8 months ago
- asked a month ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 9 months ago
@alatech, this is my entire code block RDS subnet script: resource "aws_db_subnet_group" "ACS-rds" { name = "acs-rds" subnet_ids = var.private_subnets
tags = merge( var.tags, { Name = "ACS-database" }, ) }
create the RDS instance with the subnets group
resource "aws_db_instance" "ACS-rds" { allocated_storage = 20 storage_type = "gp2" engine = "mysql" engine_version = "5.7" instance_class = "db.t2.micro" name = "daviddb" username = var.db-username password = var.db-password parameter_group_name = "default.mysql5.7" db_subnet_group_name = aws_db_subnet_group.ACS-rds.name skip_final_snapshot = true vpc_security_group_ids = var.db-sg multi_az = "true" }
Hi, what is the content of private_subnets? It must be an array, can you share?