https://github.com/mikebild/cdk-cdn-construct
https://github.com/mikebild/cdk-cdn-construct
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mikebild/cdk-cdn-construct
- Owner: MikeBild
- Created: 2021-08-12T07:17:14.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-16T08:57:12.000Z (almost 5 years ago)
- Last Synced: 2025-02-14T02:47:00.633Z (over 1 year ago)
- Language: TypeScript
- Size: 216 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AWS Serverless based CDN using the AWS-CDK
**WORK IN PROGRESS**
This project tries to implement a simple way to deploy static web content like Single-Page-Applications (SPA) or Static-Websites into the cloud using a AWS S3 bucket and a distribute it via a CDN using AWS CloudFront.
## Intention and conceptual background
Reusable application blocks are already commonplace in many areas of software development. (e.g. UI-Libraries, NPM-Modules, etc.) Only with reusable modules/components is it really possible to beeing productive in application development. But at the moment you still need a lot of special cloud know-how to be able to use the Serverless-Cloud architecture effectively in your own project. This project tries to establish a complete and reusable Serverless-Application-Blocks (also called cloud modules) which you can easily integrate, deploy and use in your own application stack using the AWS-CDK.
## Architecture and implementation
This project is a reusable AWS-CDK stack implementation that creates a AWS S3 bucket to deploy your static content into it and distribute the content via a CDN using AWS CloudFront.

You can use it in your own AWS-CDK-App like this:
```typescript
#!/usr/bin/env node
import { join } from 'path';
import { App } from '@aws-cdk/core';
import { CdkCdnConstructStack } from 'cdk-cdn-construct';
const app = new App();
// your own stacks ...
new CdkCdnConstructStack(app, 'My-Stack-Name', {
namespace: `my-app-namespace`,
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },
});
// your own stacks ...
```
TBD
## Setup
`npm install cdk-cdn-construct`
## CLI Configuration
Create a **.env** file like:
```
CDK_DEFAULT_REGION=eu-central-1
CDK_DEFAULT_ACCOUNT=default
CDK_CDN_NAME=your-host-and-bucket-name
CDK_CDN_PATH=./build
CDK_CDN_DOMAIN=example.com
```
Add this line to your **package.json**:
```json
{
"scripts": {
"deploy": "export $(cat .env | xargs) && cdk deploy --all --require-approval never --app cdk-cdn-construct"
}
}
```
**Deploy the examples using AWS-Vault**
`aws-vault exec --no-session -- yarn deploy`