diff --git a/mmv1/products/compute/api.yaml b/mmv1/products/compute/api.yaml index e68a7b874d6f..82d5699a2cf1 100644 --- a/mmv1/products/compute/api.yaml +++ b/mmv1/products/compute/api.yaml @@ -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: | diff --git a/mmv1/products/compute/terraform.yaml b/mmv1/products/compute/terraform.yaml index 0cf727488de2..df660dc0f360 100644 --- a/mmv1/products/compute/terraform.yaml +++ b/mmv1/products/compute/terraform.yaml @@ -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' diff --git a/mmv1/templates/terraform/examples/backend_bucket_include_http_headers.tf.erb b/mmv1/templates/terraform/examples/backend_bucket_include_http_headers.tf.erb new file mode 100644 index 000000000000..2845d5a61708 --- /dev/null +++ b/mmv1/templates/terraform/examples/backend_bucket_include_http_headers.tf.erb @@ -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" +} diff --git a/mmv1/templates/terraform/examples/backend_bucket_query_string_whitelist.tf.erb b/mmv1/templates/terraform/examples/backend_bucket_query_string_whitelist.tf.erb new file mode 100644 index 000000000000..f4151212ec95 --- /dev/null +++ b/mmv1/templates/terraform/examples/backend_bucket_query_string_whitelist.tf.erb @@ -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" +}