【发布时间】:2022-11-19 08:19:45
【问题描述】:
我在一个更大的项目中有一些有效的地形定义:
resource "google_storage_bucket" "owlee_functions_bucket" {
name = "owlee_functions_bucket"
location = "europe-west2"
project = "owlee-software"
}
resource "google_storage_bucket_object" "archive" {
name = "index.zip"
bucket = google_storage_bucket.owlee_functions_bucket.name
source = "../apps/backend/dist/index.zip"
}
resource "google_cloudfunctions_function" "backend_function" {
name = "backend_function"
runtime = "nodejs16"
project = "owlee-software"
region = "europe-west2"
available_memory_mb = 128
source_archive_bucket = google_storage_bucket.owlee_functions_bucket.name
source_archive_object = google_storage_bucket_object.archive.name
trigger_http = true
entry_point = "OWLEE"
}
然后我尝试通过 CI 进行部署,目前,我只是在压缩新版本的函数以处理部署后运行terraform apply。
这不是很好,我想理想地将其更改为非 terraform 过程,但似乎没有任何记录/可能的任何地方,这让我觉得我对此有错误的方法。
第二个更迫切需要解决的问题——
我现在想继续在本地管理我的基础设施,不想每次必须在本地运行 terraform apply 时都必须压缩新版本的功能才能部署。
有没有办法 - 在创建之后 - 避免通过 terraform 覆盖/上传函数?
我猜这对于 CI 部署的工作来说是有必要的。
我已经查看了一些其他 SO 线程,但他们正在查看有关云构建和工件注册表的细节。
【问题讨论】:
标签: google-cloud-functions terraform terraform-provider-gcp infrastructure-as-code