Skip to content

Instantly share code, notes, and snippets.

View apoorvmote's full-sized avatar
✍️
writing tutorials on apoorv.blog

Apoorv Mote apoorvmote

✍️
writing tutorials on apoorv.blog
View GitHub Profile
FROM ubuntu:20.04
RUN apt-get update && apt-get install wget git xz-utils -y
RUN mkdir -p /home/apoorvmote/website/
WORKDIR /home/apoorvmote/website/
EXPOSE 1313
# https://taskfile.dev
version: '3'
tasks:
default:
cmds:
- rm deployment.zip -f
- zip deployment.zip index.js
exports.discountForProduct = (productId) => {
const products = [
{
productId: '1',
discount: '10%'
},
{
productId: '2',
discount: '20%'
import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from "aws-lambda";
import { DynamoDB, PutItemInput } from '@aws-sdk/client-dynamodb'
import { marshall } from '@aws-sdk/util-dynamodb'
import { v4 as uuid } from 'uuid'
interface TodoInput {
id?: string
title: string
done: boolean
}
new ARecord(this, 'apiAliasRecord', {
zone: hostedZone,
target: RecordTarget.fromAlias(new ApiGatewayv2Domain(domain))
})
import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from 'aws-lambda'
export async function myFunction(event: APIGatewayProxyEventV2): Promise<APIGatewayProxyResultV2> {
return {
statusCode: 200,
body: JSON.stringify({ message: 'hello from ts lambda' })
}
}
{
"lambdaARN": "arn:aws:lambda:us-east-1:123567890:function:lambda-cost-6cvNuq95XpKYZbM6-getTodoFn01C9D3BC-gEAFh9acFv8PunBf",
"powerValues": [
128,256,512,1024,2048
],
"num": 10,
"payload": {
"body": "{\"id\": \"58dcfe41-cc3f-4f5b-afbf-d69ef4908bae\"}"
},
"parallelInvocation": true,
import { Code, Function, Runtime } from '@aws-cdk/aws-lambda';
import * as cdk from '@aws-cdk/core';
export class GoLambdaStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// The code that defines your stack goes here
new Function(this, 'goLambda', {
runtime: Runtime.GO_1_X,
package main
import (
"encoding/json"
"fmt"
)
// OptionalInt is for json unmarshal
type OptionalInt struct {
Value int
# https://taskfile.dev
version: '3'
includes:
project1:
taskfile: ./project1/Taskfile.yml
dir: ./project1
project2:
taskfile: ./project2/Taskfile.yml