![](/img/trans.png)
[英]How to deploy the Google Cloud Function via Terraform without using a bucket?
[英]How to modify CORS of an existing bucket in google cloud using Terraform
我使用創建默認存儲桶的 Terraform 創建應用引擎。 我想在相同的 terraform 代碼中修改它的 CORS。
當我使用以下代碼時,它會嘗試創建一個新存儲桶:
resource "google_storage_bucket" "app_engine_bucket" {
name = local.app_engine_default_bucket
location = "US"
cors {
origin = ["*"]
method = ["GET", "PUT", "DELETE"]
response_header = ["Content-Type"]
max_age_seconds = 3600
}
}
由於您添加了您正在使用 Appengine 的評論,因此您將使用應用配置 yaml來指定您的 CORS 設置。
例子:
handlers:
- url: /images
static_dir: static/images
http_headers:
Access-Control-Allow-Origin: https://mygame.uc.r.appspot.com
# ...
如果您想修改不受 AppEngine 管理的存儲桶,您可以在存儲桶的配置中指定 CORS 配置,如 Marcin 在評論中提到的那樣。
例子:
resource "google_storage_bucket" "static-site" {
name = "image-store.com"
location = "EU"
force_destroy = true
uniform_bucket_level_access = true
website {
main_page_suffix = "index.html"
not_found_page = "404.html"
}
cors {
origin = ["http://image-store.com"]
method = ["GET", "HEAD", "PUT", "POST", "DELETE"]
response_header = ["*"]
max_age_seconds = 3600
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.