我有一个用于创建eks集群的Terraform脚本 我还有另一个创建rds的terraform脚本,我希望创建该rds 在与eks群集相同的VPC中。
data "aws_eks_cluster" "example" {
name = "example"
}
output "subnets" {
value = "${data.aws_eks_cluster.example.vpc_config.vpc_id}"
}
这是我的rds.tf
resource "aws_db_instance" "rds" {
allocated_storage = "${var.rds_allocated_storage}"
storage_type = "${var.rds_storage_type}"
engine = "${var.rds_engine}"
engine_version = "${var.rds_engine_version}"
instance_class = "${var.rds_instance_class}"
name = "${var.project_name}_${var.env}_data_rds${var.rds_engine}"
username = "dbadmin"
password = "${var.rds_db_password}"
multi_az = false
skip_final_snapshot = true
db_subnet_group_name = "${aws_db_subnet_group.rds_subnet.name}"
vpc_security_group_ids = "${var.rds_vpc_security_group_ids}"
identifier = "${var.project_name}-${var.env}-data-rds${var.rds_engine}"
我想从我的eks获取db_subnet_group_name和vpc_security_group_ids 而不是来自variables.tf
答案 0 :(得分:0)
我相信您需要类似的东西
vpc_security_group_ids = "${data.aws_eks_cluster.example.vpc_config.0.security_group_ids}"