Construct to create static web site with TLS certificate.
The web site is hosted using AWS S3 bucket and CloudFront distribution.
import { StaticWebSite } from 'aws-cdk-static-https-site'
new StaticWebSite(scope: Construct, id: string, props: StaticWebSiteProps)
- Type:
@aws-cdk/core.Construct
Scope where the site is created, e.g. stack.
- Type:
string
Construct id.
Properties.
- Type:
@aws-cdk/aws-s3.Bucket
Reference to S3 bucket holding the static web site.
Reference to CloudFront distribution.
- Type:
string
Domain name of the CloudFront distribution (e.g. abc123defghij.cloudfront.net). When not using the Route 53 hosted zone, this domain can be set as CNAME for the domain to redirect to the distribution.
- Type:
string
Domain name of the site (eg.
www.example.org or example.org)
Reference to created certificate.
Reference to hosted zone.
- Type:
string
Domain name of the redirected secondary domain (e.g. example.org). Depends on property primaryDomain. It is undefined if property redirectSecondaryDomain is false.
- Type:
@aws-cdk/aws-s3.Bucket
Reference to S3 bucket created for redirection of secondary domain.
Reference to CloudFront distribution created for redirection of secondary domain.
- Type:
string
Domain name of the CloudFront distribution (e.g. abc123defghij.cloudfront.net) created to redirect secondary domain to primary domain.
Properties of static web site.
import { StaticWebSiteProps } from 'aws-cdk-static-https-site'
const staticWebSiteProps: StaticWebSiteProps = { ... }
- Type:
boolean
- Default:
analyticsReporting
setting of containingApp
, or value of 'aws:cdk:version-reporting' context key
Include runtime versioning information in this Stack.
- Type:
string
- Default: No description.
A description of the stack.
- Type:
@aws-cdk/core.Environment
- Default: The environment of the containing
Stage
if available, otherwise create the stack will be environment-agnostic.
The AWS environment (account/region) where this stack will be deployed.
Set the region
/account
fields of env
to either a concrete value to
select the indicated environment (recommended for production stacks), or to
the values of environment variables
CDK_DEFAULT_REGION
/CDK_DEFAULT_ACCOUNT
to let the target environment
depend on the AWS credentials/configuration that the CDK CLI is executed
under (recommended for development stacks).
If the Stack
is instantiated inside a Stage
, any undefined
region
/account
fields from env
will default to the same field on the
encompassing Stage
, if configured there.
If either region
or account
are not set nor inherited from Stage
, the
Stack will be considered "environment-agnostic"". Environment-agnostic
stacks can be deployed to any environment but may not be able to take
advantage of all features of the CDK. For example, they will not be able to
use environmental context lookups such as ec2.Vpc.fromLookup
and will not
automatically translate Service Principals to the right format based on the
environment's AWS partition, and other such enhancements.
- Type:
string
- Default: Derived from construct path.
Name to deploy the stack with.
- Type:
@aws-cdk/core.IStackSynthesizer
- Default:
DefaultStackSynthesizer
if the@aws-cdk/core:newStyleStackSynthesis
feature flag is set,LegacyStackSynthesizer
otherwise.
Synthesis method to use while deploying this stack.
- Type: {[ key: string ]:
string
} - Default: {}
Stack tags that will be applied to all the taggable resources and the stack itself.
- Type:
boolean
- Default: false
Whether to enable termination protection for this stack.
- Type:
string
Root domain of the web site, e.g. "example.org".
- Type:
string
Local path where are files of the the static web site stored.
- Type:
string
ARN of the existing certificate.
Unless using Route 53, it is recommended to create certificate manually in AWS Console and pass it's ARN in this parameter. If certificateArn is not defined then the certificate is created and validated depending on certificateValidation parameter.
- Type:
aws-cdk-static-https-site.StaticWebSiteCertificateValidation
- Default: StaticWebSiteCertificateValidation.FROM_EMAIL
Choose validation type for creating new certificate.
It is not used when using Route 53 (useRoute53 is true).
- Type:
boolean
- Default: false
Create wildcard certificate for the sub-domain, e.g. *.example.org.
- Type:
string
- Default: ''
Defines defaultRootObject of the CloudFront distribution.
The object (file name) to return when a viewer requests the root URL (/) instead of a specific object.
By default the CloudFront uses index.html, however it is better to leave it empty and let S3 bucket to choose the right root document. Therefore the StaticWebSite is using empty string as defaultRootObject.
- Type:
aws-cdk-static-https-site.StaticWebSitePrimaryDomain
- Default: StaticWebSitePrimaryDomain.SUB_DOMAIN.
Which domain is the primary domain for the web site - the root domain (e.g. example.org) or the sub domain (e.g. www.example.org).
- Type:
boolean
- Default: false
Redirect secondary domain to the primary domain.
- Type:
string
Sub domain of the web site e.g. "www".
- Type:
boolean
- Default: true
Use Route 53 hosted zone.
- Type:
string
- Default: : undefined
File name of the error 404 document of the web site.
- Type:
string
- Default: : 'index.html'
File name of the main index document of the web site.
Type of certificate validation (not used if using Route 53) If hosted zone is not available then a certificate can be created using DNS or EMAIL validation.
Specification which of root domain / sub domain is primarilly used to host the static web site.
The other domain can be optionally redirected to the primary domain.