From 6b7909ff59295af3bf03494346bc929bb3a6d23a Mon Sep 17 00:00:00 2001 From: Marc Dietrichstein Date: Thu, 18 Apr 2024 00:46:03 +0200 Subject: [PATCH] Add "path" property to rewrite config for firebase hosting version (#10448) --- mmv1/products/firebasehosting/Version.yaml | 18 +++++++++++++++ .../firebasehosting_version_path.tf.erb | 23 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 mmv1/templates/terraform/examples/firebasehosting_version_path.tf.erb diff --git a/mmv1/products/firebasehosting/Version.yaml b/mmv1/products/firebasehosting/Version.yaml index d17ec1071be6..2d2a80c2f876 100644 --- a/mmv1/products/firebasehosting/Version.yaml +++ b/mmv1/products/firebasehosting/Version.yaml @@ -37,6 +37,14 @@ examples: site_id: site-id test_env_vars: project_id: :PROJECT_NAME + - !ruby/object:Provider::Terraform::Examples + name: 'firebasehosting_version_path' + min_version: 'beta' + primary_resource_id: 'default' + vars: + site_id: site-id + test_env_vars: + project_id: :PROJECT_NAME - !ruby/object:Provider::Terraform::Examples name: 'firebasehosting_version_cloud_run' min_version: 'beta' @@ -112,18 +120,28 @@ properties: exactly_one_of: - glob - regex + - !ruby/object:Api::Type::String + name: path + description: + The URL path to rewrite the request to. + exactly_one_of: + - path + - function + - run - !ruby/object:Api::Type::String name: function description: The function to proxy requests to. Must match the exported function name exactly. exactly_one_of: + - path - function - run - !ruby/object:Api::Type::NestedObject name: run description: The request will be forwarded to Cloud Run. exactly_one_of: + - path - function - run properties: diff --git a/mmv1/templates/terraform/examples/firebasehosting_version_path.tf.erb b/mmv1/templates/terraform/examples/firebasehosting_version_path.tf.erb new file mode 100644 index 000000000000..d4df018f8ea4 --- /dev/null +++ b/mmv1/templates/terraform/examples/firebasehosting_version_path.tf.erb @@ -0,0 +1,23 @@ +resource "google_firebase_hosting_site" "default" { + provider = google-beta + project = "<%= ctx[:test_env_vars]['project_id'] %>" + site_id = "<%= ctx[:vars]['site_id'] %>" +} + +resource "google_firebase_hosting_version" "default" { + provider = google-beta + site_id = google_firebase_hosting_site.default.site_id + config { + rewrites { + glob = "**" + path = "/index.html" + } + } +} + +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 = "Path Rewrite" +} \ No newline at end of file