Skip to main content

Base CDK stack for Single Page Applications

Project description

Sktan AWS CDK Base Stack - Single Page Application Base

This base stack is designed to provide the bare minimum requirements required to support a serverless single page application styled website on AWS.

Resources Created

  • Cloudfront Distribution
  • Website Assets S3 Bucket
  • Staging Deployment S3 Bucket
  • Lambda Function (to copy assets from the staging s3 bucket to the website assets bucket)

Prerequisites

  • Python 3.6+ and pip
  • sktan_cdk.single_page_app
pip install sktan-cdk.single-page-app

Deploying as is

If you want to use the stack as is, you will be able to use this like any other CDK stack and then run cdk synth to view your results:

Folder Structure

example-spa-website
|-- app.py
|-- cdk.json
|-- website_html
|   |-- index.html
|   |-- css
|   |   |-- example.css
|   |-- images
|   |   |-- logo.jpg

app.py

from aws_cdk import core
import sktan_cdk.single_page_app

app = core.App()

spa_app = single_page_app(app, "example-spa-website", website_identifier='www-example-com')
spa_app.create_website_bucket('website_html')
spa_app.create_cloudfront_distribution(cloudfront_alias={
  'acm_cert_ref': 'arn:aws:acm:us-east-1:123456789012:certificate/example-certificate-arn-format',
  'names': [
    'www.example.com'
  ]
})
app.synth()

Extending the stack

If you'd like to use this stack as a basis for your application, then you are free to extend it to implement additional functionality.

import sktan_cdk.single_page_app
from aws_cdk import (
  aws_s3 as s3
)

class existing_s3_bucket_website(single_page_app):
  def create_website_bucket(self, deployment_path: typing.Optional[str]):
    s3.fromBucketArn(self, self.__website_identifier, 'arn:aws:s3:::www-example-com')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sktan_cdk.single_page_app-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sktan_cdk.single_page_app-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file sktan_cdk.single_page_app-0.1.0.tar.gz.

File metadata

  • Download URL: sktan_cdk.single_page_app-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.4

File hashes

Hashes for sktan_cdk.single_page_app-0.1.0.tar.gz
Algorithm Hash digest
SHA256 805497ee9b920e217c63854ddc3cebb61f3e12126b96a4fb712c87753b5e2ab1
MD5 890b6d10a49f8cf7e0b851f7ca0d435d
BLAKE2b-256 05d33b8164abf5bf349c244d137adcf70a566f7d1b59275fb389fc0d12346c24

See more details on using hashes here.

File details

Details for the file sktan_cdk.single_page_app-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sktan_cdk.single_page_app-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.4

File hashes

Hashes for sktan_cdk.single_page_app-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c6a6eaaf337d4249393e1c842dd916013988fad2a97ca4de0ffb4037608b27f
MD5 f939e6f114df9f68aec268db4c50a462
BLAKE2b-256 8396c80765920e9e8b50bcc31f4312b37077394af9a99679e5fd0b796db3536c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page