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

cloudcraft

v1.0.0

Published

Node.js SDK for rendering AWS and Azure diagrams using the Cloudcraft API.

Downloads

14

Readme

Cloudcraft Node.js Library

License: Apache-2.0 Build Status

Cloudcraft diagram

Visualize your cloud architecture with Cloudcraft by Datadog, the best way to create smart AWS and Azure diagrams.

Cloudcraft supports both manual and programmatic diagramming, as well as automatic reverse engineering of existing cloud environments into beautiful system architecture diagrams.

This cloudcraft Node library provides an easy-to-use native Node SDK for interacting with the Cloudcraft API.

Use case examples:

  • Snapshot and visually compare your live AWS or Azure environment before and after a deployment, in your app or as part of your automated CI pipeline
  • Download an inventory of all your cloud resources from a linked account as JSON
  • Write a converter from a third party data format to Cloudcraft diagrams
  • Backup, export & import your Cloudcraft data
  • Programmatically create Cloudcraft diagrams

This SDK requires a Cloudcraft API key to use. A free trial of Cloudcraft Pro with API access is available.

Requirements

Node 22 or higher.

Installation

To install cloudcraft, run:

npm install cloudcraft --save

Or, if you prefer yarn:

yarn add cloudcraft

Usage

The API is accessed through the Cloudcraft class. An API key available through the Cloudcraft user interface is required when instantiating Cloudcraft. It can be passed to the class as an argument or through the CLOUDCRAFT_API_KEY environment variable:

import { Cloudcraft } from 'Cloudcraft';

const client = new Cloudcraft('api_key...');

(async () => {
    const user = await client.user.me();

    console.log(user.name);
})();

Configuration

Initialize with config object

The package can be initialized with several options:

import { Cloudcraft } from 'Cloudcraft';

const client = new Cloudcraft('api_key...', {
    host: 'customhost',
});

| Option | Default | Description | | ------------------- | --------------------- | ------------------------------------------------ | | maxNetworkRetries | 10 | The amount of times a request should be retried. | | timeout | 80_000 | Maximum time each request can take in ms. | | host | 'api.cloudcraft.co' | Host that requests are made to. | | port | 443 | Port that requests are made to. | | protocol | 'https' | 'https' or 'http'. |

Blueprints

List my blueprints

const client = new Cloudcraft();

const blueprints = await client.blueprint.list();

Retrieve blueprint

const client = new Cloudcraft();

const blueprint = await client.blueprint.get('id');

Create blueprint

const client = new Cloudcraft();

const blueprint = await client.blueprint.create({
    data: {
        grid: 'standard',
        name: 'My new blueprint',
    },
});

Update blueprint

const client = new Cloudcraft();

const blueprint = await client.blueprint.get('id');
blueprint.data.name = 'My updated blueprint';

await client.blueprint.update(blueprint);

Export blueprint as image

const client = new Cloudcraft();

const blueprint = await client.blueprint.get('id');
const svg = (await client.blueprint.export(
  blueprint.id,
  Cloudcraft.BlueprintFormat.SVG
)) as string;

Delete blueprint

const client = new Cloudcraft();

const blueprint = await client.blueprint.get('id');
await client.blueprint.delete(blueprint.id);

AWS Accounts

Add AWS account

const client = new Cloudcraft();

const awsAccount = await client.awsAccount.create(
    {
        name: 'Test account',
        roleArn: 'arn:...',
    },
    'us-east-1',
);

List my AWS accounts

const client = new Cloudcraft();

const awsAccounts = await client.awsAccount.list();

Snapshot AWS account

const client = new Cloudcraft();

const awsAccounts = await client.awsAccount.list();
const awsAccount = awsAccounts.find(
  (awsAccount) => awsAccount.id === 'id'
) as any;
const svg = (await client.awsAccount.snapshot(
  awsAccount.id,
  'us-east-1',
  Cloudcraft.BlueprintFormat.SVG
)) as string;

Update AWS account

const client = new Cloudcraft();

const awsAccounts = await client.awsAccount.list();
const awsAccount = awsAccounts.find(
  (awsAccount) => awsAccount.id === 'id'
) as any;
awsAccount.name = 'Updated account';

const updatedAWSAccount = await client.awsAccount.update(awsAccount);

Delete AWS account

const client = new Cloudcraft();

const awsAccounts = await client.awsAccount.list();
const awsAccount = awsAccounts.find(
  (awsAccount) => awsAccount.id === 'id'
) as any;
await client.awsAccount.delete(awsAccount.id);

Get my AWS IAM Role parameters

const client = new Cloudcraft();

const iamParameters = await client.awsAccount.iamParameters();

Budgets

Export budget for a blueprint

const client = new Cloudcraft();

const blueprint = await client.blueprint.create(testBlueprint);

const csv = (await client.budget.export(
  blueprint.id,
  Cloudcraft.BudgetFormat.CSV
)) as string;

Users

Get my information

const client = new Cloudcraft();

const user = await client.user.me();

Contributing

Anyone can help make cloudcraft better. Check out the contribution guidelines for more information.


Released under the Apache-2.0 License.