Terraform eks datasource vpc subnets security group



我有一个创建 eks 集群的地形脚本 我有另一个创建 rds 的地形脚本,我希望创建这个 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}"

我想从我的ek中得到db_subnet_group_name和vpc_security_group_ids 而不是来自 variables.tf

我相信你需要类似的东西

vpc_security_group_ids = "${data.aws_eks_cluster.example.vpc_config.0.security_group_ids}"

相关内容

  • 没有找到相关文章

最新更新