https://github.com/arhea/aws-userdata-handlebars
Use Handlebars templates in AWS CDK UserData
https://github.com/arhea/aws-userdata-handlebars
Last synced: 9 months ago
JSON representation
Use Handlebars templates in AWS CDK UserData
- Host: GitHub
- URL: https://github.com/arhea/aws-userdata-handlebars
- Owner: arhea
- License: apache-2.0
- Created: 2020-01-17T22:53:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T05:16:53.000Z (over 3 years ago)
- Last Synced: 2025-02-19T02:49:48.760Z (over 1 year ago)
- Language: TypeScript
- Size: 644 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UserData Powered By Handlebars



This construct enables the use of Handlebars templates as Userdata. Often times UserData scripts are long, complex, and require inserting other variables from your environment. This construct extends the base functionality of the default ec2.UserData class to include Handlebars.
## Usage
```typescript
import { HandlebarsUserData } from '@arhea/aws-userdata-handlebars';
import * as path from 'path';
// create our object
// for Windows add .forWindows() instead of .forLinux()
const webUserData = HandlebarsUserData.forLinux();
// load the template file
webUserData.addTemplateFile(path.join(__dirname, 'userdata', 'webserver.handlebars'));
// add data to the template in a key, value format
webUserData.addData('loadBalancerUrl', `http://${app.loadBalancerDnsName}`);
```
## Useful commands
* `npm run build` compile typescript to js
* `npm run watch` watch for changes and compile
* `npm run test` perform the jest unit tests