JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q35592F
  • License MIT

The CDK Construct Library of Astro

Package Exports

  • @astrojs-aws/construct
  • @astrojs-aws/construct/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@astrojs-aws/construct) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Astro Construct Library


cdk-constructs: Experimental

The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


Introduction

Astro is the all-in-one web framework designed for speed. This library is supported modes, static, lambda and edge, to deploy astro website to AWS.

Usage

Static Hosting

Static Hosting

For developing, it's not recommended to deploy with CloudFront, because setup CloudFront is really too slow, at least takes 5min.

import { StaticAstroSite } from "@astrojs-aws/construct"

const site = new StaticAstroSite(this, "Site", {
  siteDir: "/path/to/dist",
})

new CfnOutput(this, "Domains", {
  value: site.domains.join(", "),
})

It's recommended to deploy with CloudFront in production environment.

import { StaticAstroSite } from "@astrojs-aws/construct"

const site = new StaticAstroSite(this, "Site", {
  siteDir: "/path/to/dist",
  cfOptions: {
    domain: "example.com",
    certificateArn: "arn:aws:acm:us-east-1:xxx-xxx-xxx",
  },
})

new CfnOutput(this, "Domains", {
  value: site.domains.join(", "),
})

Lambda Hosting

Lambda Hosting

import { LambdaAstroSite } from "@astrojs-aws/construct"

const site = new LambdaAstroSite(this, "Site", {
  serverEntry: "/path/to/server/entry.mjs",
  staticDir: "/path/to/client",
})

new CfnOutput(this, "Domains", {
  value: site.domains.join(", "),
})

Deploy with CloudFront.

import { LambdaAstroSite } from "@astrojs-aws/construct"

const site = new LambdaAstroSite(this, "Site", {
  serverEntry: "/path/to/server/entry.mjs",
  staticDir: "/path/to/client",
  cfOptions: {
    domain: "example.com",
    certificateArn: "arn:aws:acm:us-east-1:xxx-xxx-xxx",
  },
})

new CfnOutput(this, "Domains", {
  value: site.domains.join(", "),
})

Edge Hosting

Edge Hosting

As we known that, edge function working in Edge node. But for developing, setup CloudFront is really too slow. We can only deploy the Lambda function, and use AWS SAM for testing and debuging.

import { EdgeAstroSite } from "@astrojs-aws/construct"

new EdgeAstroSite(this, "Site", {
  serverEntry: "/path/to/server/entry.mjs",
  staticDir: "/path/to/client",
  onlyLambda: true,
})

Deploy to production environment.

import { EdgeAstroSite } from "@astrojs-aws/construct"

const site = new EdgeAstroSite(this, "Site", {
  serverEntry: "/path/to/server/entry.mjs",
  staticDir: "/path/to/client",
  cfOptions: {
    domain: "example.com",
    certificateArn: "arn:aws:acm:us-east-1:xxx-xxx-xxx",
  },
})

new CfnOutput(this, "Domains", {
  value: site.domains.join(", "),
})