Closed antonin-a closed 1 year ago
Hello,
I'm using the RDS instance v3 on my project, but the subnet_id is not related to network_id.
Here is a code I'm using:
### netwoking module
resource "flexibleengine_vpc_subnet_v1" "subnet_" {
for_each = {
for instance in local.vpc_configuration : "${var.BU}${instance.subnet_name}" => instance
}
name = "${var.BU}${each.value.subnet_name}"
cidr = each.value.subnet_cidr
gateway_ip = each.value.subnet_gw
vpc_id = flexibleengine_vpc_v1.vpc_["${var.BU}${each.value.vpc_name}"].id
primary_dns = "100.125.0.41"
secondary_dns= "100.126.0.41"
}
output "**db_subnet**" {
value = flexibleengine_vpc_subnet_v1.subnet_["${var.BU}_priv_database"].id
}
### main vars
subnet_id = module.networking.db_subnet // it will get the value from the output "**db_subnet**"
### rds module
resource "flexibleengine_rds_instance_v3" "RDS_instance" {
name = "${var.BU}_${var.type}_rds_instance"
flavor = var.enable-ha ? var.db_flavor_ha : var.db_flavor
ha_replication_mode = var.enable-ha ? "async" : ""
availability_zone = var.enable-ha ? ["eu-west-0b","eu-west-0a"] : ["eu-west-0b"]
security_group_id = var.security_group_database
vpc_id = var.db_vpc
**subnet_id = var.subnet_id**
db {
password = var.db_password
type = "MySQL"
version = "8.0"
port = "3306"
}
volume {
type = "COMMON"
size = 100
}
backup_strategy {
start_time = "08:00-09:00"
keep_days = 3
}
lifecycle {
ignore_changes = [
db
]
}
}
If you have all code in the same folder you can replace inside the rds creation var.subnet_id with 'flexibleengine_vpc_subnet_v1.your_subnet_name.id'
@antonin-a For historical reasons, there are several confusing concepts in subnet resource/service, I will try to explain them:
so, When other services need to refer to subnets, we recommend using subnet_id to represent the subnet service, and the value is flexibleengine_vpc_subnet_v1.subnet-1.id
.
In order to distinguish subnet_id parameter from subnet_id attribute in the subnet, we plan to change subnet_id attribute to ipv4_subent_id
closed by #857
Hi there,
When trying to create a RDS instance using https://registry.terraform.io/providers/FlexibleEngineCloud/flexibleengine/latest/docs/resources/rds_instance_v3
"Subnet_id" argument is asked : https://registry.terraform.io/providers/FlexibleEngineCloud/flexibleengine/latest/docs/resources/rds_instance_v3#subnet_id
But in fact it is waiting for 'network_id'
(Looks similar to https://github.com/FlexibleEngineCloud/terraform-provider-flexibleengine/issues/176) regards