D
Deno

help

anyone have a modern container workflow for the serverless framework?

Wwungobungo7/26/2023
I was able to find code that executed at one point in time. It no longer does. I’d really like to instead get fresh or deno into a container and use serverless to make it work on aws. this is at least as of current a requirement for all code at my workplace and is a hard must to hit production with deno. Gpt was rabbit holing into irrelevant nonsense
Wwungobungo7/26/2023
Specifically getting it working with serverless framework ; the terminology in this space is HORRENDOUS
Ffro.profesional7/28/2023
You can use the image and docker file to deploy using Serverless framework http://serverless.com//blog/container-support-for-lambda https://github.com/hayd/deno-lambda/tree/master/example-serverless We usted to have deno api running on AWS LAMBDA with the combination of this articles and a more simplier Serverless yml
Container Image Support for AWS Lambda
Container Image Support for AWS Lambda has now been added. Read up on why you may (or may not) want to use it and how easy it is to use with the framework
GitHub
deno-lambda/example-serverless at master · hayd/deno-lambda
A deno runtime for AWS Lambda. Deploy deno via docker, SAM, serverless, or bundle it yourself. - hayd/deno-lambda
Ffro.profesional7/28/2023
Give it a read to the repository and the article it was pretty simple, we moved to deno deploy due the lower cold starts, thats why currently i dont have an example, let me know if u cant to try to setup a basic example
Wwungobungo7/28/2023
Unfortunately I have a codified requirement to utilize serverless for 100% of AWS infra at my company 😭 There’s hardline requirements for access to internal networks no meshing nothing allowed
Ffro.profesional7/28/2023
I did find and old test trying to use OAK https://github.com/fro-profesional/POC/tree/main/aws-deno
GitHub
POC/aws-deno at main · fro-profesional/POC
Proof of concept. Quick test of different things. Contribute to fro-profesional/POC development by creating an account on GitHub.
Ffro.profesional7/28/2023
Let me know if it helps But in short: Define serverless.yml | .ts | .js
// serverless.js (you can use yml also)
const name = "deno-lambda-test";
let config = {
service: name,
provider: {
name: "aws",
ecr: { images: { [name]: { path: "./" } } },
},
functions: {
service: {
image: { name },
events: [{ httpApi: "*" }],
},
},
};
module.exports = config;
// serverless.js (you can use yml also)
const name = "deno-lambda-test";
let config = {
service: name,
provider: {
name: "aws",
ecr: { images: { [name]: { path: "./" } } },
},
functions: {
service: {
image: { name },
events: [{ httpApi: "*" }],
},
},
};
module.exports = config;
Define Dockerfile
//Dockerfile
FROM hayd/deno-lambda:1.29.1

COPY . .
RUN deno cache lambda.ts

CMD ["lambda.handler"]
//Dockerfile
FROM hayd/deno-lambda:1.29.1

COPY . .
RUN deno cache lambda.ts

CMD ["lambda.handler"]
Define handler
//lambda.ts
import {
APIGatewayProxyEventV2,
APIGatewayProxyResultV2,
Context,
} from "https://deno.land/x/lambda@1.28.3/mod.ts";

const handler = async (
event: APIGatewayProxyEventV2,
context: Context
): Promise<APIGatewayProxyResultV2> => {

return {
body: JSON.stringify({
message: "hello-world"
}),
headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": "*",
},
statusCode: 200,
};
};

export { handler };
//lambda.ts
import {
APIGatewayProxyEventV2,
APIGatewayProxyResultV2,
Context,
} from "https://deno.land/x/lambda@1.28.3/mod.ts";

const handler = async (
event: APIGatewayProxyEventV2,
context: Context
): Promise<APIGatewayProxyResultV2> => {

return {
body: JSON.stringify({
message: "hello-world"
}),
headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": "*",
},
statusCode: 200,
};
};

export { handler };
Wwungobungo7/28/2023
thanks! this is what I was looking for

Looking for more? Join the community!

Recommended Posts
How to deno up nuxt?**Setting up Nuxt3**: When learning more about V8 and the node.js architecture I became aware of dengoogle cloud SDKsHi all, I am building an application that interacts with google cloud apis, specifically google plaPrisma and denogetting this ```error: could not find package '.prisma' from referrer 'file:///Users/nikos/WebstormPDates don't increment correctlywhen I run the below function with the specific date 2023-09-30, I get the result of n-1 (for any nuHi, can anyone direct me to the repo/functions where the deno/fresh project generator is held?I am looking to add functionality to this project generator but I'm not familiar enough to really fiSpeed of generatorsHow fast are JS generators when used as iterators? To be clear, I see the `for..of` loop being veryParsing HTML/XMLLately I've been researching how to write a simple HTML/XML -> JSON converter. My syntax isn't complIs it possible to import cjs module from es module, both in extension?cjs is added using `deno_core::extension`'s `js`. esm added using `deno_core::extension`'s `esm` IDeno.serve() doesn't streamhttps://gist.github.com/guest271314/39a3f93346bbc7dec5ee9fa1ff579256Deno ImportsI'm trying to use react-hook-form in an application, but bringing in the dependency results in a depWhere to store this key — and how?```ts const cryptoKey = await crypto.subtle.generateKey({ name: 'HMAC', hash: 'SHA-512' }, tTyping DateTimes```ts interface ICity { slug: string name: string description?: string createdAt: Date updBundle without exportIs it possible to have the output not having `export... ` line?LSP badly resolves relative imports between cached modulesI don't really understand this, but it looks to me like the LSP / VS Code has started resolving relaReason for "Following modules were not evaluated"What is the reason for "Following modules were not evaluated; make sure they are imported from otherdiscordav.deno.dev not working nowIm using discordav.deno.dev for get the discord profile picture from id. It was working yesterday buKV: What to return from here?```TS // Create City router.post('/cities', async (context) => { const data = await context.requLog Deno.command process outputi need to execute a command wich will keep running until stopped and log the output. i found this buUncaught TypeError: Cannot set properties of null (setting 'innerHTML')Code: var bcb = new WebSocket('wss://stream.binance.com:9443/ws/bnbusdt@trade'); bcb.onmessage = (It's hard to read that the font used in the official Deno website.On the official Deno website (deno.land), I think it difficult to distinguish between upper and lowe