0.0.5 • Published 11 months ago

awscdk-construct-file-publisher v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

awscdk-construct-file-publisher

View on Construct Hub

CDK Construct for making local files publicly available

  • Specify a path to a local folder that contains files
  • FilePublisher creates an S3 bucket and uploads all the files to the bucket
  • FilePublisher creates a CloudFront distribution and set the bucket as its origin via Origin Access Identity (OAI)
  • You can access the files via CloudFront as the S3 bucket remains private

Install

NPM

Usage

import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { FilePublisher } from 'awscdk-construct-file-publisher';

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

    // Upload all the files in the local folder (./upload) to S3
    const publicFolder = new FilePublisher(this, 'FilePublisher', {
      path: './upload',
    });

    // You can access the file via Internet
    new cdk.CfnOutput(this, "PublicURL", {
      value: `${publicFolder.url}/dog.mp4`,,
      exportName: cdk.Aws.STACK_NAME + "PublicURL",
      description: "Public URL",
    });
  }
}
0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

12 months ago

0.0.1

1 year ago

0.0.0

1 year ago