feat : add chesskit domain
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -22,3 +22,4 @@ tsconfig.tsbuildinfo
|
|||||||
# CDK asset staging directory
|
# CDK asset staging directory
|
||||||
.cdk.staging
|
.cdk.staging
|
||||||
cdk.out
|
cdk.out
|
||||||
|
cdk.context.json
|
||||||
|
|||||||
@@ -13,10 +13,18 @@ import {
|
|||||||
Source,
|
Source,
|
||||||
} from "aws-cdk-lib/aws-s3-deployment";
|
} from "aws-cdk-lib/aws-s3-deployment";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { ARecord, HostedZone, RecordTarget } from "aws-cdk-lib/aws-route53";
|
||||||
|
import { CloudFrontTarget } from "aws-cdk-lib/aws-route53-targets";
|
||||||
|
import { DnsValidatedCertificate } from "aws-cdk-lib/aws-certificatemanager";
|
||||||
|
|
||||||
|
interface AppStackProps extends cdk.StackProps {
|
||||||
|
domainName: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class AppStack extends cdk.Stack {
|
export class AppStack extends cdk.Stack {
|
||||||
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
|
constructor(scope: Construct, id: string, props: AppStackProps) {
|
||||||
super(scope, id, props);
|
super(scope, id, props);
|
||||||
|
const { domainName } = props;
|
||||||
|
|
||||||
const bucket = new Bucket(this, "Bucket", {
|
const bucket = new Bucket(this, "Bucket", {
|
||||||
accessControl: BucketAccessControl.PRIVATE,
|
accessControl: BucketAccessControl.PRIVATE,
|
||||||
@@ -82,7 +90,17 @@ export class AppStack extends cdk.Stack {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
new Distribution(this, "Distribution", {
|
const hostedZone = HostedZone.fromLookup(this, "HostedZone", {
|
||||||
|
domainName,
|
||||||
|
});
|
||||||
|
|
||||||
|
const certificate = new DnsValidatedCertificate(this, "Certificate", {
|
||||||
|
domainName,
|
||||||
|
hostedZone,
|
||||||
|
region: "us-east-1",
|
||||||
|
});
|
||||||
|
|
||||||
|
const distribution = new Distribution(this, "Distribution", {
|
||||||
defaultRootObject: "index.html",
|
defaultRootObject: "index.html",
|
||||||
errorResponses: [
|
errorResponses: [
|
||||||
{
|
{
|
||||||
@@ -100,6 +118,15 @@ export class AppStack extends cdk.Stack {
|
|||||||
origin: originAccessControl,
|
origin: originAccessControl,
|
||||||
responseHeadersPolicy,
|
responseHeadersPolicy,
|
||||||
},
|
},
|
||||||
|
domainNames: [domainName],
|
||||||
|
certificate,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
new ARecord(this, "AliasRecord", {
|
||||||
|
zone: hostedZone,
|
||||||
|
target: RecordTarget.fromAlias(new CloudFrontTarget(distribution)),
|
||||||
|
});
|
||||||
|
|
||||||
|
new cdk.CfnOutput(this, "SiteUrl", { value: `https://${domainName}` });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,5 +4,6 @@ import { AppStack } from "./app-stack";
|
|||||||
const app = new cdk.App();
|
const app = new cdk.App();
|
||||||
|
|
||||||
new AppStack(app, "FreechessWebapp", {
|
new AppStack(app, "FreechessWebapp", {
|
||||||
env: { region: "eu-west-3" },
|
env: { region: "eu-west-3", account: process.env.CDK_DEFAULT_ACCOUNT },
|
||||||
|
domainName: "chesskit.org",
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user