Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,10 @@ deployable
VMs
CDN
subdirectories
DNSSEC
AzureTF
VSCode
https
[0-9]+px
^.+[-:_]\w+$
[a-z]+([A-Z0-9]|[A-Z0-9]\w+)
Expand Down
4 changes: 3 additions & 1 deletion docs/architecture/websites.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ async function fetchData() {
**Operations** will use or extend the Nitric infrastructure modules, including both Terraform and Pulumi:

- Terraform Modules:
- Not yet available
- [Azure Website Terraform Module](https://github.com/nitrictech/nitric/blob/main/cloud/azure/deploytf/.nitric/modules/website/main.tf)
- [Google Cloud Website Terraform Module](https://github.com/nitrictech/nitric/blob/main/cloud/gcp/deploytf/.nitric/modules/website/main.tf)
- Pulumi Modules:
- [AWS Website Pulumi Module](https://github.com/nitrictech/nitric/blob/main/cloud/aws/deploy/website.go)
- [Azure Website Pulumi Module](https://github.com/nitrictech/nitric/blob/main/cloud/azure/deploy/website.go)
- [Google Cloud Website Pulumi Module](https://github.com/nitrictech/nitric/blob/main/cloud/gcp/deploy/website.go)
2 changes: 1 addition & 1 deletion docs/providers/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Currently, both the Pulumi and Terraform providers use the same underlying cloud
| [Batch](/batch) | [AWS Batch](/providers/mappings/aws/batch) | Coming soon | [GCP Batch](/providers/mappings/gcp/batch) | Custom |
| [Schedules](/schedules) | [CloudWatch Event Bridge](/providers/mappings/aws/schedules) | [Dapr Binding](/providers/mappings/azure/schedules) | [Cloud Scheduler](/providers/mappings/gcp/schedules) | Custom |
| [Websockets](/websockets) | [API Gateway](/providers/mappings/aws/websockets) | Not implemented | Not implemented | Custom |
| [Websites](/websites) | [AWS Cloudfront](/providers/mappings/aws/websites) | [Front Door](/providers/mappings/azure/websites) | Not implemented | Custom |
| [Websites](/websites) | [AWS Cloudfront](/providers/mappings/aws/websites) | [Front Door](/providers/mappings/azure/websites) | [Cloud CDN](/providers/mappings/gcp/websites) | Custom |
| [Storage](/storage#buckets) | [S3](/providers/mappings/aws/storage) | [Blob Storage](/providers/mappings/azure/storage) | [Cloud Storage](/providers/mappings/gcp/storage) | SeaweedFS |
| [Key Value Stores](/keyvalue) | [DynamoDB](/providers/mappings/aws/keyvalue) | [Table Storage](/providers/mappings/azure/keyvalue) | [FireStore](/providers/mappings/gcp/keyvalue) | BoltDB |
| [SQL Databases](/sql) | [RDS](/providers/mappings/aws/sql) | [Azure Database](/providers/mappings/azure/sql) | [Cloud SQL](/providers/mappings/gcp/sql) | Docker |
Expand Down
27 changes: 27 additions & 0 deletions docs/providers/mappings/gcp/websites.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
description: 'How Nitric deploys Websites to Google Cloud Platform'
---

# Google Cloud Resources - Websites

Nitric Websites are deployed to Google Cloud using [Cloud Storage](https://cloud.google.com/storage), [Cloud CDN](https://cloud.google.com/cdn), [Cloud DNS](https://cloud.google.com/dns), [Cloud Load Balancing](https://cloud.google.com/load-balancing) and [Certificate Manager](https://cloud.google.com/certificate-manager).

## Google Cloud Resources

The following resources are created when deploying Websites to Google Cloud:

- Storage Bucket
- Cloud CDN Backends
- Load Balancer Target Https Proxy
- DNS Zone Entries
- A Certificate Manager Certificate

## Deployment

During deployment the Nitric CLI creates a storage bucket for each website, uploading each static asset as an object. Then configures a target https proxy, certificate, and CDN as described to serve those assets:

- A Cloud Storage Bucket, per website
- Cloud CDN to cache and serve static files
- A Cloud Load Balancer to route traffic to buckets and APIs, including URL rewrites
- Cloud DNS to configure a domain name for the Load Balancer
- Certificate Manager to issue a certificate for the Load Balancer, enabling HTTPS
69 changes: 69 additions & 0 deletions docs/providers/pulumi/gcp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ apis:
# provide domains to be used for the api
description: An Azure API

# Add CDN configuration, required for websites deployments
# Available since v1.20.0
cdn:
# The name of the Google Cloud DNS Zone to use when configuring the website DNS
zone-name: yourzone
# A valid subdomain for the DNS Zone to use for the deployed websites endpoint
domain-name: app.example.com
# The following configuration values are optional
# Specify the TTL the CDN sends in the Cache-Control or Expires headers to clients
client-ttl: 3600
# Specify the TTL for content cached by the CDN when the origin server does not provide any caching directives
default-ttl: 604800
# Skip CDN cache invalidation during deployments (defaults to false)
skip-cache-invalidation: true

# Configure your deployed services
config:
# How services without a type will be deployed
Expand Down Expand Up @@ -162,6 +177,60 @@ config:
concurrency: 1000
```

### Websites

When deploying [websites](/websites), Google Cloud CDN doesn't automatically provide DNS names for deployed sites, so a DNS name must be provided. To do this you'll need to register a new domain name (or use one you already own), then configure the domain (or a subdomain) so that it uses the Google Name Servers (using a Google Cloud DNS Zone).

The DNS Zone in Google will then allow Nitric to create DNS records that route traffic to the CDN. Here are the steps:

- Purchase/Register a domain name with your domain registrar of choice.
- Navigate to https://console.cloud.google.com/net-services/dns/zones in your GCP Project
- Click `CREATE ZONE`
- Leave `Public` selected
- Enter a `Zone name`, and `Description` of your choice
- Enter your domain name (or subdomain) in the `DNS name` field
- Optionally enable DNSSEC
- Click `CREATE`

Now that the DNS Zone is created, you need to configure your registrar (domain) or existing DNS (subdomain) to point at the new name servers created for the zone.

The configuration detail are available on the `Zone details` page by clicking `REGISTRAR SETUP`. This step is different depending on your chosen domain registrar. Below are some general steps depending on whether your configuring the primary domain or a subdomain.

#### Domain

Your registrar (e.g. Namecheap, GoDaddy, Cloudflare, etc.) will allow you to change the name servers for you domain, sometimes this is called 'Custom DNS'. Add each of the name servers (NS records) from the Registrar setup dialog in the relevant config page for your registrar.

#### Subdomain

If you're configuring a subdomain e.g. app.yourdomain.com, you can simply add the NS records to your existing DNS configuration for the chosen subdomain. Typically, the config will look something like this:

<Note>Substitute your values for `Host` and `Nameserver`</Note>

| Record Type | Host | Nameserver |
| ----------- | ---- | ----------------------------- |
| NS Record | app | ns-cloud-a1.googledomains.com |
| NS Record | app | ns-cloud-a2.googledomains.com |
| NS Record | app | ns-cloud-a3.googledomains.com |
| NS Record | app | ns-cloud-a4.googledomains.com |

<Note>
If you enabled DNSSEC for the zone you will also need to create the relevant
DS record
</Note>

### Stack file configuration

Now that you have your DNS Zone created and Nameservers configured you can add the relevant config to your GCP stack file.

```yaml title:nitric.[stack ID].yaml
# Add to your stack file
cdn:
# The name of the DNS Zone you configured in Google Cloud DNS
zone-name: yourzone
# The domain name or subdomain you want to use for your website (any valid subdomain for the zone is permitted)
domain-name: app.example.com
```

<Note>
Missing something? Let us know by raising an issue in
[GitHub](https://github.com/nitrictech/nitric) or by dropping us a line on
Expand Down
12 changes: 12 additions & 0 deletions docs/providers/terraform/azure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ adminemail: [email protected]

# Subscription ID to associate deployed services with
subscription-id: example-subscription-id

# Add CDN configuration, required for custom domains for website deployments
# Available since v1.23.0
cdn:
# The name of the Azure DNS Zone to use when configuring the website DNS
zone-name: example.com
# The resource group name of the DNS Zone you configured in Azure DNS Zones
zone-resource-group: yourzone-rg
# A valid domain or subdomain for the DNS Zone to use for the deployed websites endpoint
domain-name: app.example.com
# Skip CDN cache invalidation during deployments (defaults to false)
skip-cache-invalidation: true
```
<Note>
Expand Down
15 changes: 15 additions & 0 deletions docs/providers/terraform/gcp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ gcp-project-id: my-gcp-project-id
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
schedule-timezone: Australia/Sydney

# Add CDN configuration, required for websites deployments
# Available since v1.22.0
cdn:
# The name of the Google Cloud DNS Zone to use when configuring the website DNS
zone-name: yourzone
# A valid subdomain for the DNS Zone to use for the deployed websites endpoint
domain-name: app.example.com
# The following configuration values are optional
# Specify the TTL the CDN sends in the Cache-Control or Expires headers to clients
client-ttl: 3600
# Specify the TTL for content cached by the CDN when the origin server does not provide any caching directives
default-ttl: 604800
# Skip CDN cache invalidation during deployments (defaults to false)
skip-cache-invalidation: true

# Configure your deployed services
config:
# How services without a type will be deployed
Expand Down
12 changes: 6 additions & 6 deletions docs/reference/preview-features/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Each preview feature will have its own documentation page, which will include in

## Current Preview Features

| Features | Preview Released | Feedback Issue |
| -------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [docker-providers](/providers/custom/docker) | CLI v1.39.0 | [feedback](https://github.com/nitrictech/nitric/issues/605) |
| [sql-databases](/sql) | CLI v1.42.0<br/>AWS Provider v1.6.0<br/>Azure Provider v1.9.0<br/>AWS Terraform Provider v1.8.0 | [feedback](https://github.com/nitrictech/nitric/issues/684) |
| [batch-services](/batch) | CLI v1.54.0<br/>AWS Provider v1.14.0<br/>GCP Provider v1.14.0 | [feedback](https://github.com/nitrictech/nitric/issues/685) |
| [websites](/websites) | CLI v1.58.0<br/>AWS Provider v1.18.0<br/>Azure Provider v1.19.4 | [feedback](https://github.com/nitrictech/nitric/issues/748) |
| Features | Preview Released | Feedback Issue |
| -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [docker-providers](/providers/custom/docker) | CLI v1.39.0 | [feedback](https://github.com/nitrictech/nitric/issues/605) |
| [sql-databases](/sql) | CLI v1.42.0<br/>AWS Provider v1.6.0<br/>Azure Provider v1.9.0<br/>AWS Terraform Provider v1.8.0 | [feedback](https://github.com/nitrictech/nitric/issues/684) |
| [batch-services](/batch) | CLI v1.54.0<br/>AWS Provider v1.14.0<br/>GCP Provider v1.14.0 | [feedback](https://github.com/nitrictech/nitric/issues/685) |
| [websites](/websites) | CLI v1.58.0<br/>AWS Provider v1.18.0<br/>Azure Provider v1.19.4<br/>GCP Provider v1.20.0<br/>Azure Terraform Provider v1.23.0<br/>GCP Terraform Provider v1.22.0 | [feedback](https://github.com/nitrictech/nitric/issues/748) |

## Released Preview Features

Expand Down
18 changes: 16 additions & 2 deletions docs/websites.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ If you're interested in the architecture, provisioning, or deployment steps, the
https://github.com/nitrictech/nitric/issues
</Note>

<Note>
When deploying website with the `nitric/gcp` provider a custom domain and DNS
zone will be required. See the [`nitric/gcp`
docs](/providers/pulumi/gcp#websites) for details.
</Note>

## Overview

Nitrics website resource lets you:
Nitric's website resource lets you:

- Serve static files (HTML, JS, CSS, images) from cloud storage.
- Serve your entire Nitric application from a single domain.
Expand Down Expand Up @@ -192,12 +198,20 @@ websites:
url: http://localhost:4322
```

## Custom Domains

You can configure a custom domain for your website by following the instructions in the cloud provider documentation:

- [AWS](/providers/pulumi/aws#websites)
- [Azure](/providers/pulumi/azure#websites)
- [Google Cloud](/providers/pulumi/gcp#websites)

## Cloud Service Mapping

Each cloud provider comes with a set of default services used when deploying resources. You can find the default services for each cloud provider below.

- [AWS](/providers/mappings/aws/websites)
- [Azure](/providers/mappings/azure/websites)
- Google Cloud - Not implemented
- [Google Cloud](/providers/mappings/gcp/websites)

If you need support for additional clouds or website types, let us know by [opening an issue](https://github.com/nitrictech/nitric/issues) or joining the conversation on [Discord](https://nitric.io/chat).
4 changes: 4 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ export const navigation: NavEntry[] = [
title: 'Schedules',
href: '/providers/mappings/gcp/schedules',
},
{
title: 'Websites',
href: '/providers/mappings/gcp/websites',
},
{
title: 'Storage',
href: '/providers/mappings/gcp/storage',
Expand Down
Loading