All exports are available from a single entry point:
import { CloudBurnClient, builtInRuleMetadata, parseIaC, evaluateScanPolicy, assertValidAwsRegion, assertSupportedAwsRegion, withAwsClientCredentials, isAwsDiscoveryErrorCode, awsCorePreset, SEVERITIES } from '@cloudburn/sdk';
Exports
| Export | Kind | Description |
|---|---|---|
CloudBurnClient | class | Main SDK entry point |
builtInRuleMetadata | constant | Array of all built-in rule metadata |
parseIaC | function | Standalone IaC parser |
evaluateScanPolicy | function | Evaluates a ScanResult against a severity threshold |
assertValidAwsRegion | function | Region format validator (shape/pattern only) |
assertSupportedAwsRegion | function | Region validator (checks against known AWS regions list) |
withAwsClientCredentials | function | Scopes AWS credentials to a discovery callback |
isAwsDiscoveryErrorCode | function | Type guard for discovery error codes |
awsCorePreset | constant | Default AWS rule preset (re-exported from @cloudburn/rules) |
SEVERITIES | constant | Ordered severity tuple ['high', 'medium', 'low'] (re-exported from @cloudburn/rules) |
CloudBurnClient
The main SDK class. See CloudBurnClient reference for full documentation.
import { CloudBurnClient } from '@cloudburn/sdk';
const client = new CloudBurnClient();
builtInRuleMetadata
An array of BuiltInRuleMetadata objects describing all rules that ship with CloudBurn. This is a plain serializable array — no class instances, safe to JSON.stringify.
import { builtInRuleMetadata } from '@cloudburn/sdk';
// List all AWS EC2 rules
const ec2Rules = builtInRuleMetadata.filter(
(rule) => rule.provider === 'aws' && rule.service === 'ec2'
);
for (const rule of ec2Rules) {
console.log(`${rule.id}: ${rule.name}`);
}
Each entry is typed as BuiltInRuleMetadata:
type BuiltInRuleMetadata = {
id: string;
name: string;
description: string;
provider: CloudProvider;
service: string;
severity: Severity;
supports: Source[];
};
See Rules for a browsable list of all built-in rules.
parseIaC
Parses IaC files and returns structured resource objects without running any rules.
parseIaC(
path: string,
options?: {
sourceKinds?: ('cloudformation' | 'terraform')[];
}
): Promise<{ provider: CloudProvider; type: string; name: string; location?: SourceLocation; attributes: Record<string, unknown> }[]>
Parameters:
| Parameter | Type | Description |
|---|---|---|
path | string | Path to a directory or file containing IaC code |
options.sourceKinds | ('cloudformation' | 'terraform')[] | Limit parsing to specific IaC source kinds. Defaults to both. |
Returns: An array of parsed resource objects, each containing the cloud provider, resource type, name, attributes, and source location.
Example:
import { parseIaC } from '@cloudburn/sdk';
const resources = await parseIaC('./infrastructure');
for (const resource of resources) {
console.log(`${resource.provider}/${resource.type} "${resource.name}"`);
if (resource.location) {
console.log(` at ${resource.location.path}:${resource.location.line}`);
}
}
evaluateScanPolicy
Evaluates a ScanResult against an inclusive severity threshold and returns whether the scan should be treated as a policy violation.
evaluateScanPolicy(result: ScanResult, threshold?: Severity): ScanPolicyResult
Parameters:
| Parameter | Type | Description |
|---|---|---|
result | ScanResult | The scan result to evaluate. |
threshold | Severity | Lowest severity that counts as a violation. Omit to include every active finding. |
Returns: ScanPolicyResult — qualifyingFindingCount, the evaluated threshold, and violated.
scanStatic() and discover() already call this internally when CloudBurnModeConfig.failOn is set, populating ScanResult.policy automatically. Call evaluateScanPolicy() directly when you want to apply a threshold that differs from the loaded config, or re-evaluate a result you've filtered yourself.
Example:
import { evaluateScanPolicy } from '@cloudburn/sdk';
const result = await client.scanStatic('./infrastructure');
const policy = evaluateScanPolicy(result, 'medium');
if (policy.violated) {
console.error(`${policy.qualifyingFindingCount} findings at or above 'medium' severity`);
process.exitCode = 1;
}
assertValidAwsRegion
Validates that a value matches the shape of an AWS region string. Throws a TypeError if the format is invalid. Does not check against a list of known AWS regions — use assertSupportedAwsRegion for that.
assertValidAwsRegion(region: unknown): asserts region is string
Use this to validate user-supplied or environment-supplied region values before passing them to SDK methods.
Throws: TypeError with a descriptive message if the region is invalid.
Example:
import { assertValidAwsRegion } from '@cloudburn/sdk';
const region = process.env.AWS_REGION;
assertValidAwsRegion(region); // throws if region is undefined or invalid
// region is now typed as string
const result = await client.discover({ target: { mode: 'region', region } });
assertSupportedAwsRegion
Validates that a string is a known, supported AWS region. Throws an AwsDiscoveryError with code INVALID_AWS_REGION if the region is not in the known AWS regions list.
assertSupportedAwsRegion(region: string): AwsRegion
Use this when you need to verify that a region is not just well-formed but also a real, supported AWS region.
Throws: AwsDiscoveryError if the region is not recognized.
Example:
import { assertSupportedAwsRegion } from '@cloudburn/sdk';
const region = assertSupportedAwsRegion('us-east-1'); // returns typed AwsRegion
assertSupportedAwsRegion('not-a-region'); // throws AwsDiscoveryError
withAwsClientCredentials
Runs a callback with ambient AWS credentials applied to every AWS client the CloudBurn SDK creates inside it, without threading credentials through each call site. Clients you construct yourself (for example new S3Client()) do not consult this context and keep their own credential chain.
withAwsClientCredentials<T>(
credentials: AwsClientCredentials | undefined,
fn: () => Promise<T>
): Promise<T>
Parameters:
| Parameter | Type | Description |
|---|---|---|
credentials | AwsClientCredentials | undefined | AWS SDK v3 credentials or a credential provider. undefined falls back to the default credential chain. |
fn | () => Promise<T> | Callback whose AWS client construction should use the credentials. |
Returns: The callback's resolved value.
CloudBurnClient.discover() calls this internally when you pass options.aws.credentials, so most callers never need withAwsClientCredentials directly — reach for the discover() option first. Use this export when you need to scope credentials across a wider block of code, such as a multi-account loop that calls discover() once per account.
Example:
import { withAwsClientCredentials } from '@cloudburn/sdk';
import { fromTemporaryCredentials } from '@aws-sdk/credential-providers';
const credentials = fromTemporaryCredentials({
params: { RoleArn: 'arn:aws:iam::111111111111:role/cloudburn-readonly' },
});
const result = await withAwsClientCredentials(credentials, () =>
client.discover({ target: { mode: 'current' } }),
);
See AWS Credentials for the multi-account pattern.
isAwsDiscoveryErrorCode
Type guard that checks whether a string is a known CloudBurn discovery error code.
isAwsDiscoveryErrorCode(code: unknown): code is string
Returns: true if code is a recognized discovery error code.
Use this to handle specific discovery errors in ScanDiagnostic.code:
import { isAwsDiscoveryErrorCode } from '@cloudburn/sdk';
const result = await client.discover();
for (const diag of result.diagnostics ?? []) {
if (diag.code && isAwsDiscoveryErrorCode(diag.code)) {
console.error(`Discovery error [${diag.code}]: ${diag.message}`);
}
}
Known error codes include codes for Resource Explorer not enabled, insufficient permissions, and region access issues.
awsCorePreset
The default AWS rule preset, re-exported from @cloudburn/rules. Lists the rule IDs enabled by default for AWS discovery and IaC scans, excluding account-wide opt-in rules such as CLDBRN-AWS-TAGGING-1.
const awsCorePreset: {
id: string;
name: string;
description: string;
ruleIds: string[];
};
import { awsCorePreset } from '@cloudburn/sdk';
console.log(`Default rule count: ${awsCorePreset.ruleIds.length}`);
SEVERITIES
The ordered severity tuple, re-exported from @cloudburn/rules. Severity is (typeof SEVERITIES)[number].
const SEVERITIES: readonly ['high', 'medium', 'low'];
Use this to build a severity picker or to validate a user-supplied failOn value before passing it to CloudBurnModeConfig:
import { SEVERITIES } from '@cloudburn/sdk';
const requested = process.env.FAIL_ON;
if (requested && !SEVERITIES.includes(requested as (typeof SEVERITIES)[number])) {
throw new Error(`Invalid severity "${requested}". Use one of: ${SEVERITIES.join(', ')}`);
}
What's next
| Rules | Browse all built-in rules (referenced by builtInRuleMetadata) |
| Types Reference | Full type definitions |
| CloudBurnClient | Method reference |