- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因此,我们在我们的组织中非常广泛地使用 terraform,我对其他人如何进行 VPC 对等互连有一些疑问。连接的初始创建非常简单。我们从刚刚创建的 VPC 拉入并引用另一个 VPC,然后它填充路由表等。问题出在我们刚刚与之对等的 VPC 上。现在,我们必须手动转到其他网络堆栈并手动添加 CIDR/PCX id 作为变量。我编写了一个脚本,可以让我们更轻松地处理这个问题,但我想问是否有人针对任何现有 VPC 动态执行 AWS 查找,并自动将现有 PCX 添加到该 VPC 的路由表中。
OPS VPC 就是一个体现这一点值(value)的示例。我们有OPS,然后是dev、prod、qa、stg、uat、cte等。因此,当我们创建CTE vpc时,它会自动创建一个pcx并将其链接到ops并路由到ops。然而,ops 并不知道这个新的 pcx。所以我们必须手动添加。我希望运营商能够自行进行资源查找,并为其找到的任何新 VPC/PCX 提供自己的资源。
TLDR;一种使双向 VPC 对等互连更加动态的方法
最佳答案
假设您使用 remote state backend ,您可以将 OPS 网络堆栈拉入 remote state data source然后从您希望它能够路由到的任何临时堆栈更改其路由表。
将尝试做一个最小的示例(显然缺少大量样板):
# my_ops_stack.tf
provider "aws" {
region = "eu-west-1"
}
module "ops_stack" {
source = "/my/modules/ops_stack"
cidr = "10.1.0.0/16"
// other vars probably
}
// the outputs which will be accessible
// via the remote state data source:
output "routing_table_id" {
value = "${module.ops_stack.routing_table_id}"
}
output "vpc_id" {
value = "${module.ops_stack.vpc_id}"
}
output "vpc_cidr" {
value = "10.1.0.0/16"
}
我现在 configure使用 terraform cli (this will soon be possible in config) 的该堆栈的远程状态后端:
# Run in the same folder as my_ops_stack.tf
terraform remote config \
-backend=s3 \
-backend-config="bucket=my-state-bucket" \
-backend-config="key=ops-stack/terraform.tfstate" \
-backend-config="region=eu-west-1"
现在状态后端已配置,您应用于堆栈的任何更改都将同步到该后端:
terraform apply
# the usual stuff... but now synced with s3!
现在,在新的临时堆栈的模板中(dev、prod、qa、stg、uat、cte 等):
# my_dev_stack.tf
provider "aws" {
region = "eu-west-1"
}
// Pull in your ops stack from the remote backend:
data "terraform_remote_state" "ops_stack" {
backend = "s3"
config {
bucket = "my-state-bucket"
key = "ops-stack/terraform.tfstate"
region = "eu-west-1"
}
}
// Create your dev stack
module "dev_stack" {
source = "/my/modules/dev_stack"
cidr = "10.2.0.0/16"
// The ops_stack vpc id for creating the peering connection:
ops_vpc_id = "${data.terraform_remote_state.ops_stack.vpc_id}"
// Maybe some security group rules you wanna setup
allow_access_from = "${data.terraform_remote_state.ops_stack.vpc_cidr}"
// other vars probably
}
// And use its outputs to add a route to the
// ops vpc routing table from the dev stack!
resource "aws_route" "ops_to_dev" {
route_table_id = "${data.terraform_remote_state.ops_stack.routing_table_id}"
destination_cidr_block = "10.2.0.0/16" // dev_stack's cidr
vpc_peering_connection_id = "${module.dev_stack.vpcx_id}"
}
完成临时堆栈后,您可以安全地销毁它,它甚至会清理其在操作堆栈中的路由。
希望这就是您想要的!
关于Terraform 和 VPC 对等互连,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41818231/
我希望我的 C/C++ 客户端通过 SSL 验证服务器。我首先使用 从服务器下载了证书文件 openssl s_client -showcerts -connect www.openssl.org:4
我正在尝试学习使用 RSelenium。我坚持只是尝试使用 rsDriver 启动服务器。我只是想运行下面的代码并得到以下错误: rD = 8 x64 (build 9200) Matrix prod
我已经建立了一个 8 组织的单 channel 结构网络。我能够进行整个网络设置。但是设置成功后。一些 docker 实例停止监听它们各自的端口。当我做 docker ps -a它显示了一些对等节点图
如何在多个 Azure Kubernetes 集群上的 Pod 之间配置路由? 与 Google Cloud 上的 ip-alias/vpc-native 类似的内容 最佳答案 在 AKS 中,我认为
我正在尝试实现点对点连接应用程序。所以我想将 2 个以上的设备相互连接。如何为每对设备创建单独的 session 使用新的 GameKit 框架是否可以连接到 1 个以上的设备? 最佳答案 您可以使用
我一直致力于创建一个 VPC 对等连接,该连接可以使用 cloudformation 从 eu-west-1 与 us-east-1 进行对等。这是目前的云信息: AWSTemplateFormatV
我正在尝试在两个不同区域之间进行 vpc 对等互连。在这里我已经创建了资源,现在我只想将它们的 id 作为参数传递。在同一区域,我可以在两个 VPC 之间进行对等。但我在两个不同的区域收到错误,因为r
我是一名优秀的程序员,十分优秀!