Package: mbonig.cicd-spa-website
SPA + CICD Website ConstructThis CDK construct is used to create a static website with a CodePipeline to deploy
from source code on pushes tomaster. The goal of this construct is to be able to
point it at a git repository, give it a url,
and you've got a continuously deployed static website.This is a pre-release!This is a quick first-draft. All the options that will likely need to be added to accomodate a large
number of use-cases are still needed. If you'd like to make requests or help update this construct, please
open anIssueor aPR.What Gets CreatedAt the base level, the following will be built:An S3 bucket for build artifactsAn S3 bucket for the website contentCICD Pipeline - CodePipeline sourced from Github, built using CodeBuild and deployed to an S3 bucket.If a certificate is supplied or requested:An ACM certificate will be provisioned via DNS if requestedA CloudFront Distribution pointing to the S3 bucket.ExampleThis will create the website, the deployment pipeline, and add a generated certificate (and CloudFront) for HTTPS support.# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826CicdSpaWebsite(stack,"public-site",url="www.matthewbonig.com",github_source={"owner":"mbonig","repo":"public_site","oauth_token":SecretValue.secrets_manager("github-oauth-token")},hosted_zone={"hosted_zone_id":"ABCDEFGHIJKLM","zone_name":"matthewbonig.com"},certificate=True)Input PropertiespropertydescriptionexampleurlThe url you'd like your website to be available at. Must be full url and must be controlled by the given HostedZonewww.matthewbonig.comgithubSource.ownerThe Github repository's ownermboniggithubSource.repoThe GH repo namepublic_sitegithubSource.branchAn optional branch name. Defaults to 'master'qagithubSource.oauthTokenAn ISecret pointing to an oauthToken.SecretValue.secretsManager('github-oauth-token')hostedZone(Optional) - If provided, used to create DNS Records.hostedZone.hostedZoneIdThe hostedZone ID for the 'url's domainABCDEFGHIhostedZone.zoneNameThe hostedZone's namematthewbonig.comcertificate(Optional) - If provided, creates a CloudFront Distribution with the given certificate. If 'true' is provided, then a certificate will be generated.truebuildSpec(Optional) - If provided, will override the default BuildSpec in the CodeBuild project. Accepts either a string value (the filename in the source code) or an object. The object is passed to theBuildSpec.fromObject(). If not provided, seeBuildSpec.build-prod.yamlDesign NotesCertificatesIf a certificate is required to provide HTTPS support then a simple S3 Bucket with website hosting will not work. This construct chooses to put a CloudFront Distribution in front of it when a certificate is required.If that certificate already exists, it can be supplied as an ICertificate. If not, then it will be created using aDNSValidatedCertificate.If no certificate is supplied or requested, then the site will be hosted using a public S3 Bucket with Website Hosting enabled. No CloudFront Distribution will be created in that case.Github SourcesGithub source information is provided through props for the construct.If you'd like to see support for another type of Source action, please open anIssueor aPR.BuildSpecThe default buildspec is defined atDEFAULT_BUILD_SPEC. It uses a Node v12 runtime, runs annpm installand then annpm run buildand assumes the static deliverables are in thedistdirectory.You may override the BuildSpec with either your own object or by passing a string which will be interpreted as a filename within the source to use.ContributingPlease open Pull Requests and Issues on theGithub Repo.LicenseMIT