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 🙏

© 2025 – Pkg Stats / Ryan Hefner

aws-iac-gen

v0.2.3

Published

Infrastructure-as-Code generator CLI

Downloads

18

Readme

aws-iac-gen

AWS Infrastructure as Code Generator - A CLI tool for generating CloudFormation templates from existing AWS resources.

Overview

aws-iac-gen (or iac-gen for short) helps you generate CloudFormation templates from your existing AWS resources. It uses AWS CloudFormation's resource scanning capabilities to discover resources in your account and convert them into reusable Infrastructure as Code templates.

Features

  • Resource Scanning: Scan your AWS account for existing resources
  • Resource Discovery: List and select from previous resource scans
  • Template Generation: Convert discovered resources into CloudFormation templates
  • Stack Filtering: Automatically excludes resources managed by existing CloudFormation stacks
  • Real-time Progress: Visual feedback with spinners during long operations
  • Resource Limits: Built-in warnings and errors for AWS limits (500 resources per template)

Installation

npm install -g aws-iac-gen

Or install from source:

git clone https://github.com/krzmknt/aws-iac-gen.git
cd aws-iac-gen
npm install
npm run build
npm link

Prerequisites

  • Node.js 18 or higher
  • AWS CLI configured with appropriate credentials
  • AWS permissions for CloudFormation resource scanning and template generation

Usage

Commands

iac-gen resources

Download AWS resources from a scan.

Options:

  • --new-scan - Start a new resource scan
  • --from-scan - Choose from existing scans
  • -o, --output <file> - Output file name (default: resources.json)

Examples:

# Start a new scan and save resources
iac-gen resources --new-scan

# Choose from existing scans
iac-gen resources --from-scan

# Specify custom output file
iac-gen resources --new-scan -o my-resources.json

iac-gen template

Generate a CloudFormation template from resources.

Options:

  • -i, --input <file> - Input resources file (default: resources.json)
  • -o, --output <file> - Output template file (default: template.json)
  • --from-stack <stack> - Use an existing stack as the template base

Examples:

# Generate template from resources.json
iac-gen template

# Use custom input/output files
iac-gen template -i my-resources.json -o my-template.yaml

# Generate template from existing stack
iac-gen template --from-stack my-existing-stack

Workflow Example

  1. Scan for resources:

    iac-gen resources --new-scan
  2. Review the resources (optional):

    cat resources.json | jq '.[] | .ResourceType' | sort | uniq -c
  3. Generate CloudFormation template:

    iac-gen template
  4. Deploy the template (using AWS CLI):

    aws cloudformation create-stack \
      --stack-name my-new-stack \
      --template-body file://template.json

Important Notes

Resource Limits

  • AWS CloudFormation supports a maximum of 500 resources per template
  • The tool will warn when your scan contains more than 500 resources
  • Template generation will fail if you try to process more than 500 resources

Stack-Managed Resources

  • Resources already managed by CloudFormation stacks are automatically filtered out
  • The tool shows how many stack-managed resources were excluded

Scan Status

  • Only COMPLETE scans can be used for resource extraction
  • The tool will error if you select a scan that is still IN_PROGRESS or FAILED

Configuration

The tool uses your AWS CLI configuration. Set your region using:

export AWS_REGION=us-east-1
# or
export AWS_DEFAULT_REGION=us-east-1

Development

# Install dependencies
npm install

# Run in development mode
npm run dev -- [command] [options]

# Build
npm run build

# Lint
npm run lint

# Format code
npm run format

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Troubleshooting

"No scans found" error

  • Ensure you have run at least one scan using iac-gen resources --new-scan
  • Check that you're in the correct AWS region

"Selected scan is in IN_PROGRESS status" error

  • Wait for the scan to complete (usually takes a few minutes)
  • Resource scans must be in COMPLETE status to extract resources

"Resources file contains X resources, which exceeds the AWS limit of 500" error

  • Filter your resources before generating a template
  • Consider splitting resources into multiple templates
  • Remove unnecessary resource types from the JSON file

AWS Permissions

Ensure your AWS credentials have the following permissions:

  • cloudformation:StartResourceScan
  • cloudformation:DescribeResourceScan
  • cloudformation:ListResourceScans
  • cloudformation:ListResourceScanResources
  • cloudformation:CreateGeneratedTemplate
  • cloudformation:DescribeGeneratedTemplate
  • cloudformation:GetGeneratedTemplate