Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add staging.zemn.me #3115

Merged
merged 2 commits into from
May 23, 2023
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
1 change: 1 addition & 0 deletions ts/pulumi/me/zemn/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ ts_project(
"//:node_modules/@pulumi/aws",
"//:node_modules/@pulumi/pulumi",
"//ts/pulumi/me/zemn/zone",
"//ts/pulumi/me/zemn/staging",
],
)
1 change: 1 addition & 0 deletions ts/pulumi/me/zemn/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * as staging from 'ts/pulumi/me/zemn/staging';
export * as zone from 'ts/pulumi/me/zemn/zone';
16 changes: 16 additions & 0 deletions ts/pulumi/me/zemn/staging/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("//ts:rules.bzl", "ts_project")
load("//ts/next.js:rules.bzl", "next_project")

package(default_visibility = ["//visibility:public"])

ts_project(
name = "staging",
data = ["//ts/pulumi/me/zemn/staging/public:public_next"],
deps = [
"//:node_modules/@pulumi/aws-static-website",
"//:node_modules/@pulumi/pulumi",
"//:node_modules/@pulumi/aws",
"//ts/pulumi/me/zemn/zone"
],
assets = glob(["**/*.css"])
)
58 changes: 58 additions & 0 deletions ts/pulumi/me/zemn/staging/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import * as aws from '@pulumi/aws';
import * as staticwebsite from '@pulumi/aws-static-website';
import * as pulumi from '@pulumi/pulumi';
import * as asset from '@pulumi/pulumi/asset';
import * as zone from 'ts/pulumi/me/zemn/zone';

const domainName = pulumi.interpolate`staging.${zone.zone.name}`;

export const cert = new aws.acm.Certificate('staging.zemn.me_cert', {
domainName: domainName,
validationMethod: 'DNS',
});

const second = 1;
const minute = 60 * second;

// this code seems stupid but you can't iterate over a list
// in pulumi outputs so it's necessary.

// NB: number of validations is the number of domains https://github.com/pulumi/pulumi/issues/5736#issuecomment-725767836

const record = (
name: string,
validation: pulumi.Output<aws.types.output.acm.CertificateDomainValidationOption>
) =>
new aws.route53.Record(name, {
name: validation.resourceRecordName,
records: [validation.resourceRecordValue],
type: validation.resourceRecordType,
zoneId: zone.zone.zoneId,
ttl: 1 * minute, // because these really don't need to be cached
});

export const validation0 = record(
'cert_validation_0',
cert.domainValidationOptions[0]
);

export const validation = new aws.acm.CertificateValidation('cert-validation', {
certificateArn: cert.arn,
validationRecordFqdns: [validation0.fqdn],
});

// should use this one because it waits for the certificate to actualy be validated
export const arn = validation.certificateArn;

export const site = new staticwebsite.Website('staging.zemn.me', {
withCDN: true,
indexHTML: new asset.FileAsset(
'ts/pulumi/me/zemn/staging/public/out/index.html'
).path,
error404: new asset.FileAsset(
'ts/pulumi/me/zemn/staging/public/out/404.html'
).path,
sitePath: 'ts/pulumi/me/zemn/staging/public/out',
targetDomain: 'staging.zemn.me',
certificateARN: arn,
});
21 changes: 21 additions & 0 deletions ts/pulumi/me/zemn/staging/public/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

load("//ts:rules.bzl", "ts_project")
load("//ts/next.js:rules.bzl", "next_project")

package(default_visibility = ["//visibility:public"])

ts_project(
name = "public",
deps = [
"//:node_modules/@types/react",
"//:node_modules/next",
"//:node_modules/react",
"//ts/next.js"
],
assets = glob(["**/*.css"])
)

next_project(
name = "public_next",
srcs = [":public"],
)
13 changes: 13 additions & 0 deletions ts/pulumi/me/zemn/staging/public/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { AppProps } from 'next/app';
import { HeaderTags } from 'ts/next.js';

export function App({ Component, pageProps }: AppProps) {
return (
<>
<HeaderTags />
<Component {...pageProps} />
</>
);
}

export default App;
14 changes: 14 additions & 0 deletions ts/pulumi/me/zemn/staging/public/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Head from 'next/head';

export default function Main() {
return (
<>
<Head>
<title>zemn.me</title>
</Head>

<p>This is the staging site for zemn.me! </p>
<p>I am excited to see it work!</p>
</>
);
}