@astro-aws/constructs
Constructs for deploying your Astro project that is built using @astro-aws/adapter.
Usage
- Install this package and it’s peer dependencies in your AWS CDK project.
# Using NPMnpm install @astro-aws/constructs constructs aws-cdk-lib
# Using Yarnyarn add @astro-aws/constructs constructs aws-cdk-lib
# Using PNPMpnpm add @astro-aws/constructs constructs aws-cdk-lib
# Using Bunbun add @astro-aws/constructs constructs aws-cdk-lib
- Add the construct to your CDK stack.
import { Stack } from "aws-cdk-lib/core"import type { StackProps } from "aws-cdk-lib/core"import { AstroAWS } from "@astro-aws/constructs"
export interface MyAstroStackProps extends StackProps {}
export class MyAstroStack extends Stack { public constructor(scope: Construct, id: string, props: MyAstroStackProps) { super(scope, id, props)
new AstroAWS(this, "AstroAWS", { websitePath: "..", // Replace with the path to your website code. }) }}
Customization
All the resources created by the AstroAWS
construct can be customized. We expose every prop of the resources that is customizable. The props can be set by passing them in to the cdk
field on the AstroAWS
construct props. Depending on the deployment method, not all of the props will be used. The constructed can be access through the cdk
field on the AstroAWS
construct object.
import { Stack, CfnOutput } from "aws-cdk-lib/core"import type { StackProps } from "aws-cdk-lib/core"import { AstroAWS } from "@astro-aws/constructs"
export interface MyAstroStackProps extends StackProps {}
export class MyAstroStack extends Stack { public constructor(scope: Construct, id: string, props: MyAstroStackProps) { super(scope, id, props)
const astroAWS = new AstroAWS(this, "AstroAWS", { cdk: { lambdaFunction: { memorySize: 1024, }, }, websitePath: "..", // Replace with the path to your website code. })
new CfnOutput(this, "DistributionDomainName", { value: astroAWS.cdk.cloudfrontDistribution.distributionDomainName, }) }}
Example
See the source code of this site
More
For more information, see the documentation website