private_subnet_id = one(aws_subnet.private_subnet[*]) != null ? one(aws_subnet.private_subnet[*]).id : var.private_subnet_id
public_subnet_id = one(aws_subnet.public_subnet[*]) != null ? one(aws_subnet.public_subnet[*]).id : var.public_subnet_id
+ additional_rds_subnet_id = one(aws_subnet.additional_rds_subnet[*]) != null ? one(aws_subnet.additional_rds_subnet[*]).id : var.additional_rds_subnet_id
public_hosts = var.private_only ? [] : var.user_facing_hosts
private_hosts = concat(
}
]
])
+ use_rds = var.use_rds
}
}
}
+#
+# Additional subnet on a different AZ is required if RDS is enabled
+#
+resource "aws_subnet" "additional_rds_subnet" {
+ count = (var.additional_rds_subnet_id == "" && local.use_rds) ? 1 : 0
+ vpc_id = local.arvados_vpc_id
+ availability_zone = data.aws_availability_zones.available.names[1]
+ cidr_block = "10.1.3.0/24"
+
+ lifecycle {
+ precondition {
+ condition = (var.vpc_id == "")
+ error_message = "additional_rds_subnet_id should be set if vpc_id is also set"
+ }
+ }
+}
+
#
# VPC S3 access
#
value = local.arvados_sg_id
}
+output "additional_rds_subnet_id" {
+ value = local.use_rds ? local.additional_rds_subnet_id : ""
+}
+
output "eip_id" {
value = { for k, v in aws_eip.arvados_eip: k => v.id }
}
output "custom_tags" {
value = var.custom_tags
}
+
+output "use_rds" {
+ value = var.use_rds
+}
# Optional networking options. Set existing resources to be used instead of
# creating new ones.
# NOTE: We only support fully managed or fully custom networking, not a mix of both.
+#
# vpc_id = "vpc-aaaa"
# sg_id = "sg-bbbb"
# public_subnet_id = "subnet-cccc"
# private_subnet_id = "subnet-dddd"
+#
+# RDS related parameters:
+# use_rds = true
+# additional_rds_subnet_id = "subnet-eeee"
# Optional custom tags to add to every resource. Default: {}
# custom_tags = {
default = ""
}
+variable "additional_rds_subnet_id" {
+ description = "Use existing subnet for RDS instead of creating one for the cluster"
+ type = string
+ default = ""
+}
+
variable "private_subnet_id" {
description = "Use existing private subnet instead of creating one for the cluster"
type = string
description = "Apply customized tags to every resource on the cluster"
type = map(string)
default = {}
+}
+
+variable "use_rds" {
+ description = "Enable this to create an RDS instance as the cluster's database service"
+ type = bool
+ default = false
}
\ No newline at end of file