[英]How to modify CORS of an existing bucket in google cloud using Terraform
I create app engine using Terraform which creates a default bucket.我使用创建默认存储桶的 Terraform 创建应用引擎。 I would like to modify its CORS in the same terraform code.
我想在相同的 terraform 代码中修改它的 CORS。
When I use following code it tries to create a new bucket:当我使用以下代码时,它会尝试创建一个新存储桶:
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
}
}
Since you've added a comment that you're using Appengine, you'd use the app configuration yaml to specify your CORS settings.由于您添加了您正在使用 Appengine 的评论,因此您将使用应用配置 yaml来指定您的 CORS 设置。
Example:例子:
handlers:
- url: /images
static_dir: static/images
http_headers:
Access-Control-Allow-Origin: https://mygame.uc.r.appspot.com
# ...
If you wanted to modify buckets not managed by AppEngine you could specify the CORS configuration in the configuration for the bucket as Marcin mentioned in the comments.如果您想修改不受 AppEngine 管理的存储桶,您可以在存储桶的配置中指定 CORS 配置,如 Marcin 在评论中提到的那样。
example:例子:
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.