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-cdk-gen

v0.2.1

Published

Opinionated tool to generate Typescript AWS CDK constructs.

Downloads

21

Readme

Typescript AWS CDK Generator: aws-cdk-gen

This project allows you to generate Typescript constructs for a variety of common AWS CDK use cases. It was built using PlopJS.

Why?

The hope is that you will be able to use this tool to remove boilerplate code and get 90% of the code needed with a few key strokes.

Additionally, new developers can learn how to connect CDK constructs in a project with minimum changes.

Library In Action

Here is an example of generating a Go Lambda.

alt text

Here is an example of the outputted files.

alt text

As you can see it generates the Lambda construct, a Lambda integration, and a directory that contains a Go program as well as a build script. This gives a developer all they need to get started.

Caveats

This tool has a few caveats.

  1. This tool is opinionated in the sense that it generates files at set paths.

  2. This initial version is based on aws-cdk version 1.85.0. As a result, it may not work with older CDK projects.

  3. There are a number of experimental constructs used in this package that are not in active development. As a result, some of the construct's may not work in the future. I plan on moving to more stable constructs in future releases.

  4. The user needs to install any missing dependencies.

Installation

npm install --save-dev aws-cdk-gen

Getting started

Create a script in your package.json to generate CDK constructs. For example

"scripts": {
    "aws-cdk-gen": "aws-cdk-gen"
}

Run your script and that's it!

Base Generators Available

There a few constructs available upon starting the tool in a new CDK project. Below is a screenshot of the initial options available.

alt text

Here are a description of the various options.

  • Go Lambda - Generate a Go Lambda with an example handler. You need to build the Go artifact to successfully deploy. Please follow the README in the generated handler files. Uses experimental construct.

    • Inputs:
      • Lambda Name
    • Outputs:
      • S3 Asset
      • Standard Lambda Function
      • Api Gateway V2 Lambda Integration
      • example Go main file
      • README on build process
      • shell script to automate build
  • NodeJS Lambda - Generate a NodeJS Lambda with an example handler. Uses experimental construct.

    • Inputs:
      • Lambda Name
    • Outputs:
      • NodeJS Experimental Lambda Function
      • Api Gateway V2 Lambda Integration
      • example JS handler
  • S3 Bucket - Basic S3 Bucket construct.

    • Inputs:
      • Bucket Name
    • Outputs:
      • S3 Bucket Construct
  • API Gateway - Generate an API Gateway. Needed to add a Lambda Route or generate a DynamoDb stack.

    • Inputs:
      • Api Gateway Name
    • Outputs:
      • Api GatewayV2 Construct

Note: The comments in the generated API Gateway construct file are used to inject code. It is not recommended to delete them.

Generators Available With Dependencies

There are a few generators that are dependent on other constructs to have been generated. As a result, they are initially hidden from the user.

Below is a screenshot of the hidden options available.

alt text

Here are a description of the various options.

  • Add Lambda Route - Generate a route for a Lambda to an existing API Gateway. Requires the creation of both a Lambda and an API Gateway to see the options.

    • Inputs:
      • Select API GatewayV2 - select from list of previously generated gateways.
      • Select API GatewayV2 Lambda Integration - select from list of previously generated lambda integrations.
      • Define Route for Lambda - enter string for route. Ex. "/users/".
    • Outputs:
      • Imports Lambda Integration into Api Gateway construct. Adds a route for the Lambda to the Gateway.
  • DynamoDB and Lambdas - Generate a DynamoDB table and 4 Lambdas with example handlers. The handlers cover GET, POST, PUT, and DELETE. You will need to configure a data schema to properly use this function. Requires the creation of an API Gateway to see the option.

    • Inputs:
      • Select API GatewayV2 - select from list of previously generated gateways.
      • Name your Table - Enter string for your table.
      • Select a name for your Lambdas - Enter string for Lambdas. Will be used for all 4 Lambdas.
      • Define Route for Lambdas - enter string for route. Ex. "/users/". Will be used for all 4 Lambdas.
    • Outputs:
      • Will have one main DynamoDB construct. It contains:
        • 1 DynamoDB Table
        • 4 NodeJS Lambdas granted access to the table and passed the table name as environment variable
        • 4 LambdaProxy Integrations
      • Will output a handler folder with 4 different JS handler files.
      • Will add 4 routes to the API Gateway that you selected.

License

Licensed under MIT

Copyright (c) 2021 Jayson Alzate