The CDK Construct Library of Astro
Project description
Astro Construct Library
---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
For developing, it's not recommended to deploy with CloudFront, because setup CloudFront is really too slow, at least takes 5min.
from astrojs_aws.construct import StaticAstroSite
site = StaticAstroSite(self, "Site",
site_dir="/path/to/dist"
)
CfnOutput(self, "Domains",
value=site.domains.join(", ")
)
It's recommended to deploy with CloudFront in production environment.
from astrojs_aws.construct import StaticAstroSite
site = StaticAstroSite(self, "Site",
site_dir="/path/to/dist",
cf_options=CfOptions(
domain="example.com",
certificate_arn="arn:aws:acm:us-east-1:xxx-xxx-xxx"
)
)
CfnOutput(self, "Domains",
value=site.domains.join(", ")
)
Lambda Hosting
from astrojs_aws.construct import LambdaAstroSite
site = LambdaAstroSite(self, "Site",
server_entry="/path/to/server/entry.mjs",
static_dir="/path/to/client"
)
CfnOutput(self, "Domains",
value=site.domains.join(", ")
)
Deploy with CloudFront.
from astrojs_aws.construct import LambdaAstroSite
site = LambdaAstroSite(self, "Site",
server_entry="/path/to/server/entry.mjs",
static_dir="/path/to/client",
cf_options=CfOptions(
domain="example.com",
certificate_arn="arn:aws:acm:us-east-1:xxx-xxx-xxx"
)
)
CfnOutput(self, "Domains",
value=site.domains.join(", ")
)
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.
from astrojs_aws.construct import EdgeAstroSite
EdgeAstroSite(self, "Site",
server_entry="/path/to/server/entry.mjs",
static_dir="/path/to/client",
only_lambda=True
)
Deploy to production environment.
from astrojs_aws.construct import EdgeAstroSite
site = EdgeAstroSite(self, "Site",
server_entry="/path/to/server/entry.mjs",
static_dir="/path/to/client",
cf_options=CfOptions(
domain="example.com",
certificate_arn="arn:aws:acm:us-east-1:xxx-xxx-xxx"
)
)
CfnOutput(self, "Domains",
value=site.domains.join(", ")
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file astrojs-aws.construct-0.0.20.tar.gz
.
File metadata
- Download URL: astrojs-aws.construct-0.0.20.tar.gz
- Upload date:
- Size: 67.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72a86956c2458910c3cdf564e72aa28f42aa40ddd1a26adff12c88bdb2c41b1c |
|
MD5 | 15644a039ea5ab2f7f96c3813a1d40b5 |
|
BLAKE2b-256 | 07879ff05f0266011a3a25f6470f5cd30c82fe8d041eb9ec11be778abbad1aaf |
File details
Details for the file astrojs_aws.construct-0.0.20-py3-none-any.whl
.
File metadata
- Download URL: astrojs_aws.construct-0.0.20-py3-none-any.whl
- Upload date:
- Size: 65.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cc3635e33b416eee66a06df048b26f5d7b5e1f45e4cae8524aa779aa8c4ded7 |
|
MD5 | 92093c2519adaf962fc1ae468084c164 |
|
BLAKE2b-256 | 0b01e5df7b41be56f1d881f55e0ff2c92069e6cf0dc9a2d0efef8e674a4293c1 |