Skip to content

Commit

Permalink
format and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshay committed Nov 17, 2023
1 parent 2f4c125 commit 10bfacd
Show file tree
Hide file tree
Showing 6 changed files with 6,251 additions and 2,573 deletions.
8 changes: 4 additions & 4 deletions apps/infra/cdk.context.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hosted-zone:account=738697399292:domainName=astro-aws.org:region=us-east-1": {
"Id": "/hostedzone/Z0584480MGUI8KRBPWM",
"Name": "astro-aws.org."
}
"hosted-zone:account=738697399292:domainName=astro-aws.org:region=us-east-1": {
"Id": "/hostedzone/Z0584480MGUI8KRBPWM",
"Name": "astro-aws.org."
}
}
17 changes: 7 additions & 10 deletions apps/infra/src/bin/infra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Environments,
ENVIRONMENT_PROPS,
} from "../lib/constants/environments.js"
import { MonitoringStack } from "../lib/stacks/monitoring-stack.js"
import { WebsiteStack } from "../lib/stacks/website-stack.js"
import { CertificateStack } from "../lib/stacks/certificate-stack.js"
import { GitHubOIDCStack } from "../lib/stacks/github-oidc-stack.js"
Expand All @@ -20,12 +19,6 @@ const createStackName = (
) => ["AstroAWS", environment, stack, runtime, mode].filter(Boolean).join("-")

Object.entries(ENVIRONMENT_PROPS).forEach(([environment, environmentProps]) => {
const monitoringStack = new MonitoringStack(
app,
createStackName(environment, "Monitoring"),
environmentProps,
)

environmentProps.websites.forEach((websiteProps) => {
let certificateStack: CertificateStack | undefined

Expand All @@ -42,7 +35,7 @@ Object.entries(ENVIRONMENT_PROPS).forEach(([environment, environmentProps]) => {
createStackName(
environment,
"Certificate",
"nodejs18",
websiteProps.runtime,
websiteProps.mode,
),
{
Expand All @@ -55,12 +48,16 @@ Object.entries(ENVIRONMENT_PROPS).forEach(([environment, environmentProps]) => {

new WebsiteStack(
app,
createStackName(environment, "Website", "nodejs18", websiteProps.mode),
createStackName(
environment,
"Website",
websiteProps.runtime,
websiteProps.mode,
),
{
...environmentProps,
...websiteProps,
certificate: certificateStack?.certificate,
cloudwatchDashboard: monitoringStack.cloudwatchDashboard,
hostedZone: certificateStack?.hostedZone,
},
)
Expand Down
35 changes: 32 additions & 3 deletions apps/infra/src/lib/constants/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,57 @@ const ENVIRONMENT_PROPS: Record<Environment, EnvironmentProps> = {
hostedZoneName: "astro-aws.org",
mode: "static",
package: "@astro-aws/docs",
runtime: "nodejs20",
},
{
aliases: ["www.ssr.dev", "ssr.dev"],
aliases: ["www.ssr.nodejs18.dev", "ssr.nodejs18.dev"],
hostedZoneName: "astro-aws.org",
mode: "ssr",
package: "@astro-aws/examples-base",
runtime: "nodejs18",
},
{
aliases: ["www.stream.dev", "stream.dev"],
aliases: ["www.stream.nodejs18.dev", "stream.nodejs18.dev"],
hostedZoneName: "astro-aws.org",
mode: "ssr-stream",
package: "@astro-aws/examples-base",
runtime: "nodejs18",
},
{
aliases: ["www.edge.dev", "edge.dev"],
aliases: ["www.edge.nodejs18.dev", "edge.nodejs18.dev"],
env: {
...base.env,
region: "us-east-1",
},
hostedZoneName: "astro-aws.org",
mode: "edge",
package: "@astro-aws/examples-base",
runtime: "nodejs18",
},
{
aliases: ["www.ssr.nodejs20.dev", "ssr.nodejs20.dev"],
hostedZoneName: "astro-aws.org",
mode: "ssr",
package: "@astro-aws/examples-base",
runtime: "nodejs20",
},
{
aliases: ["www.stream.nodejs20.dev", "stream.nodejs20.dev"],
hostedZoneName: "astro-aws.org",
mode: "ssr-stream",
package: "@astro-aws/examples-base",
runtime: "nodejs20",
},
{
aliases: ["www.edge.nodejs20.dev", "edge.nodejs20.dev"],
env: {
...base.env,
region: "us-east-1",
},
hostedZoneName: "astro-aws.org",
mode: "edge",
package: "@astro-aws/examples-base",
runtime: "nodejs20",
},
],
},
Expand Down
8 changes: 4 additions & 4 deletions apps/infra/src/lib/stacks/website-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ type StaticWebsiteStackProps = {
aliases?: readonly [string, ...string[]]
mode: string
hostedZoneName?: string
runtime?: string
package: string
runtime: string
}

type WebsiteStackProps = AstroAWSStackProps &
StaticWebsiteStackProps & {
cloudwatchDashboard: Dashboard
cloudwatchDashboard?: Dashboard
certificate?: Certificate
hostedZone?: IHostedZone
}
Expand All @@ -57,7 +57,7 @@ class WebsiteStack extends Stack {
environment,
hostedZone,
hostedZoneName,
runtime = "nodejs18",
runtime,
} = props

const distDir = mode === "static" ? "dist" : `dist/${mode}`
Expand Down Expand Up @@ -220,7 +220,7 @@ class WebsiteStack extends Stack {
)
}

cloudwatchDashboard.addWidgets(...widgets)
cloudwatchDashboard?.addWidgets(...widgets)

new CfnOutput(this, "CloudFrontDistributionId", {
value: astroAwsConstruct.cdk.cloudfrontDistribution.distributionId,
Expand Down
Loading

0 comments on commit 10bfacd

Please sign in to comment.