Skip to content

Latest commit

 

History

History
376 lines (203 loc) · 11.7 KB

API.md

File metadata and controls

376 lines (203 loc) · 11.7 KB

API Reference

Constructs

StaticWebSite

Construct to create static web site with TLS certificate.

The web site is hosted using AWS S3 bucket and CloudFront distribution.

Initializer

import { StaticWebSite } from 'aws-cdk-static-https-site'

new StaticWebSite(scope: Construct, id: string, props: StaticWebSiteProps)
scopeRequired

Scope where the site is created, e.g. stack.


idRequired
  • Type: string

Construct id.


propsRequired

Properties.


Properties

bucketRequired

Reference to S3 bucket holding the static web site.


distributionRequired

Reference to CloudFront distribution.


distributionDomainRequired
  • 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.


siteDomainRequired
  • Type: string

Domain name of the site (eg.

www.example.org or example.org)


certificateOptional

Reference to created certificate.


hostedZoneOptional

Reference to hosted zone.


redirectedDomainOptional
  • 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.


redirectionBucketOptional

Reference to S3 bucket created for redirection of secondary domain.


redirectionDistributionOptional

Reference to CloudFront distribution created for redirection of secondary domain.


redirectionDistributionDomainOptional
  • Type: string

Domain name of the CloudFront distribution (e.g. abc123defghij.cloudfront.net) created to redirect secondary domain to primary domain.


Structs

StaticWebSiteProps

Properties of static web site.

Initializer

import { StaticWebSiteProps } from 'aws-cdk-static-https-site'

const staticWebSiteProps: StaticWebSiteProps = { ... }
analyticsReportingOptional
  • Type: boolean
  • Default: analyticsReporting setting of containing App, or value of 'aws:cdk:version-reporting' context key

Include runtime versioning information in this Stack.


descriptionOptional
  • Type: string
  • Default: No description.

A description of the stack.


envOptional
  • 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.


stackNameOptional
  • Type: string
  • Default: Derived from construct path.

Name to deploy the stack with.


synthesizerOptional
  • 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.


tagsOptional
  • Type: {[ key: string ]: string}
  • Default: {}

Stack tags that will be applied to all the taggable resources and the stack itself.


terminationProtectionOptional
  • Type: boolean
  • Default: false

Whether to enable termination protection for this stack.


rootDomainRequired
  • Type: string

Root domain of the web site, e.g. "example.org".


siteContentsPathRequired
  • Type: string

Local path where are files of the the static web site stored.


certificateArnOptional
  • 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.


certificateValidationOptional

Choose validation type for creating new certificate.

It is not used when using Route 53 (useRoute53 is true).


createWildcardCertificateOptional
  • Type: boolean
  • Default: false

Create wildcard certificate for the sub-domain, e.g. *.example.org.


defaultRootObjectOptional
  • 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.


primaryDomainOptional

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


redirectSecondaryDomainOptional
  • Type: boolean
  • Default: false

Redirect secondary domain to the primary domain.


siteSubDomainOptional
  • Type: string

Sub domain of the web site e.g. "www".


useRoute53Optional
  • Type: boolean
  • Default: true

Use Route 53 hosted zone.


websiteErrorDocumentOptional
  • Type: string
  • Default: : undefined

File name of the error 404 document of the web site.


websiteIndexDocumentOptional
  • Type: string
  • Default: : 'index.html'

File name of the main index document of the web site.


Enums

StaticWebSiteCertificateValidation

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.

FROM_DNS


FROM_EMAIL


StaticWebSitePrimaryDomain

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.

ROOT_DOMAIN


SUB_DOMAIN