小编Ale*_*x G的帖子

如何避免 RDS 实例和安全组的模块中出现循环错误

我正在编写一个 terraform 模块,该模块提供 RDS 数据库实例及其用于控制​​入站连接的关联安全组。我遇到的问题是安全组资源需要数据库端口作为参数,而数据库实例资源需要安全组 ID 作为参数。因此出现循环错误。

resource "aws_security_group" "this" {
  name = "${local.name}-inbound"
  description = "Allow inbound traffic from customer instances and management"
  vpc_id = "${var.vpc_id}"
  ingress {
    from_port = "${aws_db_instance.this.port}"
    to_port   = "${aws_db_instance.this.port}"
    protocol  = 6
    security_groups = ["${var.ingress_sg_ids}"]
  }
}

resource "aws_db_instance" "this" {
  allocated_storage       = "${var.storage_size}"
  storage_type            = "${var.storage_type}"
  engine                  = "${var.db_engine}"
  engine_version          = "${var.db_engine_version}"
  instance_class          = "${var.instance_type}"
  identifier_prefix       = "${local.name}-"
  name                    = "${var.env}_${var.workspace}"
  username                = "${var.root_username}"
  password                = "${random_id.root_password.b64}"
  db_subnet_group_name    = "${aws_db_subnet_group.this.name}"
  parameter_group_name    = "${var.param_group_name}" …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services terraform

1
推荐指数
1
解决办法
2030
查看次数

标签 统计

amazon-web-services ×1

terraform ×1