{"id":16101534,"url":"https://github.com/mendhak/aws-lambda-markdown-to-html","last_synced_at":"2025-04-06T00:27:49.579Z","repository":{"id":45017745,"uuid":"280205181","full_name":"mendhak/AWS-Lambda-Markdown-To-HTML","owner":"mendhak","description":null,"archived":false,"fork":false,"pushed_at":"2022-01-13T22:45:44.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T06:38:48.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/mendhak.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}},"created_at":"2020-07-16T16:36:43.000Z","updated_at":"2024-12-20T07:28:32.000Z","dependencies_parsed_at":"2022-09-22T16:02:12.602Z","dependency_job_id":null,"html_url":"https://github.com/mendhak/AWS-Lambda-Markdown-To-HTML","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2FAWS-Lambda-Markdown-To-HTML","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2FAWS-Lambda-Markdown-To-HTML/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2FAWS-Lambda-Markdown-To-HTML/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2FAWS-Lambda-Markdown-To-HTML/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mendhak","download_url":"https://codeload.github.com/mendhak/AWS-Lambda-Markdown-To-HTML/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419638,"owners_count":20936009,"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":[],"created_at":"2024-10-09T18:50:12.492Z","updated_at":"2025-04-06T00:27:49.548Z","avatar_url":"https://github.com/mendhak.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nExample repo to show Lambda development locally as well as in AWS.  The sample NodeJS code is in [lambda/index.js](lambda/index.js).  \n\nThe payload the Lambda expects is in the `event` object, in this case it's `event.markdown`, which is passed to the `markdown-it` library. \n\nYou can [run this Lambda in AWS](#running-the-lambda-in-aws), or [run this Lambda in a local container](#running-the-lambda-locally)\n\n\n# Running the Lambda in AWS\n\n\n## Setup\n\nClone this project, and `npm install`.  \n\nGet yourself some AWS credentials against your account -  either an IAM or temporary credentials.\n\nCreate a Lambda role if it doesn't already exist:\n\n```\naws iam create-role --role-name lambda-ex --assume-role-policy-document file://trust-policy.json\n```\n\nMake note of the Role ARN that comes back, you'll need it later. \n\n## Deploy \n\nCreate a zip file for the lambda: \n\n```\nzip -r myfunction.zip .\n```\n\nCreate your lambda function with the zip.  Substitute the Role ARN here. \n\n```\naws lambda create-function --region eu-west-1 --function-name my-function --zip-file fileb://myfunction.zip --handler lambda/index.handler --runtime nodejs12.x --role arn:aws:iam::123456789012:role/lambda-ex\n```\n\nOr update the existing function: \n\n```\naws lambda update-function-code --region eu-west-1 --function-name my-function --zip-file fileb://myfunction.zip\n```\n\n## Run\n\nNow invoke the function: \n\n```\naws lambda invoke --function-name my-function outype Tail --payload '{ \"markdown\": \"# Bob\" }' --cli-binary-format raw-in-base64-out\n```\n\nAnd look inside `outfile.txt` for the resulting HTML.  \n\n\n## Clean up\n\nRemove the function that you created. \n\n```\naws lambda delete-function --function-name my-function\n```\n\n\n# Running the Lambda locally\n\n## Setup\n\nClone this project, and `npm install`.  \n\n\n## Start the container\n\nThe [docker-compose.yml](docker-compose.yml) makes use of the [`lambci/lambda`](https://github.com/lambci/docker-lambda) image to run Lambda functions for local development.  \nThis is the same image used by AWS SAM, LocalStack and Serverless.  Minus the overhead.  \n\nRun the container\n\n```\ndocker-compose up\n```\n\n## Run\n\nThen in another terminal, invoke the function, and inspect the outfile. \n\n```\naws lambda invoke --endpoint http://localhost:9001 --region eu-west-1 --no-sign-request --function-name myfunction --payload '{\"markdown\":\"# Hello World!\"}' --cli-binary-format raw-in-base64-out outfile.txt\n\ncat outfile.txt\n\n```\n\nYou can also invoke it directly using curl\n\n```\ncurl -d '{\"markdown\":\" ## Hello, World\"}' http://localhost:9001/2015-03-31/functions/myfunction/invocation\n```\n\n\n## Clean up\n\nJust stop and remove the container\n\n```\ndocker-compose stop   # Or Ctrl+C \ndocker-compose rm\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmendhak%2Faws-lambda-markdown-to-html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmendhak%2Faws-lambda-markdown-to-html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmendhak%2Faws-lambda-markdown-to-html/lists"}