Skip to content

This tool helps verify that SST (https://sst.dev/) infrastructure provides correct resource bindings to lambdas.

License

Notifications You must be signed in to change notification settings

quadient/sst-link-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SST Link Check Tool

⚠️Warning: The tool code is for inspiration and needs to be tweaked for your project paths to work. Therefore is not distributed as a package in npm repository.

This tool helps verify that SST infrastructure provides correct resource bindings to lambdas.

What tool does

  • Reads the Pulumi state file (./state.json) to get "linked values encryption key".
  • Scans .sst/artifacts for all artifact subdirectories.
    • Reads each bundle.mjs file to find all Resource. usages.
    • Reads values provided in the resource.enc file.
  • Compares the resources found in bundle.mjs with those in the resource.enc file and reports discrepancies.

Prerequisites

  • Node.js installed
  • pnpm installed

Installation

Install dependencies using pnpm:

pnpm install

Usage

  • deploy the stage and export the Pulumi state file
# CWD: inside the SST project root directory

# deploy the stage to generate the bundle.mjs files + resource.enc files
pnpm sst --stage "<stagename>" deploy

# get pulumi state file of stage
# => this will expose encrypted credentials, so be careful with it ⚠️
pnpm sst --stage "<stagename>" state export --decrypt > state.json
  • run this tool to check SST artifacts against the linked values from infrastructure
# NOTE: modify the index.ts file to your project setup (the ARTIFACTS_DIR and STATE_FILE_PATH variables)

# CWD: inside the tool directory
pnpm run-tool

Example Output

SST Artifact Resource Bindings:

[MobileApiFunction]
  - MainAuthJwtSigningKey
  - MainBucket
  - MainTable
  - MainWebSocketApi

  resource.enc file Links:
  - MainBucket
  - MainTable
  - MainWebSocketApi

  DISCREPANCIES FOUND:
  Resources in bundle.mjs but not in resource.enc file:
    - MainAuthJwtSigningKey

DEBT and NOTES

  • no test coverage that this tools works after SST upgrades (tool is used and verified on sst@3.13.10)
  • currently there is no focus to make code improvements (awaiting feedback from SST team to idealy provide native support for this)
  • parts of the code were generated by AI prompting - see prompt.md

About

This tool helps verify that SST (https://sst.dev/) infrastructure provides correct resource bindings to lambdas.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published