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

dynamoose-to-cloudformation

v0.2.4

Published

A beta release of a cloudformation yml generation from dynamoose models

Downloads

34

Readme

dynamoose-to-cloudformation

beta release

How to use

  • The tool is installed locally to your project
  • The tool is used via command line (including a package.json script)
  • Available cli arguments:
  Usage: index [options]

  Options:

    -v, --version                                   output the version number
    -i, --input [fullpath]                          The es5 input file to parse. Expects the said file to offer a std module.exports object containing name and attributes
    -d, --dir                                       If present the tool will attempt to scrape all the 1st level files found in the folder, if not present then the tool will assume the input is a file
    -o, --output [fullpath]                         The output path including filename to place the file
    --WriteScalingPolicyTarget [integer]            WriteScalingPolicyTarget integer, defualt is 50
    --ReadScalingPolicyTarget [integer]             ReadScalingPolicyTarget integer, defualt is 50
    --WriteScalingPolicyScaleInCooldown [integer]   WriteScalingPolicyScaleInCooldown integer, defualt is 60
    --WriteScalingPolicyScaleOutCooldown [integer]  WriteScalingPolicyScaleOutCooldown integer, defualt is 60
    --ReadScalingPolicyScaleInCooldown [integer]    ReadScalingPolicyScaleInCooldown integer, defualt is 60
    --ReadScalingPolicyScaleOutCooldown [integer]   ReadScalingPolicyScaleOutCooldown integer, defualt is 60
    --TableReadCapacityUnits [integer]              TableReadCapacityUnits integer, defualt is 15
    --TableWriteCapacityUnits [integer]             TableWriteCapacityUnits integer, defualt is 15
    --TableReadMinCap [integer]                     TableReadMinCap integer, defualt is 15
    --TableReadMaxCap [integer]                     TableReadMaxCap integer, defualt is 15
    --TableWriteMinCap [integer]                    TableWriteMinCap integer, defualt is 15
    --TableWriteMaxCap [integer]                    TableWriteMaxCap integer, defualt is 15
    -s --streams [list]                             Comma separated list of tables names to add streams, eg users,songs
    -p --tableNamePrefix [string]                   The table name prefix as a string eg "wcp_live_"
    -h, --help                                      output usage information
    

Example usage

NB this is referring to the example models in this repo. The below example will extract all the js model files from the directory ./models and output a complete yml. It will also add streams to the table User.

node ./index.js -i ./models -d -o dynamodb/descriptions/streamsPrefix.yml -s User,Hashing -p Live

For more examples, take a look at the package.json in this project.

The above example will output the following:

Description: 'Dynamodb cloudformation schema including scaling from https://www.npmjs.com/package/dynamoose-to-cloudformation'
Parameters:
  WriteScalingPolicyTarget:
    Type: Number
    Default: 50
  ReadScalingPolicyTarget:
    Type: Number
    Default: 50
  WriteScalingPolicyScaleInCooldown:
    Type: Number
    Default: 60
  WriteScalingPolicyScaleOutCooldown:
    Type: Number
    Default: 60
  ReadScalingPolicyScaleInCooldown:
    Type: Number
    Default: 60
  ReadScalingPolicyScaleOutCooldown:
    Type: Number
    Default: 60
  TableLiveHashingReadCapacityUnits:
    Description: ReadCapacityUnits for the table
    Type: Number
    Default: 15
  TableLiveHashingWriteCapacityUnits:
    Description: WriteCapacityUnits for the table
    Type: Number
    Default: 15
  TableLiveHashingReadMinCap:
    Type: Number
    Default: 15
  TableLiveHashingReadMaxCap:
    Type: Number
    Default: 15
  TableLiveHashingWriteMinCap:
    Type: Number
    Default: 15
  TableLiveHashingWriteMaxCap:
    Type: Number
    Default: 15
  TableLiveProductsReadCapacityUnits:
    Description: ReadCapacityUnits for the table
    Type: Number
    Default: 15
  TableLiveProductsWriteCapacityUnits:
    Description: WriteCapacityUnits for the table
    Type: Number
    Default: 15
  TableLiveProductsReadMinCap:
    Type: Number
    Default: 15
  TableLiveProductsReadMaxCap:
    Type: Number
    Default: 15
  TableLiveProductsWriteMinCap:
    Type: Number
    Default: 15
  TableLiveProductsWriteMaxCap:
    Type: Number
    Default: 15
  TableLiveUserReadCapacityUnits:
    Description: ReadCapacityUnits for the table
    Type: Number
    Default: 15
  TableLiveUserWriteCapacityUnits:
    Description: WriteCapacityUnits for the table
    Type: Number
    Default: 15
  TableLiveUserReadMinCap:
    Type: Number
    Default: 15
  TableLiveUserReadMaxCap:
    Type: Number
    Default: 15
  TableLiveUserWriteMinCap:
    Type: Number
    Default: 15
  TableLiveUserWriteMaxCap:
    Type: Number
    Default: 15
