Skip to content

Commit a78549e

Browse files
Add headers to Hosting Version (#12527) (#20654)
[upstream:93c2b6e54aed3c54aed94e92875dd06b863d49f2] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent e607496 commit a78549e

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

.changelog/12527.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
firebasehosting: added `headers` field in `google_firebase_hosting_version` resource (beta)
3+
```

website/docs/r/firebase_hosting_version.html.markdown

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,68 @@ resource "google_firebase_hosting_release" "default" {
5959
message = "Redirect to Google"
6060
}
6161
```
62+
## Example Usage - Firebasehosting Version Headers
63+
64+
65+
```hcl
66+
resource "google_firebase_hosting_site" "default" {
67+
provider = google-beta
68+
project = "my-project-name"
69+
site_id = "site-id"
70+
}
71+
72+
resource "google_firebase_hosting_version" "default" {
73+
provider = google-beta
74+
site_id = google_firebase_hosting_site.default.site_id
75+
config {
76+
headers {
77+
# Also okay to use regex
78+
glob = "/headers/**"
79+
headers = {
80+
my-header = "my-value"
81+
}
82+
}
83+
}
84+
}
85+
86+
resource "google_firebase_hosting_release" "default" {
87+
provider = google-beta
88+
site_id = google_firebase_hosting_site.default.site_id
89+
version_name = google_firebase_hosting_version.default.name
90+
message = "With custom headers"
91+
}
92+
```
93+
## Example Usage - Firebasehosting Version Headers Regex
94+
95+
96+
```hcl
97+
resource "google_firebase_hosting_site" "default" {
98+
provider = google-beta
99+
project = "my-project-name"
100+
site_id = "site-id"
101+
}
102+
103+
resource "google_firebase_hosting_version" "default" {
104+
provider = google-beta
105+
site_id = google_firebase_hosting_site.default.site_id
106+
config {
107+
headers {
108+
# Also okay to use glob
109+
regex = "^~/headers$"
110+
headers = {
111+
my-header = "my-value"
112+
}
113+
}
114+
}
115+
}
116+
117+
resource "google_firebase_hosting_release" "default" {
118+
provider = google-beta
119+
site_id = google_firebase_hosting_site.default.site_id
120+
version_name = google_firebase_hosting_version.default.name
121+
message = "With custom headers"
122+
}
123+
```
62124
## Example Usage - Firebasehosting Version Path
63125

64126

@@ -228,6 +290,12 @@ The following arguments are supported:
228290
triggers Hosting to respond with a redirect to the specified destination path.
229291
Structure is [documented below](#nested_redirects).
230292

293+
* `headers` -
294+
(Optional)
295+
An array of objects, where each object specifies a URL pattern that, if matched to the request URL path,
296+
triggers Hosting to apply the specified custom response headers.
297+
Structure is [documented below](#nested_headers).
298+
231299

232300
<a name="nested_rewrites"></a>The `rewrites` block supports:
233301

@@ -290,6 +358,20 @@ The following arguments are supported:
290358
}
291359
```
292360

361+
<a name="nested_headers"></a>The `headers` block supports:
362+
363+
* `glob` -
364+
(Optional)
365+
The user-supplied glob to match against the request URL path.
366+
367+
* `regex` -
368+
(Optional)
369+
The user-supplied RE2 regular expression to match against the request URL path.
370+
371+
* `headers` -
372+
(Required)
373+
The additional headers to add to the response. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
374+
293375
## Attributes Reference
294376

295377
In addition to the arguments listed above, the following computed attributes are exported:

0 commit comments

Comments
 (0)