access user-data on EC2 machines
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
test
.gitignore
.travis.yml
Jakefile.js
Readme.md
package.json

Readme.md

ec-user-data

A very simple library to access user-data on EC2 machines (or a configuration file called ${HOME}\.deployer.json everywhere else).

This library first check of the existence of a file called ${HOME}\.deployer.json. If this file exists, the content of the file is parsed and, if the file contains valid JSON, the content is returned.

If there is no ${HOME}\.deployer.json, the library tries to access AWS Instance Metadata. In particular, this library accesses information passed using the user-data field that can be passed when launching an instance.

Command-Line Example

ubuntu@ip-10-252-172-224:/tmp$ node_modules/.bin/ec2-user-data
config= {"aws-logging":true,"application-name":"deployer","aws-log-bucket":"tmw-tailoring-qa-logs","aws-region":"us-west-2","local-ipv4":"10.252.172.224","aws-access-key-id":"AKIAJKRUL44GH2U7AP5Q","aws-secret-access-key":"EVQKm+xVCjhwbjZOlOqxDpf+eBFSIaSK13Um0uFQ","manifest":"s3://tmw-tailoring-qa/config/tailoring.json"}

Node.js Example

var config = require("ec-user-data");

return config(function (err, config) {
   if (err) {
       return console.error("retrieving config failed", err);
   }

    console.log("config=", JSON.stringify(config));
});

License

MIT License