@astro-aws/constructs
v0.7.0
Published
Constructs for deploying an Astro application to AWS Lambda
Downloads
36
Maintainers
Readme
@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 NPM
npm install @astro-aws/constructs constructs aws-cdk-lib
# Using Yarn
yarn add @astro-aws/constructs constructs aws-cdk-lib
# Using PNPM
pnpm add @astro-aws/constructs constructs aws-cdk-lib
# Using Bun
bun 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,
})
}
}