Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hupe1980/custom-resource-helper
A helper for cloudformation custom resources
https://github.com/hupe1980/custom-resource-helper
aws cloudformation customresource lambda
Last synced: 13 days ago
JSON representation
A helper for cloudformation custom resources
- Host: GitHub
- URL: https://github.com/hupe1980/custom-resource-helper
- Owner: hupe1980
- License: mit
- Created: 2019-01-03T16:42:57.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:37:55.000Z (almost 2 years ago)
- Last Synced: 2024-04-18T04:52:40.479Z (8 months ago)
- Topics: aws, cloudformation, customresource, lambda
- Language: TypeScript
- Homepage:
- Size: 1.26 MB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# custom-resource-helper
[![Build Status](https://travis-ci.org/hupe1980/custom-resource-helper.svg?branch=master)](https://travis-ci.org/hupe1980/custom-resource-helper)
> A helper for cloudformation custom resources
## Install
```bash
npm install --save custom-resource-helper
```## How to use
```typescript
import { customResourceHelper, ResourceHandler, ResourceHandlerReturn } from 'custom-resource-helper';export const handler = customResourceHelper(
(): ResourceHandler => ({
onCreate: async (event, context, logger): Promise => {
// Place your code to handle Create events here.
const physicalResourceId = 'myResourceId';
const responseData = {};return {
physicalResourceId,
responseData
};
},
onUpdate: async (event, context, logger): Promise => {
// Place your code to handle Update events here.
const physicalResourceId = event.PhysicalResourceId;
const responseData = {};return {
physicalResourceId,
responseData
};
},
onDelete: async (event, context, logger): Promise => {
// Place your code to handle Delete events here
return;
}
})
/* optional: customLogFactory */
);
```## Logging
By default log level is set to warning. This can be customized with a custom LogFactory or by defining the "LogLevel" property in the custom resource resource in your template. For example:
```json
"MyCustomResource": {
"Type": "AWS::CloudFormation::CustomResource",
"Properties": {
"LogLevel": "debug",
//...
}
}
```## Utils
```typescript
import { camelizeKeys } from 'custom-resource-helper';
//...
console.log(event);
/*
{
...
ResourceProperties: {
...
BucketName: 'testbucket',
---
}
...
}
*/
const {
resourceProperties: { bucketName }
} = camelizeKeys(event);console.log(bucketName); //prints: testBuckets
//...
```