Host static websites on a shared CloudFront distribution.
import { SharedStaticWebsiteHosting } from '@scaleleap/cdk-shared-static-website-hosting'
new SharedStaticWebsiteHosting(scope: Construct, id: string, props: SharedStaticWebsiteHostingProps)
Name | Type | Description |
---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
SharedStaticWebsiteHostingProps |
No description. |
- Type: constructs.Construct
- Type: string
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
public toString(): string
Returns a string representation of this construct.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
import { SharedStaticWebsiteHosting } from '@scaleleap/cdk-shared-static-website-hosting'
SharedStaticWebsiteHosting.isConstruct(x: any)
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
- Type: any
Any object.
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
bucket |
aws-cdk-lib.aws_s3.IBucket |
Bucket where the static files are stored. |
distribution |
aws-cdk-lib.aws_cloudfront.IDistribution |
CloudFront distribution. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
public readonly bucket: IBucket;
- Type: aws-cdk-lib.aws_s3.IBucket
Bucket where the static files are stored.
public readonly distribution: IDistribution;
- Type: aws-cdk-lib.aws_cloudfront.IDistribution
CloudFront distribution.
import { SharedStaticWebsiteHostingProps } from '@scaleleap/cdk-shared-static-website-hosting'
const sharedStaticWebsiteHostingProps: SharedStaticWebsiteHostingProps = { ... }
Name | Type | Description |
---|---|---|
hostedZone |
aws-cdk-lib.aws_route53.IHostedZone |
A hosted zone that is open for modification by the construct. |
bucket |
aws-cdk-lib.aws_s3.IBucket |
An S3 bucket where the static files will be stored. |
public readonly hostedZone: IHostedZone;
- Type: aws-cdk-lib.aws_route53.IHostedZone
A hosted zone that is open for modification by the construct.
This construct will add a wildcard A record that points to the CloudFront distribution.
public readonly bucket: IBucket;
- Type: aws-cdk-lib.aws_s3.IBucket
- Default: A new bucket will be created, if not provided.
An S3 bucket where the static files will be stored.
This construct assumes full control of the bucket.