All Projects → nideveloper → Cdk Spa Deploy

nideveloper / Cdk Spa Deploy

Licence: mit
This is an AWS CDK Construct to make deploying a single page website (Angular/React/Vue) to AWS S3 behind SSL/Cloudfront easier

Programming Languages

python
139335 projects - #7 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Cdk Spa Deploy

React Deploy S3
Deploy create react app's in AWS S3
Stars: ✭ 66 (-29.79%)
Mutual labels:  cloudfront, ssl
react-deploy-s3
Deploy create react app's in AWS S3
Stars: ✭ 67 (-28.72%)
Mutual labels:  ssl, cloudfront
Nx Packaged
Angular libraries with ng-packagr embedded in Nx Workspace.
Stars: ✭ 82 (-12.77%)
Mutual labels:  angular-cli
Ngx Youtube Player
YouTube player app built with Angular 7
Stars: ✭ 92 (-2.13%)
Mutual labels:  angular-cli
Coreui Free Angular Admin Template
CoreUI Angular is free Angular 2+ admin template based on Bootstrap 4
Stars: ✭ 1,279 (+1260.64%)
Mutual labels:  angular-cli
Angular Full Stack
Angular Full Stack project built using Angular, Express, Mongoose and Node. Whole stack in TypeScript.
Stars: ✭ 1,261 (+1241.49%)
Mutual labels:  angular-cli
Certificaat
General-purpose ACME client
Stars: ✭ 88 (-6.38%)
Mutual labels:  ssl
Angular2andjavaee
This project should provide a starting point for people interested in using Angular 10 with Ivy in a Java EE environment.
Stars: ✭ 78 (-17.02%)
Mutual labels:  angular-cli
React Apig Lambda
Render React.js on-demand with CDN caching
Stars: ✭ 93 (-1.06%)
Mutual labels:  cloudfront
Pric
Simple zero-config tool to create Private Certificate Authority & issue locally-trusted development server certificates with any domain names you'd like. SSL certificates for development purposes.
Stars: ✭ 87 (-7.45%)
Mutual labels:  ssl
Spring Boot Angular Example
Example app showing how to build a Spring Boot REST API and Angular UI
Stars: ✭ 92 (-2.13%)
Mutual labels:  angular-cli
Checkssl
checks ssl certs for a set of domains
Stars: ✭ 86 (-8.51%)
Mutual labels:  ssl
Ngx Snake
Snake arcade game implemented in Angular 7
Stars: ✭ 85 (-9.57%)
Mutual labels:  angular-cli
Movies Finder
Movies finder is a small Angular 5 app https://movies-finder.firebaseapp.com/
Stars: ✭ 89 (-5.32%)
Mutual labels:  angular-cli
Ansible Haproxy
Ansible role to set up (the latest version of) HAProxy in Ubuntu systems
Stars: ✭ 83 (-11.7%)
Mutual labels:  ssl
Tls Inspector
Easily view and inspect X.509 certificates on your iOS device.
Stars: ✭ 92 (-2.13%)
Mutual labels:  ssl
Spring Boot Starter Acme
Generate SSL certs easily for Spring Boot apps
Stars: ✭ 83 (-11.7%)
Mutual labels:  ssl
Http Client
A high-performance, high-stability, cross-platform HTTP client.
Stars: ✭ 86 (-8.51%)
Mutual labels:  ssl
Trust stores observatory
Continuously monitor and record the content of the major platforms' root certificate stores.
Stars: ✭ 87 (-7.45%)
Mutual labels:  ssl
Php Hyper Builtin Server
Reverse proxy for PHP built-in server which supports multiprocessing and TLS/SSL encryption
Stars: ✭ 93 (-1.06%)
Mutual labels:  ssl

CDK-SPA-Deploy

npm Vulnerabilities

This is an AWS CDK Construct to make deploying a single page website (Angular/React/Vue) to AWS S3 behind SSL/Cloudfront as easy as 5 lines of code.

Installation and Usage

Typescript

npm install --save cdk-spa-deploy
import cdk = require('@aws-cdk/core');
import { SPADeploy } from 'cdk-spa-deploy';