Outputs:
  TableLiveHashingStreamARN:
    Value: !GetAtt TableLiveHashing.StreamArn
    Export:
      Name:
        'Fn::Sub': '${AWS::StackName}-Hg'
  TableLiveUserStreamARN:
    Value: !GetAtt TableLiveUser.StreamArn
    Export:
      Name:
        'Fn::Sub': '${AWS::StackName}-Ur'
Resources:
  TableLiveHashing:
    Type: 'AWS::DynamoDB::Table'
    Properties:
      TableName: LiveHashing
      AttributeDefinitions:
        - AttributeName: id
          AttributeType: S
        - AttributeName: userId
          AttributeType: S
      KeySchema:
        - AttributeName: id
          KeyType: HASH
        - AttributeName: userId
          KeyType: RANGE
      ProvisionedThroughput:
        ReadCapacityUnits: !Ref TableLiveHashingReadCapacityUnits
        WriteCapacityUnits: !Ref TableLiveHashingWriteCapacityUnits
      StreamSpecification:
        StreamViewType: NEW_AND_OLD_IMAGES
  TableLiveHashingWriteScalableTarget:
    Type: 'AWS::ApplicationAutoScaling::ScalableTarget'
    Properties:
      MaxCapacity: !Ref TableLiveHashingWriteMaxCap
      MinCapacity: !Ref TableLiveHashingWriteMinCap
      ResourceId: !Join
        - /
        - - table
          - !Ref TableLiveHashing
      RoleARN: !Sub  arn:aws:iam::${AWS::AccountId}:role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_DynamoDBTable
      ScalableDimension: 'dynamodb:table:WriteCapacityUnits'
      ServiceNamespace: dynamodb
  TableLiveHashingReadScalableTarget:
    Type: 'AWS::ApplicationAutoScaling::ScalableTarget'
    Properties:
      MaxCapacity: !Ref TableLiveHashingReadMaxCap
      MinCapacity: !Ref TableLiveHashingReadMinCap
      ResourceId: !Join
        - /
        - - table
          - !Ref TableLiveHashing
      RoleARN: !Sub  arn:aws:iam::${AWS::AccountId}:role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_DynamoDBTable
      ScalableDimension: 'dynamodb:table:ReadCapacityUnits'
      ServiceNamespace: dynamodb
  TableLiveHashingWriteScalingPolicy:
    Type: 'AWS::ApplicationAutoScaling::ScalingPolicy'
    Properties:
      PolicyName: WriteAutoScalingPolicy
      PolicyType: TargetTrackingScaling
      ScalingTargetId: !Ref TableLiveHashingWriteScalableTarget
      TargetTrackingScalingPolicyConfiguration:
        TargetValue: !Ref WriteScalingPolicyTarget
        ScaleInCooldown: !Ref WriteScalingPolicyScaleInCooldown
        ScaleOutCooldown: !Ref WriteScalingPolicyScaleOutCooldown
        PredefinedMetricSpecification:
          PredefinedMetricType: DynamoDBWriteCapacityUtilization
  TableLiveHashingReadScalingPolicy:
    Type: 'AWS::ApplicationAutoScaling::ScalingPolicy'
    Properties:
      PolicyName: ReadAutoScalingPolicy
      PolicyType: TargetTrackingScaling
      ScalingTargetId: !Ref TableLiveHashingReadScalableTarget
      TargetTrackingScalingPolicyConfiguration:
        TargetValue: !Ref ReadScalingPolicyTarget
        ScaleInCooldown: !Ref ReadScalingPolicyScaleInCooldown
        ScaleOutCooldown: !Ref ReadScalingPolicyScaleOutCooldown
        PredefinedMetricSpecification:
          PredefinedMetricType: DynamoDBReadCapacityUtilization
  TableLiveProducts:
    Type: 'AWS::DynamoDB::Table'
    Properties:
      TableName: LiveProducts
      AttributeDefinitions:
        - AttributeName: id
          AttributeType: S
        - AttributeName: name
          AttributeType: S
      KeySchema:
        - AttributeName: id
          KeyType: HASH
        - AttributeName: name
          KeyType: RANGE
      ProvisionedThroughput:
        ReadCapacityUnits: !Ref TableLiveProductsReadCapacityUnits
        WriteCapacityUnits: !Ref TableLiveProductsWriteCapacityUnits
  TableLiveProductsWriteScalableTarget:
    Type: 'AWS::ApplicationAutoScaling::ScalableTarget'
    Properties:
      MaxCapacity: !Ref TableLiveProductsWriteMaxCap
      MinCapacity: !Ref TableLiveProductsWriteMinCap
      ResourceId: !Join
        - /
        - - table
          - !Ref TableLiveProducts
      RoleARN: !Sub  arn:aws:iam::${AWS::AccountId}:role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_DynamoDBTable
      ScalableDimension: 'dynamodb:table:WriteCapacityUnits'
      ServiceNamespace: dynamodb
  TableLiveProductsReadScalableTarget:
    Type: 'AWS::ApplicationAutoScaling::ScalableTarget'
    Properties:
      MaxCapacity: !Ref TableLiveProductsReadMaxCap
      MinCapacity: !Ref TableLiveProductsReadMinCap
      ResourceId: !Join
        - /
        - - table
          - !Ref TableLiveProducts
      RoleARN: !Sub  arn:aws:iam::${AWS::AccountId}:role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_DynamoDBTable
      ScalableDimension: 'dynamodb:table:ReadCapacityUnits'
      ServiceNamespace: dynamodb
  TableLiveProductsWriteScalingPolicy:
    Type: 'AWS::ApplicationAutoScaling::ScalingPolicy'
    Properties:
      PolicyName: WriteAutoScalingPolicy
      PolicyType: TargetTrackingScaling
      ScalingTargetId: !Ref TableLiveProductsWriteScalableTarget
      TargetTrackingScalingPolicyConfiguration:
        TargetValue: !Ref WriteScalingPolicyTarget
        ScaleInCooldown: !Ref WriteScalingPolicyScaleInCooldown
        ScaleOutCooldown: !Ref WriteScalingPolicyScaleOutCooldown
        PredefinedMetricSpecification:
          PredefinedMetricType: DynamoDBWriteCapacityUtilization
  TableLiveProductsReadScalingPolicy:
    Type: 'AWS::ApplicationAutoScaling::ScalingPolicy'
    Properties:
      PolicyName: ReadAutoScalingPolicy
      PolicyType: TargetTrackingScaling
      ScalingTargetId: !Ref TableLiveProductsReadScalableTarget
      TargetTrackingScalingPolicyConfiguration:
        TargetValue: !Ref ReadScalingPolicyTarget
        ScaleInCooldown: !Ref ReadScalingPolicyScaleInCooldown
        ScaleOutCooldown: !Ref ReadScalingPolicyScaleOutCooldown
        PredefinedMetricSpecification:
          PredefinedMetricType: DynamoDBReadCapacityUtilization
  TableLiveUser:
    Type: 'AWS::DynamoDB::Table'
    Properties:
      TableName: LiveUser
      AttributeDefinitions:
        - AttributeName: id
          AttributeType: S
        - AttributeName: forename
          AttributeType: S
      KeySchema:
        - AttributeName: id
          KeyType: HASH
        - AttributeName: forename
          KeyType: RANGE
      ProvisionedThroughput:
        ReadCapacityUnits: !Ref TableLiveUserReadCapacityUnits
        WriteCapacityUnits: !Ref TableLiveUserWriteCapacityUnits
      StreamSpecification:
        StreamViewType: NEW_AND_OLD_IMAGES
  TableLiveUserWriteScalableTarget:
    Type: 'AWS::ApplicationAutoScaling::ScalableTarget'
    Properties:
      MaxCapacity: !Ref TableLiveUserWriteMaxCap
      MinCapacity: !Ref TableLiveUserWriteMinCap
      ResourceId: !Join
        - /
        - - table
          - !Ref TableLiveUser
      RoleARN: !Sub  arn:aws:iam::${AWS::AccountId}:role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_DynamoDBTable
      ScalableDimension: 'dynamodb:table:WriteCapacityUnits'
      ServiceNamespace: dynamodb
  TableLiveUserReadScalableTarget:
    Type: 'AWS::ApplicationAutoScaling::ScalableTarget'
    Properties:
      MaxCapacity: !Ref TableLiveUserReadMaxCap
      MinCapacity: !Ref TableLiveUserReadMinCap
      ResourceId: !Join
        - /
        - - table
          - !Ref TableLiveUser
      RoleARN: !Sub  arn:aws:iam::${AWS::AccountId}:role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_DynamoDBTable
      ScalableDimension: 'dynamodb:table:ReadCapacityUnits'
      ServiceNamespace: dynamodb
  TableLiveUserWriteScalingPolicy:
    Type: 'AWS::ApplicationAutoScaling::ScalingPolicy'
    Properties:
      PolicyName: WriteAutoScalingPolicy
      PolicyType: TargetTrackingScaling
      ScalingTargetId: !Ref TableLiveUserWriteScalableTarget
      TargetTrackingScalingPolicyConfiguration:
        TargetValue: !Ref WriteScalingPolicyTarget
        ScaleInCooldown: !Ref WriteScalingPolicyScaleInCooldown
        ScaleOutCooldown: !Ref WriteScalingPolicyScaleOutCooldown
        PredefinedMetricSpecification:
          PredefinedMetricType: DynamoDBWriteCapacityUtilization
  TableLiveUserReadScalingPolicy:
    Type: 'AWS::ApplicationAutoScaling::ScalingPolicy'
    Properties:
      PolicyName: ReadAutoScalingPolicy
      PolicyType: TargetTrackingScaling
      ScalingTargetId: !Ref TableLiveUserReadScalableTarget
      TargetTrackingScalingPolicyConfiguration:
        TargetValue: !Ref ReadScalingPolicyTarget
        ScaleInCooldown: !Ref ReadScalingPolicyScaleInCooldown
        ScaleOutCooldown: !Ref ReadScalingPolicyScaleOutCooldown
        PredefinedMetricSpecification:
          PredefinedMetricType: DynamoDBReadCapacityUtilization

Current known limitations

  • The tool can only create simple secondary RANGE indexes of the name of the attribute.
  • Secondary indexes of alternate names to their attribute are currently not possible.
  • Global indexes are not currently possible.