Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

npm install -g aws-cdk
npm install
npm run watch
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',
});
const name = new lambda.Function(this, 'NameHandler', {
runtime: lambda.Runtime.PROVIDED,
code: lambda.Code.fromAsset('src/program'),
handler: 'name.handler',
layers: layer,
})
new apigw.LambdaRestApi(this, 'Deno-Endpoint', {
handler: name
});
import {
APIGatewayProxyEvent,
APIGatewayProxyResult,
Context
} from "https://deno.land/x/lambda/mod.ts";
export async function handler(
event: APIGatewayProxyEvent,
context: Context
): Promise<APIGatewayProxyResult> {
#!/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
mkdir bucket.website.com
# cd to the folder
cd bucket.website.com
# 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
//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',
});