export class CdkStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new SPADeploy(this, 'spaDeploy')
      .createBasicSite({
        indexDoc: 'index.html',
        websiteFolder: '../blog/dist/blog'
      });

    new SPADeploy(this, 'cfDeploy')
      .createSiteWithCloudfront({
        indexDoc: 'index.html',
        websiteFolder: '../blog/dist/blog'
      });
  }
}

Python

pip install cdk-spa-deploy
from aws_cdk import core
from spa_deploy import SPADeploy

class PythonStack(core.Stack):
  def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
    super().__init__(scope, id, **kwargs)

    SPADeploy(self, 'spaDeploy').create_basic_site(
      index_doc='index.html',
      website_folder='../blog/blog/dist/blog'
    )


    SPADeploy(self, 'cfDeploy').create_site_with_cloudfront(
      index_doc='index.html',
      website_folder='../blog/blog/dist/blog'
    )

Dotnet / C#

This project has now been published to nuget, more details to follow soon but you can find it here

# package manager
Install-Package CDKSPADeploy -Version 1.80.0
# .NET CLI
dotnet add package CDKSPADeploy --version 1.80.0
# Package reference
<PackageReference Include="CDKSPADeploy" Version="1.80.0" />
# Paket CLI
paket add CDKSPADeploy --version 1.80.0

Java

A version has now been published to maven

<dependency>
  <groupId>com.cdkpatterns</groupId>
  <artifactId>CDKSPADeploy</artifactId>
  <version>1.81.0</version>
</dependency>

Advanced Usage

Auto Deploy From Hosted Zone Name

If you purchased your domain through route 53 and already have a hosted zone then just use the name to deploy your site behind cloudfront. This handles the SSL cert and everything for you.

new SPADeploy(this, 'spaDeploy', { encryptBucket: true })
  .createSiteFromHostedZone({
    zoneName: 'cdkpatterns.com',
    indexDoc: 'index.html',
    websiteFolder: '../website/dist/website'
  });

Custom Domain and SSL Certificates

You can also pass the ARN for an SSL certification and your alias routes to cloudfront

import cdk = require('@aws-cdk/core');
import { SPADeploy } from 'cdk-spa-deploy';

export class CdkStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new SPADeploy(this, 'cfDeploy')
      .createSiteWithCloudfront({
        indexDoc: '../blog/dist/blog',
        certificateARN: 'arn:...',
        cfAliases: ['www.alias.com']
      });
  }  
}

Encrypted S3 Bucket

Pass in one boolean to tell SPA Deploy to encrypt your website bucket

new SPADeploy(this, 'cfDeploy', {encryptBucket: true}).createBasicSite({
    indexDoc: 'index.html',
    websiteFolder: 'website'
});

Custom Origin Behaviors

Pass in an array of CloudFront Behaviors

new SPADeploy(this, 'cfDeploy').createSiteWithCloudfront({
  indexDoc: 'index.html',
  websiteFolder: 'website',
  cfBehaviors: [
    {
      isDefaultBehavior: true,
      allowedMethods: cf.CloudFrontAllowedMethods.ALL,
      forwardedValues: {
        queryString: true,
        cookies: { forward: 'all' },
        headers: ['*'],
      },
    },
    {
      pathPattern: '/virtual-path',
      allowedMethods: cf.CloudFrontAllowedMethods.GET_HEAD,
      cachedMethods: cf.CloudFrontAllowedCachedMethods.GET_HEAD,
    },
  ],
});

Restrict Access to Known IPs

Pass in a boolean and an array of IP addresses and your site is locked down!

new SPADeploy(stack, 'spaDeploy', { 
  encryptBucket: true, 
  ipFilter: true, 
  ipList: ['1.1.1.1']
}).createBasicSite({
    indexDoc: 'index.html',
    websiteFolder: 'website'
  })

Modifying S3 Bucket Created in Construct

An object is now returned containing relevant artifacts created if you need to make any further modifications:

  • The S3 bucket is present for all of the methods
  • When a CloudFront Web distribution is created it will be present in the return object
export interface SPADeployment {
  readonly websiteBucket: s3.Bucket,
}

export interface SPADeploymentWithCloudFront extends SPADeployment {
  readonly distribution: CloudFrontWebDistribution,
}

Issues / Feature Requests

https://github.com/nideveloper/CDK-SPA-Deploy

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].