diff --git a/dictionary.txt b/dictionary.txt index ed814eeea..e7a85b814 100644 --- a/dictionary.txt +++ b/dictionary.txt @@ -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+) diff --git a/docs/architecture/websites.mdx b/docs/architecture/websites.mdx index 7b3016d43..c954a627f 100644 --- a/docs/architecture/websites.mdx +++ b/docs/architecture/websites.mdx @@ -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) diff --git a/docs/providers/index.mdx b/docs/providers/index.mdx index 91b1605f5..b73dd646c 100644 --- a/docs/providers/index.mdx +++ b/docs/providers/index.mdx @@ -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 | diff --git a/docs/providers/mappings/gcp/websites.mdx b/docs/providers/mappings/gcp/websites.mdx new file mode 100644 index 000000000..a88e0859b --- /dev/null +++ b/docs/providers/mappings/gcp/websites.mdx @@ -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 diff --git a/docs/providers/pulumi/gcp.mdx b/docs/providers/pulumi/gcp.mdx index a9689a29b..d48844fd5 100644 --- a/docs/providers/pulumi/gcp.mdx +++ b/docs/providers/pulumi/gcp.mdx @@ -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 @@ -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: + +Substitute your values for `Host` and `Nameserver` + +| 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 | + + + If you enabled DNSSEC for the zone you will also need to create the relevant + DS record + + +### 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 +``` + Missing something? Let us know by raising an issue in [GitHub](https://github.com/nitrictech/nitric) or by dropping us a line on diff --git a/docs/providers/terraform/azure.mdx b/docs/providers/terraform/azure.mdx index d713c14e9..a61fa05d1 100644 --- a/docs/providers/terraform/azure.mdx +++ b/docs/providers/terraform/azure.mdx @@ -110,6 +110,18 @@ adminemail: test@example.com # 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 ``` diff --git a/docs/providers/terraform/gcp.mdx b/docs/providers/terraform/gcp.mdx index 2cb4fd6c0..a43a7c38f 100644 --- a/docs/providers/terraform/gcp.mdx +++ b/docs/providers/terraform/gcp.mdx @@ -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 diff --git a/docs/reference/preview-features/index.mdx b/docs/reference/preview-features/index.mdx index 250bc9a91..720b3909c 100644 --- a/docs/reference/preview-features/index.mdx +++ b/docs/reference/preview-features/index.mdx @@ -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
AWS Provider v1.6.0
Azure Provider v1.9.0
AWS Terraform Provider v1.8.0 | [feedback](https://github.com/nitrictech/nitric/issues/684) | -| [batch-services](/batch) | CLI v1.54.0
AWS Provider v1.14.0
GCP Provider v1.14.0 | [feedback](https://github.com/nitrictech/nitric/issues/685) | -| [websites](/websites) | CLI v1.58.0
AWS Provider v1.18.0
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
AWS Provider v1.6.0
Azure Provider v1.9.0
AWS Terraform Provider v1.8.0 | [feedback](https://github.com/nitrictech/nitric/issues/684) | +| [batch-services](/batch) | CLI v1.54.0
AWS Provider v1.14.0
GCP Provider v1.14.0 | [feedback](https://github.com/nitrictech/nitric/issues/685) | +| [websites](/websites) | CLI v1.58.0
AWS Provider v1.18.0
Azure Provider v1.19.4
GCP Provider v1.20.0
Azure Terraform Provider v1.23.0
GCP Terraform Provider v1.22.0 | [feedback](https://github.com/nitrictech/nitric/issues/748) | ## Released Preview Features diff --git a/docs/websites.mdx b/docs/websites.mdx index c393bbc09..764947847 100644 --- a/docs/websites.mdx +++ b/docs/websites.mdx @@ -14,9 +14,15 @@ If you're interested in the architecture, provisioning, or deployment steps, the https://github.com/nitrictech/nitric/issues
+ + 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. + + ## Overview -Nitric’s 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. @@ -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). diff --git a/src/config/index.ts b/src/config/index.ts index 2d3cfebb3..07326f2cb 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -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',