{"id":26492885,"url":"https://github.com/floydspace/aws-lambda-effect-runtime","last_synced_at":"2025-03-20T09:37:25.211Z","repository":{"id":278979024,"uuid":"937373746","full_name":"floydspace/aws-lambda-effect-runtime","owner":"floydspace","description":"Experimental Effect-TS custom runtime for AWS Lambda","archived":false,"fork":false,"pushed_at":"2025-03-03T20:40:12.000Z","size":54,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T01:27:00.587Z","etag":null,"topics":["aws","aws-lambda","aws-lambda-layer","effect-ts","extensions","lambda-layer","runtime"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/floydspace.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-22T22:23:09.000Z","updated_at":"2025-03-03T20:40:15.000Z","dependencies_parsed_at":"2025-02-23T00:21:55.075Z","dependency_job_id":null,"html_url":"https://github.com/floydspace/aws-lambda-effect-runtime","commit_stats":null,"previous_names":["floydspace/aws-lambda-effect-runtime"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floydspace%2Faws-lambda-effect-runtime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floydspace%2Faws-lambda-effect-runtime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floydspace%2Faws-lambda-effect-runtime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floydspace%2Faws-lambda-effect-runtime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floydspace","download_url":"https://codeload.github.com/floydspace/aws-lambda-effect-runtime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244587984,"owners_count":20477244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda","aws-lambda-layer","effect-ts","extensions","lambda-layer","runtime"],"created_at":"2025-03-20T09:37:24.629Z","updated_at":"2025-03-20T09:37:25.202Z","avatar_url":"https://github.com/floydspace.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aws-lambda-effect-runtime\n\nA custom runtime layer that runs \"Effectful\" lambda functions.\nThe idea is to have an option to implement lambda functions returning `Effect` type from [effect](https://github.com/Effect-TS/effect) library.\n\n## Setup\n\nFirst, you will need to deploy the layer to your AWS account. Clone this repository and run the `build-layer` script to prepare the layer for distribution. Then run the `publish-layer` script to publish the layer to your AWS account.\n\n```sh\ngit clone https://github.com/floydspace/aws-lambda-effect-runtime.git\ncd aws-lambda-effect-runtime\npnpm install\npnpm publish-layer\n```\n\n## Usage\n\nOnce you publish the layer to your AWS account, you can create a Lambda function that uses the layer.\n\n### Step 1: Create a Lambda handler function that returns an `Effect` type\n\nExample of an effectful lambda handler implementing the `EffectHandler` type from [`@effect-aws/lambda`](https://github.com/floydspace/effect-aws/tree/main/packages/lambda):\n\n```typescript\nimport type { SNSEvent } from \"aws-lambda\"\nimport { Effect } from \"effect\"\nimport type { EffectHandler } from \"@effect-aws/lambda\"\n\n// Define your effect handler\nexport const handler: EffectHandler\u003cSNSEvent, never\u003e = (event, context) =\u003e {\n  // Your effect logic here\n  return Effect.logInfo(\"Hello, World!\")\n}\n```\n\nor with global layer:\n\n```typescript\nimport type { SNSEvent } from \"aws-lambda\"\nimport { Effect, Logger } from \"effect\"\nimport type { EffectHandlerWithLayer } from \"@effect-aws/lambda\"\n\n// Define your effect handler with global layer\nexport const handler: EffectHandlerWithLayer\u003cSNSEvent, never\u003e = {\n  handler: (event, context) =\u003e {\n    // Your effect logic here\n    return Effect.logInfo(\"Hello, World!\")\n  },\n  layer: Logger.pretty,\n};\n```\n\nThe global layer will be constructed on lambda cold-start and finalized on shutdown. (How cool is that, huh!)\n\n### Step 2: Build the handler\n\nYou can transpile your handler function to JavaScript or bundle it. Here's how you can do it using `esbuild`:\n\n1. Run `esbuild src/handler.ts --bundle --platform=node --target=node22 --external:@effect/platform --external:effect --outfile=dist/handler.js`\n2. Zip the `/dist` folder\n\n_Note_: Make sure you exclude `effect` and `@effect/platform` from the bundle. Those dependencies are provided by the layer.\n\n### Step 3: Create the Lambda function on AWS\n\nOnce you've written your Lambda function, you need to configure a new Lambda function to the layer. The following steps apply to configuring in the console, CloudFormation, CDK, Terraform, or any other configuration management option for AWS:\n\n1. Create the Lambda function\n2. Set the Runtime to custom with Amazon Linux 2023\n3. Set the handler to `\u003chandler-file-name\u003e.\u003chandler-function-name\u003e` (e.g. `src/handler.effectHandler`)\n4. Set the architecture to whichever architecture you configured when you built/deployed the Lambda Layer\n5. Attach the Lambda Layer to your new function\n6. Upload the zip file from step 2. You can do this in the console directly, upload to S3 and set that as the location for the handler file in Lambda, or use something like CDK to manage this for you.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloydspace%2Faws-lambda-effect-runtime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloydspace%2Faws-lambda-effect-runtime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloydspace%2Faws-lambda-effect-runtime/lists"}