@astro-aws/constructs
TypeScript icon, indicating that this package has built-in type declarations

0.6.0 • Public • Published

@astro-aws/constructs

Constructs for deploying your Astro project that is built using @astro-aws/adapter.

Usage

  1. 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
  1. 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

Package Sidebar

Install

npm i @astro-aws/constructs

Weekly Downloads

3

Version

0.6.0

License

MIT

Unpacked Size

29.6 kB

Total Files

18

Last publish

Collaborators

  • lukeshay