Skip to content

Commit

Permalink
Add support for cacheKeyPolicy in BackendBuckets (#6043)
Browse files Browse the repository at this point in the history
* Add support for cacheKeyPolicy in BackendBuckets

* Add an example of include_http_headers
  • Loading branch information
genkami authored May 31, 2022
1 parent 83e0759 commit 46d49d3
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mmv1/products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,31 @@ objects:
name: 'cdnPolicy'
description: 'Cloud CDN configuration for this Backend Bucket.'
properties:
- !ruby/object:Api::Type::NestedObject
name: 'cacheKeyPolicy'
description: 'The CacheKeyPolicy for this CdnPolicy.'
properties:
- !ruby/object:Api::Type::Array
send_empty_value: true
name: 'queryStringWhitelist'
at_least_one_of:
- cdn_policy.0.cache_key_policy.0.query_string_whitelist
- cdn_policy.0.cache_key_policy.0.include_http_headers
description: |
Names of query string parameters to include in cache keys.
Default parameters are always included. '&' and '=' will
be percent encoded and not treated as delimiters.
item_type: Api::Type::String
- !ruby/object:Api::Type::Array
send_empty_value: true
name: 'includeHttpHeaders'
at_least_one_of:
- cdn_policy.0.cache_key_policy.0.query_string_whitelist
- cdn_policy.0.cache_key_policy.0.include_http_headers
description: |
Allows HTTP request headers (by name) to be used in the
cache key.
item_type: Api::Type::String
- !ruby/object:Api::Type::Integer
name: 'signedUrlCacheMaxAgeSec'
description: |
Expand Down
10 changes: 10 additions & 0 deletions mmv1/products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ overrides: !ruby/object:Overrides::ResourceOverrides
vars:
backend_bucket_name: "image-backend-bucket"
bucket_name: "image-store-bucket"
- !ruby/object:Provider::Terraform::Examples
name: "backend_bucket_query_string_whitelist"
primary_resource_id: "image_backend"
vars:
backend_bucket_name: "image-backend-bucket"
- !ruby/object:Provider::Terraform::Examples
name: "backend_bucket_include_http_headers"
primary_resource_id: "image_backend"
vars:
backend_bucket_name: "image-backend-bucket"
custom_code: !ruby/object:Provider::Terraform::CustomCode
post_create: 'templates/terraform/post_create/compute_backend_bucket_security_policy.go.erb'
post_update: 'templates/terraform/post_create/compute_backend_bucket_security_policy.go.erb'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "google_compute_backend_bucket" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['backend_bucket_name'] %>"
description = "Contains beautiful images"
bucket_name = google_storage_bucket.image_bucket.name
enable_cdn = true
cdn_policy {
cache_key_policy {
include_http_headers = ["X-My-Header-Field"]
}
}
}

resource "google_storage_bucket" "image_bucket" {
name = "<%= ctx[:vars]['backend_bucket_name'] %>"
location = "EU"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "google_compute_backend_bucket" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['backend_bucket_name'] %>"
description = "Contains beautiful images"
bucket_name = google_storage_bucket.image_bucket.name
enable_cdn = true
cdn_policy {
cache_key_policy {
query_string_whitelist = ["image-version"]
}
}
}

resource "google_storage_bucket" "image_bucket" {
name = "<%= ctx[:vars]['backend_bucket_name'] %>"
location = "EU"
}

0 comments on commit 46d49d3

Please sign in to comment.