Skip to content

Instantly share code, notes, and snippets.

View layer
const layer = new lambda.LayerVersion(this, 'deno-layer', {
code: lambda.Code.fromAsset('src/layer'),
compatibleRuntimes: [lambda.Runtime.PROVIDED],
license: 'Apache-2.0',
description: 'A layer that enables Deno to run in AWS Lambda',
View Lambda
const name = new lambda.Function(this, 'NameHandler', {
runtime: lambda.Runtime.PROVIDED,
code: lambda.Code.fromAsset('src/program'),
handler: 'name.handler',
layers: layer,
View API Gateway
new apigw.LambdaRestApi(this, 'Deno-Endpoint', {
handler: name
View Sample
import {
} from "";
export async function handler(
event: APIGatewayProxyEvent,
context: Context
): Promise<APIGatewayProxyResult> {
View Stack
#!/usr/bin/env node
import * as cdk from '@aws-cdk/core';
import { CdkOneStack } from '../lib/cdk-one-stack';
const app = new cdk.App();
new CdkOneStack(app, 'CdkOneStack'); // <- Stack name>
# make a new folder for the project
# cd to the folder
# Initialise a cdk app
cdk init app --language typescript
# install the 3 additional modules we will need
npm install @aws-cdk/aws-s3 --save-dev
npm install @aws-cdk/aws-s3-deployment --save-dev
npm install @aws-cdk/aws-route53 --save-dev
# Create a folder for the Program, this is my convention the program may have more parts
# for now it's just static so create just those folders
mkdir -p Program/static
# Populate the index.html file with some content
echo "S3 Hosting with CDK" > Program/static/index.html
View setup.js
//Create the public S3 bucket
const publicAssets = new s3.Bucket(this, 'example-qr', {
bucketName: 'example.{you-domain}',
publicReadAccess: true,
removalPolicy: cdk.RemovalPolicy.DESTROY,
websiteIndexDocument: 'index.html',