{"id":39139752,"url":"https://github.com/odedniv/safe-cfn-custom-resource","last_synced_at":"2026-01-17T21:29:44.824Z","repository":{"id":150457025,"uuid":"134946371","full_name":"odedniv/safe-cfn-custom-resource","owner":"odedniv","description":"The safest implementation for CloudFormation custom resources in NodeJS.","archived":false,"fork":false,"pushed_at":"2018-09-26T22:09:30.000Z","size":15,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-17T14:51:19.572Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/odedniv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-05-26T09:10:40.000Z","updated_at":"2019-09-12T13:05:53.000Z","dependencies_parsed_at":"2023-04-30T05:14:30.092Z","dependency_job_id":null,"html_url":"https://github.com/odedniv/safe-cfn-custom-resource","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/odedniv/safe-cfn-custom-resource","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odedniv%2Fsafe-cfn-custom-resource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odedniv%2Fsafe-cfn-custom-resource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odedniv%2Fsafe-cfn-custom-resource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odedniv%2Fsafe-cfn-custom-resource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odedniv","download_url":"https://codeload.github.com/odedniv/safe-cfn-custom-resource/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odedniv%2Fsafe-cfn-custom-resource/sbom","scorecard":{"id":702468,"data":{"date":"2025-08-11","repo":{"name":"github.com/odedniv/safe-cfn-custom-resource","commit":"a5ed34408ab05d991e33f61ace59db7269afc02c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 1/14 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T05:30:50.264Z","repository_id":150457025,"created_at":"2025-08-22T05:30:50.265Z","updated_at":"2025-08-22T05:30:50.265Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28518626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T18:55:29.170Z","status":"ssl_error","status_checked_at":"2026-01-17T18:55:03.375Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-01-17T21:29:44.710Z","updated_at":"2026-01-17T21:29:44.782Z","avatar_url":"https://github.com/odedniv.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# safe-cfn-custom-resource\n\nCloudFormation is awesome! Custom resources are awesome! But... \\\nTired of having your CloudFormation stack for **1 whole hour** because of a bug during development? Want to use `async/await`?\n\nThis package lets you have the safest implementation of your custom resource, if you use it properly your stack will never get stuck.\n\nSpecial thanks to [zippadd/cfn-custom-resource](https://www.npmjs.com/package/cfn-custom-resource),\nthis is basically a wrapper around it.\n\n## Install\n\n```bash\nnpm install --save safe-cfn-custom-resource\n```\n\n## Requirements\n\n* **Lambda Runtime:** NodeJS 8.10+ (the handler will return a promise)\n* **Lambda Timeout:** 4+ seconds (the function will timeout 3 seconds before Lambda's timeout)\n\n**Note:** 4 seconds timeout means you have less than 1 second to finish your work, you should probably set it to more.\n\n## Usage\n\nYour main JavaScript module should look like this:\n\n```javascript\n// Yes, even your initialization can be async!\nmodule.exports.handler = require('safe-cfn-custom-resource')(/*async*/ () =\u003e {\n  // Don't do ANYTHING outside this function!\n  // All your requires go here.\n\n  // event \u0026 context are the original ones the handler was invoked with.\n  return {\n    /*async*/ create(event, context) {\n      return {\n        // required\n        id: \"the physical resource id (Ref)\",\n        // optional\n        // can also supply a non-object which would be retrieved using !GetAtt: [ResourceLogicalId, Data]\n        data: { Key: \"value\", For: \"GetAtt\" }\n      };\n    },\n    /*async*/ update(event, context) {\n      return {\n        // optional, original physical resource id will be used if not supplied\n        id: \"the physical resource id (Ref)\",\n        // optional\n        // can also supply a non-object which would be retrieved using !GetAtt: [ResourceLogicalId, Data]\n        data: { Key: \"value\", For: \"GetAtt\" }\n      };\n    },\n    /*async*/ delete(event, context) {\n      // doesn't need to return anything\n    },\n  };\n});\n```\n\n* See the [official documentation for custom resource request event structure](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requests.html).\n* If you throw an error with an `id` attribute, it will be used as the physical resource id send with the failure message to CloudFormation.\n* If you are using VPN, make sure you allow the function to connect to CloudFormation's endpoint.\n\n* **Tip 1:** Remember that if the update requires re-creation, return the new physical resource id and don't delete the old one,\n             CloudFormation will automatically call this function again for deletion of the old physical resource id.\n* **Tip 2:** Use [Webpack](https://webpack.js.org/) to save some artifact size when using dependencies (like this one).\n\n### Debugging\n\nSetting an environment variable called `DEBUG` on your Lambda function will give you debug logging in CloudWatch.\nNote that your lambda needs to be able to access the function's CloudWatch log stream.\n\n### Unit testing your resource\n\nIn order to unit test your implementation there are 3 options:\n\n1. You can write your logic in a separate `resource.js` file,\n   and `require` \u0026 `return` it in the `index.js` that is used as the Lambda's handler:\n\n   ```javascript\n   # resource.js\n   module.exports = {\n     /*async*/ create(event, context) {\n       /* see above */\n     }\n     /*async*/ update(event, context) {\n       /* see above */\n     }\n     /*async*/ delete(event, context) {\n       /* see above */\n     }\n   };\n\n   # index.js\n   module.exports.handler = require('safe-cfn-custom-resource')(/*async*/ () =\u003e {\n     // Require it INSIDE the safety callback!\n     return require('./resource');\n   });\n   ```\n\n   And now you can `require` your implementation separetely.\n\n2. If you are a minimalist there is a second option. `safe-cfn-custom-resource`\n   exposes whatever you return inside the callback via a `resource` attribute:\n\n   ```javascript\n   const { handler } = require('./index');\n   let event = { /* CloudFormation event */ };\n   let context = { /* Lambda context */ };\n   handler.resource.create(event, context);\n   handler.resource.update(event, context);\n   handler.resource.delete(event, context);\n   ```\n\n   Feel free to return additional internal functions you want to test.\n\n3. You can avoid testing internal functions (e.g your `create`/`update`/`delete`),\n   and only test the exported handler:\n\n   ```javascript\n   const { handler } = require('./index');\n   let context = { /* Lambda context */ };\n   handler({ /* CloudFormation Create event */ }, context);\n   handler({ /* CloudFormation Update event */ }, context);\n   handler({ /* CloudFormation Delete event */ }, context);\n   ```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodedniv%2Fsafe-cfn-custom-resource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodedniv%2Fsafe-cfn-custom-resource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodedniv%2Fsafe-cfn-custom-resource/lists"}