npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aws-setup

v0.2.3

Published

A Node Module and Command Line Tool for initializing AWS setups via JSON, YAML or JS scripts.

Downloads

11

Readme

aws-setup

A Node Module and Command Line Tool for initializing AWS setups via JSON, YAML or JS scripts.

It allows you to define your entire AWS server setup, simple or complex, simple files. You can use variables and formatters if your definitions need to be dynamic!

Install

npm install aws-setup

To use aws-setup in your command line, add aws-setup/bin to your PATH environment variable.

Examples

Static setup

Let's assume you have a config file MyServer.json looking like that:

{
    "Main": {
        "steps": ["c-sg", "u-sg", "c-i"],

        "securityGroup": {
            "GroupName": "main-sg-1",
            "Description": "Main SG 1"
        },

        "securityGroupIngress": {
            "GroupName": "main-sg-1",
            "IpPermissions": [{
                "IpProtocol": "tcp",
                "FromPort": 80,
                "ToPort": 80,
                "IpRanges": [{"CidrIp": "0.0.0.0/0"}]
            }]
        },

        "instances": {
            "ImageId": "ami-123d5c4a",
            "MinCount": 1,
            "MaxCount": 1,
            "KeyName": "myKeyPair",
            "SecurityGroups": ["main-sg-1"],
            "InstanceType": "t1.micro",
            "UserData": "VGVzdEluc3RhbmNl"
        }
    }
}

You can setup the security group, grant global access via port 80 and launch an instance inside it with

aws-setup -i MyServer.json

If you want to split this action into two commands, which is quite useful when working on AWS (e.g. to wait for an instance to start/terminate/...), do

aws-setup -i MyServer.json -g Main -s c-sg,u-sg
aws-setup -i MyServer.json -g Main -s c-i

The first command creates the security group (c-sg) and updates its permissions (u-sg), while the second command creates the new instance (c-i). Those abbreviated commands are called steps (-s).

The naming scheme of the steps are defined in the default stepmap and can be customized. See below for more information (recommended).

Both commands have the -g Main argument meaning that the definitions of group (-g) Main is loaded, which clearly is the name of the top-level object in our MyServer.json file.

Dynamic setup

The static example above has some drawbacks: e.g. if you want to use an other AMI you have to update the entry manually in your MyServer.json file. In this case, you can use variables (${}).

In this example, we set the "ImageId" entry to

"ImageId": "${amiId}"

and call aws-setup with

aws-setup -i MyServer.json -p amiId=ami-NEWAMIID

You can even set default values via

"ImageId": "${amiId|ami-DEFAULTAMIID}"

Another drawback would be the use of static UserData which must be base64 encoded (see ec2 docs). This is a greate usecase for formatters (%{}).

We can set the "UserData" entry to

"UserData": "%{base64:MyData}"

base64 is defined in formatters.js but you can also use your own ones. See below for more information.

You can even combine variables and formatters, e.g.

"UserData": "%{base64:${userData}}"

plus

aws-setup -i MyServer.json -p userData=MyData

Description

This is what you get when you type aws-setup --help (as of version 0.2.3):

$> aws-setup --help

  Usage: aws-setup [options]

  Options:

    -h, --help                       output usage information
    -d, --setups-dir [DIR]           the location of your setups/ folder, default: ./setups
    -i, --setup-file [FILE]          the setup file, relative to <setups-dir>, default: setup(.json|.yml|.js)
    -m, --step-map [FILE]            an additional step mapping json file, relative to <setups-dir>, default: stepmap.json
    -f, --formatters [FILE]          an additional file containing formatters, relative to <setups-dir>, default: formatters.js
    -g, --group [NAME[,...]]         the group to setup, accepts a list, default: all groups
    -s, --steps [NAME[,...]]         the steps to execute, accepts a list (,) or a list of lists (:), default: all steps
    -p, --payload [KEY=VALUE,[...]]  payload that is parsed into your definitions
    -c, --config-file [FILE]         the location of your AWS config/credentials, environment variables are used when missing
    -t, --timeout [SECONDS]          adds delays between the execution of steps, default: 0
    -l, --log-level [LEVEL]          the log level, {all,debug,info,warning,error,fatal}, default: info
    -e, --execute                    execute without prompting
    -a, --abort                      abort when a request failed
    -V, --version                    output the version number

Step Mapping

TODO

Formatters

TODO

Development

Authors

Marcel R.