diff --git a/.changelog/12527.txt b/.changelog/12527.txt new file mode 100644 index 00000000000..5d9daecb9ea --- /dev/null +++ b/.changelog/12527.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +firebasehosting: added `headers` field in `google_firebase_hosting_version` resource (beta) +``` \ No newline at end of file diff --git a/website/docs/r/firebase_hosting_version.html.markdown b/website/docs/r/firebase_hosting_version.html.markdown index 2e94612a9d3..edc653c670d 100644 --- a/website/docs/r/firebase_hosting_version.html.markdown +++ b/website/docs/r/firebase_hosting_version.html.markdown @@ -59,6 +59,68 @@ resource "google_firebase_hosting_release" "default" { message = "Redirect to Google" } ``` +## Example Usage - Firebasehosting Version Headers + + +```hcl +resource "google_firebase_hosting_site" "default" { + provider = google-beta + project = "my-project-name" + site_id = "site-id" +} + +resource "google_firebase_hosting_version" "default" { + provider = google-beta + site_id = google_firebase_hosting_site.default.site_id + config { + headers { + # Also okay to use regex + glob = "/headers/**" + headers = { + my-header = "my-value" + } + } + } +} + +resource "google_firebase_hosting_release" "default" { + provider = google-beta + site_id = google_firebase_hosting_site.default.site_id + version_name = google_firebase_hosting_version.default.name + message = "With custom headers" +} +``` +## Example Usage - Firebasehosting Version Headers Regex + + +```hcl +resource "google_firebase_hosting_site" "default" { + provider = google-beta + project = "my-project-name" + site_id = "site-id" +} + +resource "google_firebase_hosting_version" "default" { + provider = google-beta + site_id = google_firebase_hosting_site.default.site_id + config { + headers { + # Also okay to use glob + regex = "^~/headers$" + headers = { + my-header = "my-value" + } + } + } +} + +resource "google_firebase_hosting_release" "default" { + provider = google-beta + site_id = google_firebase_hosting_site.default.site_id + version_name = google_firebase_hosting_version.default.name + message = "With custom headers" +} +``` ## Example Usage - Firebasehosting Version Path @@ -228,6 +290,12 @@ The following arguments are supported: triggers Hosting to respond with a redirect to the specified destination path. Structure is [documented below](#nested_redirects). +* `headers` - + (Optional) + An array of objects, where each object specifies a URL pattern that, if matched to the request URL path, + triggers Hosting to apply the specified custom response headers. + Structure is [documented below](#nested_headers). + The `rewrites` block supports: @@ -290,6 +358,20 @@ The following arguments are supported: } ``` +The `headers` block supports: + +* `glob` - + (Optional) + The user-supplied glob to match against the request URL path. + +* `regex` - + (Optional) + The user-supplied RE2 regular expression to match against the request URL path. + +* `headers` - + (Required) + The additional headers to add to the response. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: