diff --git a/ts/pulumi/lib/website.ts b/ts/pulumi/lib/website.ts index dcc6b880cb..d54fd17989 100644 --- a/ts/pulumi/lib/website.ts +++ b/ts/pulumi/lib/website.ts @@ -34,6 +34,30 @@ function relative(from: string, to: string): string { return path.relative(f, t); } +// had to copy since not exported 😠 +export interface BucketWebsiteConfigurationV2RoutingRuleRedirect { + /** + * Host name to use in the redirect request. + */ + hostName?: pulumi.Input; + /** + * HTTP redirect code to use on the response. + */ + httpRedirectCode?: pulumi.Input; + /** + * Protocol to use when redirecting requests. The default is the protocol that is used in the original request. Valid values: `http`, `https`. + */ + protocol?: pulumi.Input; + /** + * Object key prefix to use in the redirect request. For example, to redirect requests for all pages with prefix `docs/` (objects in the `docs/` folder) to `documents/`, you can set a `condition` block with `keyPrefixEquals` set to `docs/` and in the `redirect` set `replaceKeyPrefixWith` to `/documents`. + */ + replaceKeyPrefixWith?: pulumi.Input; + /** + * Specific object key to use in the redirect request. For example, redirect request to `error.html`. + */ + replaceKeyWith?: pulumi.Input; +} + export interface Args { /** * Zone to create any needed DNS records in. @@ -82,6 +106,8 @@ export interface Args { * Whether to set up email for this website. */ email: boolean + + redirect?: pulumi.Input> } /** @@ -225,6 +251,15 @@ export class Website extends pulumi.ComponentResource { const s3Site = new aws.s3.BucketWebsiteConfigurationV2( `${name}_bucket_website`, { + routingRules: + pulumi.output(args.redirect).apply( + m => m == undefined ? [] : [...m].map(([from, to]) => ({ + condition: { + keyPrefixEquals: from + }, + redirect: to + })) + ), bucket: bucket.bucket, indexDocument: { suffix: "index.html" diff --git a/ts/pulumi/zemn.me/index.ts b/ts/pulumi/zemn.me/index.ts index 437ea7d022..0eff33085a 100644 --- a/ts/pulumi/zemn.me/index.ts +++ b/ts/pulumi/zemn.me/index.ts @@ -4,7 +4,7 @@ import * as Pulumi from '@pulumi/pulumi'; import { bskyDid } from '#root/project/zemn.me/bio/bio.js'; import { BlueskyDisplayNameClaim } from '#root/ts/pulumi/lib/bluesky_username_claim.js'; import { mergeTags, tagTrue } from '#root/ts/pulumi/lib/tags.js'; -import Website from '#root/ts/pulumi/lib/website.js'; +import Website, { BucketWebsiteConfigurationV2RoutingRuleRedirect } from '#root/ts/pulumi/lib/website.js'; export interface Args { zoneId: Pulumi.Input; @@ -59,6 +59,14 @@ export class Component extends Pulumi.ComponentResource { noIndex: true, // args.noIndex, email: false, tags, + redirect: new Map([ + ["/.well-known/host-meta", { + hostName: "fed.brid.gy", + }], + ["/.well-known/webfinger", { + hostName: "fed.brid.gy", + }] + ]) }, { parent: this } );