覆盖子模块的资源

时间:2019-02-09 21:49:25

标签: amazon-web-services module terraform terraform-provider-aws

我有相当多的堆栈,可同时创建VPC,安全组和Palo Alto防火墙-3个模块。

main.tf
/vpc/
   main.tf
   outputs.tf
   variables.tf
/sg/
   main.tf
   outputs.tf
   variables.tf
/pafw/
   main.tf
   outputs.tf
   variables.tf

PA FW完成后,我需要覆盖路由表以删除Internet网关。

达到此目的的最佳方法是什么?

我正在通过“ VPC”模块的多个副本来构建具有子网和路由表以及相关路由的多个VPC

我正在使用多个“ PAFW”模块中的引导程序来构建PA FW,并且需要Internet网关才能应用Bootstrap

“ PAFW”模块完成后,我需要使用“ 0.0.0.0/0”覆盖路由,以指向在调用所有模块的main.tf中创建的VPC对等连接。

到目前为止,我已经尝试过: -从“ PAFW”模块覆盖,但找不到在../vpc模块中覆盖资源的方法 -创建单独的路由,但失败,因为已经存在带有“ 0.0.0.0/0”的路由

感谢所有帮助!

VPC模块

resource "aws_route" "public_internet_gateway" {
  count = "${var.create_vpc && !var.public_subnets_peer && length(var.public_subnets) > 0 ? 1 : 0}"

  route_table_id         = "${aws_route_table.public.id}"
  destination_cidr_block = "0.0.0.0/0"
  gateway_id             = "${aws_internet_gateway.this.id}"

  timeouts {
    create = "5m"
  }
}

resource "aws_route" "public_peering" {
  count = "${var.create_vpc && var.public_subnets_peer ? 1 : 0}"

  route_table_id         = "${aws_route_table.public.id}"
  destination_cidr_block = "0.0.0.0/0"
  vpc_peering_connection_id = "${var.vpc_peering_id_1}"

  timeouts {
    create = "5m"
  }
}

PAFW模块通过以下方式完成Bootstrap:

resource "null_resource" "check_fw_ready" {
  triggers {
    key = "${aws_instance.FWInstance.id}"
  }

  provisioner "local-exec" {
    command = "./check_fw.sh ${aws_eip.ManagementElasticIP.public_ip}"
  }
}

0 个答案:

没有答案
相关问题