googleFirebaseHostingVersion
A version
is a configuration which determine how a site is displayed. Static files are not supported at the moment.
\~> Warning: This resource is in beta, and should be used with the terraform-provider-google-beta provider. See Provider Versions for more details on beta resources.
To get more information about Version, see:
- API documentation
- How-to Guides
- Official Documentation
Example Usage - Firebasehosting Version Redirect
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleFirebaseHostingSiteDefault =
new google.firebaseHostingSite.FirebaseHostingSite(this, "default", {
project: "my-project-name",
provider: "${google-beta}",
site_id: "site-id",
});
const googleFirebaseHostingVersionDefault =
new google.firebaseHostingVersion.FirebaseHostingVersion(this, "default_1", {
config: [
{
redirects: [
{
glob: "/google/**",
location: "https://www.google.com",
status_code: 302,
},
],
},
],
provider: "${google-beta}",
site_id: googleFirebaseHostingSiteDefault.siteId,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleFirebaseHostingVersionDefault.overrideLogicalId("default");
const googleFirebaseHostingReleaseDefault =
new google.firebaseHostingRelease.FirebaseHostingRelease(this, "default_2", {
message: "Redirect to Google",
provider: "${google-beta}",
site_id: googleFirebaseHostingSiteDefault.siteId,
version_name: googleFirebaseHostingVersionDefault.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleFirebaseHostingReleaseDefault.overrideLogicalId("default");
Example Usage - Firebasehosting Version Cloud Run
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleCloudRunV2ServiceDefault =
new google.cloudRunV2Service.CloudRunV2Service(this, "default", {
ingress: "INGRESS_TRAFFIC_ALL",
location: "us-central1",
name: "cloud-run-service-via-hosting",
project: "my-project-name",
provider: "${google-beta}",
template: [
{
containers: [
{
image: "us-docker.pkg.dev/cloudrun/container/hello",
},
],
},
],
});
const googleFirebaseHostingSiteDefault =
new google.firebaseHostingSite.FirebaseHostingSite(this, "default_1", {
project: "my-project-name",
provider: "${google-beta}",
site_id: "site-id",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleFirebaseHostingSiteDefault.overrideLogicalId("default");
const googleFirebaseHostingVersionDefault =
new google.firebaseHostingVersion.FirebaseHostingVersion(this, "default_2", {
config: [
{
rewrites: [
{
glob: "/hello/**",
run: [
{
region: googleCloudRunV2ServiceDefault.location,
service_id: googleCloudRunV2ServiceDefault.name,
},
],
},
],
},
],
provider: "${google-beta}",
site_id: googleFirebaseHostingSiteDefault.siteId,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleFirebaseHostingVersionDefault.overrideLogicalId("default");
const googleFirebaseHostingReleaseDefault =
new google.firebaseHostingRelease.FirebaseHostingRelease(this, "default_3", {
message: "Cloud Run Integration",
provider: "${google-beta}",
site_id: googleFirebaseHostingSiteDefault.siteId,
version_name: googleFirebaseHostingVersionDefault.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleFirebaseHostingReleaseDefault.overrideLogicalId("default");
Example Usage - Firebasehosting Version Cloud Functions
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleFirebaseHostingSiteDefault =
new google.firebaseHostingSite.FirebaseHostingSite(this, "default", {
project: "my-project-name",
provider: "${google-beta}",
site_id: "site-id",
});
const googleStorageBucketBucket = new google.storageBucket.StorageBucket(
this,
"bucket",
{
location: "US",
name: "site-id-function-source",
project: "my-project-name",
provider: "${google-beta}",
uniform_bucket_level_access: true,
}
);
const googleStorageBucketObjectObject =
new google.storageBucketObject.StorageBucketObject(this, "object", {
bucket: googleStorageBucketBucket.name,
name: "function-source.zip",
provider: "${google-beta}",
source: "function-source.zip",
});
const googleCloudfunctionsFunctionFunction =
new google.cloudfunctionsFunction.CloudfunctionsFunction(this, "function", {
available_memory_mb: 128,
description: "A Cloud Function connected to Firebase Hosing",
entry_point: "helloHttp",
name: "cloud-function-via-hosting",
project: "my-project-name",
provider: "${google-beta}",
runtime: "nodejs16",
source_archive_bucket: googleStorageBucketBucket.name,
source_archive_object: googleStorageBucketObjectObject.name,
trigger_http: true,
});
const googleFirebaseHostingVersionDefault =
new google.firebaseHostingVersion.FirebaseHostingVersion(this, "default_4", {
config: [
{
rewrites: [
{
function: googleCloudfunctionsFunctionFunction.name,
glob: "/hello/**",
},
],
},
],
provider: "${google-beta}",
site_id: googleFirebaseHostingSiteDefault.siteId,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleFirebaseHostingVersionDefault.overrideLogicalId("default");
const googleFirebaseHostingReleaseDefault =
new google.firebaseHostingRelease.FirebaseHostingRelease(this, "default_5", {
message: "Cloud Functions Integration",
provider: "${google-beta}",
site_id: googleFirebaseHostingSiteDefault.siteId,
version_name: googleFirebaseHostingVersionDefault.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleFirebaseHostingReleaseDefault.overrideLogicalId("default");
Argument Reference
The following arguments are supported:
siteId
- (Required) Required. The ID of the site in which to create this Version.
config
- (Optional) The configuration for the behavior of the site. This configuration exists in thefirebaseJson
file. Structure is documented below.
-
rewrites
- (Optional) An array of objects (called rewrite rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond as if the service were given the specified destination URL. Structure is documented below. -
redirects
- (Optional) An array of objects (called redirect rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond with a redirect to the specified destination path. Structure is documented below.
-
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. -
function
- (Optional) The function to proxy requests to. Must match the exported function name exactly. -
run
- (Optional) The request will be forwarded to Cloud Run. Structure is documented below.
-
serviceId
- (Required) User-defined ID of the Cloud Run service. -
region
- (Optional) Optional. User-provided region where the Cloud Run service is hosted. Defaults tousCentral1
if not supplied.
-
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. -
statusCode
- (Required) The status HTTP code to return in the response. It must be a valid 3xx status code. -
location
- (Required) The value to put in the HTTP location header of the response. The location can contain capture group values from the pattern using a : prefix to identify the segment and an optional * to capture the rest of the URL. For example:
Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
-
id
- an identifier for the resource with formatsites/{{siteId}}/versions/{{versionId}}
-
name
- The fully-qualified resource name for the version, in the format: sites/SITE_ID/versions/VERSION_ID -
versionId
- The ID for the version as in sites/SITE_ID/versions/VERSION_ID
Timeouts
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.delete
- Default is 20 minutes.
Import
Version can be imported using any of these accepted formats: