cloudformation-resources
TypeScript icon, indicating that this package has built-in type declarations

1.7.0 • Public • Published

CloudFormation Resource Identifiers

I was tired of passing string values as CDK resource type identifiers in my TypeScript projects, so I scraped AWS's docs and built a class-based typeset of (a handful of) identifiers.

We have a type system; we can do better. Except for the project name: that bit remains completely terrible.

Installation

npm

npm i --save-dev cloudformation-resources

Yarn

yarn add --dev cloudformation-resources

Usage

In your CDK TypeScript files:

import { Template } from "aws-cdk-lib/assertions";
import { AWS } from "cloudformation-resources";

const app = newApp("dev");
const stack = new VpcStack(app, "vpc-stack", {});

const template = Template.fromStack(stack);
template.resourceCountIs(AWS.EC2.VPC, 1); // instead of the wholly-gnarly "AWS::EC2::VPC"

Alternatively, you can import just the service set:

import { EC2 } from "cloudformation-resources/ec2";

const app = newApp("dev");
const stack = new VpcStack(app, "vpc-stack", {});

const template = Template.fromStack(stack);
template.resourceCountIs(EC2.VPC, 1);

Building Typesets

Building (or re-building) the identifier sets requires Deno. To scrape the AWS docs and generate the TypeScript files, run:

deno run --allow-net --allow-write --allow-read scripts/scrape-identifiers.ts

Contributing

Pull requests are welcome. To add services, add them to servicePages in scripts/scrape-identifiers.ts, then run the build command.

[!IMPORTANT] Be sure to run deno fmt before committing to ensure consistent formatting.

/cloudformation-resources/

    Package Sidebar

    Install

    npm i cloudformation-resources

    Weekly Downloads

    28

    Version

    1.7.0

    License

    MIT

    Unpacked Size

    125 kB

    Total Files

    103

    Last publish

    Collaborators

    • ovao