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 🙏

© 2021 – Pkg Stats / Ryan Hefner

cdk-dasm

v1.115.0

Published

AWS CDK disassembler: convert CloudFormation to code

Downloads

1,431

Readme

CDK CloudFormation Disassembler

experimental


WIP - this module is still not fully functional:

  • [ ] Does not handle intrinsic functions
  • [ ] Only handles the "Resources" section (parameters, outputs, mappings, conditions, ...)
  • [ ] Keys in JSON blobs (such as IAM policies) are converted to camel case (instead of remain as pascal case).
  • [ ] Only TypeScript is supported

Converts an AWS CloudFormation template into AWS CDK code which synthesizes the same exact template.

Why you should not use this tool?

Generally, this is not a recommended approach when using the AWS CDK, but some people may find this useful as a means to get started or migrate an existing template.

Using this method means that you will have to use the low-level resources (e.g. s3.CfnBucket instead of s3.Bucket). This means that you lose a substantial portion of the value of the CDK, which abstracts away much of the boilerplate and glue logic required to work with AWS resources.

For example, this is how you would define an S3 bucket encrypted with a KMS key with high-level resources:

new s3.Bucket(this, 'MyBucket', {
  encryption: s3.BucketEncryption.Kms
});

And this is how the same exact configuration will be defined using low-level resources:

new kms.CfnKey(this, 'MyBucketKeyC17130CF', {
    keyPolicy: {
      "statement": [
        {
          "action": [ "kms:Create*", "kms:Describe*", "kms:Enable*", "kms:List*", "kms:Put*", "kms:Update*", "kms:Revoke*", "kms:Disable*", "kms:Get*", "kms:Delete*", "kms:ScheduleKeyDeletion", "kms:CancelKeyDeletion" ],
          "effect": "Allow",
          "principal": {
            "aws": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":iam::", { "Ref": "AWS::AccountId" }, ":root" ] ] }
          },
          "resource": "*"
        }
      ],
      "version": "2012-10-17"
    }
});

new s3.CfnBucket(this, 'MyBucketF68F3FF0', {
    bucketEncryption: {
      "serverSideEncryptionConfiguration": [
        {
          "serverSideEncryptionByDefault": {
            "kmsMasterKeyId": Fn.getAtt('MyBucketKeyC17130CF', 'Arn').toString(),
            "sseAlgorithm": "aws:kms"
          }
        }
      ]
    },
});

As you can see, there are a lot of details here that you really don't want to care about (like the value to put under sseAlgorithm or which actions are required in the key policy so the key can be managed by administrators. Also, this is actually one of the more simple examples we have in the CDK.

The AWS Construct Library includes a very large amount of "undifferentiated heavy lifting" that you can only enjoy if you use the high level resources which encapsulate all this goodness for you behind a nice clean object-oriented API.

Therefore, we encourage you to use the high-level constructs in the AWS Construct Library as much as possible. If you encounter a gap or missing capability or resource, take a look at the Escape Hatches section of the User Guide.

Usage

$ cdk-dasm < my-stack-template.json > my-stack.ts

For example, given:

{
  "Resources": {
    "MyTopic": {
      "Type": "AWS::SNS::Topic",
      "Properties": {
        "DisplayName": "YoTopic"
      }
    }
  }
}

The output will be:

// generated by cdk-dasm at 2019-08-07T02:52:01.561Z

import { Stack, StackProps, Construct, Fn } from '@aws-cdk/core';
import * as sns from '@aws-cdk/aws-sns';

export class MyStack extends Stack {
    constructor(scope: Construct, id: string, props: StackProps = {}) {
        super(scope, id, props);
        new sns.CfnTopic(this, 'MyTopic', {
            displayName: "YoTopic",
        });
    }
}