![](/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.