我创建了一个Cloud Run
带有Serverless VPC access connector
to a的 Google 修订版VPC Network
。可以通过,VPC Network
访问 Internet Cloud NAT
,以允许Cloud Run
实例具有static outbound ip address
,如本教程中所述:https ://cloud.google.com/run/docs/configuring/static-outbound-ip 。我按照教程进行了操作,一切都很好,我得到了来自Cloud Run
实例的出口流量的静态 IP 地址。
我曾经terraform
部署所有资源,您可以在下面找到其代码。问题是这样destroy
的: 获取资源后,出现以下错误:
ERROR: (gcloud.compute.networks.delete) Could not fetch resource:
- The network resource 'projects/myproject/global/networks/webhook-network' is already being used by 'projects/myproject/global/networkInstances/v1823516883-618da3a7-bd4f-4524-...-...'
(这些点包含更多数字,但由于这似乎是某种 uuid,我不想分享其余部分)。
所以我不能删除第一个网络。当我更改网络的名称和 reapply
时,apply
成功,但outbound static ip
出口的地址是169.254.X.X
,我找到以下信息:
“当你看到 a169.254.X.X
时,你肯定有问题” ==> 闻起来像麻烦。
任何可以帮助我的 Google 员工?我认为重现“损坏”的 VPC 网络的步骤是创建一个Serverless Access Connector
与 VPC 的连接,用Cloud Run
修订版引用它,然后在删除修订版之前VPC network
删除和,但老实说不确定,我不真的有闲置的 GCP 项目来测试它。Serverless Access Connector
Cloud Run
这个 StackOverflow 问题没有帮助:https ://serverfault.com/questions/1016015/google-cloud-platform-find-resource-by-full-resource-name ,这是我能找到的唯一相关问题。
有人有想法么?
locals {
region = "europe-west1"
}
resource "google_compute_network" "webhook_network" {
name = "webhook-network-6"
auto_create_subnetworks = false
}
resource "google_compute_subnetwork" "subnetwork" {
depends_on = [
google_compute_network.webhook_network
]
name = "webhook-subnet-6"
network = google_compute_network.webhook_network.self_link
ip_cidr_range = "10.14.0.0/28"
region = local.region
}
resource "google_compute_router" "router" {
depends_on = [
google_compute_subnetwork.subnetwork,
google_compute_network.webhook_network
]
name = "router6"
region = google_compute_subnetwork.subnetwork.region
network = google_compute_network.webhook_network.name
}
// I created the static IP address manually
//resource "google_compute_address" "static_address" {
// name = "nat-static-ip-address"
// region = local.region
//}
resource "google_compute_router_nat" "advanced-nat" {
name = "natt"
router = google_compute_router.router.name
region = local.region
nat_ip_allocate_option = "MANUAL_ONLY"
nat_ips = [
var.ip_name
]
source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
}
data "google_project" "project" {
}
}
resource "google_vpc_access_connector" "access_connector" {
depends_on = [
google_compute_network.webhook_network,
google_compute_subnetwork.subnetwork
]
name = "stat-ip-conn-6"
project = var.project_id
region = local.region
ip_cidr_range = "10.4.0.0/28"
network = google_compute_network.webhook_network.name
}