🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@ttoss/cloudformation

Package Overview
Dependencies
Maintainers
2
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ttoss/cloudformation

CloudFormation utils.

latest
Source
npmnpm
Version
0.13.2
Version published
Weekly downloads
1.2K
351.84%
Maintainers
2
Weekly downloads
 
Created
Source

@ttoss/cloudformation

Utilities and TypeScript types for working with AWS CloudFormation templates.

Installation

pnpm add @ttoss/cloudformation

Intrinsic Function Types

The package exports TypeScript types for all commonly used CloudFormation intrinsic functions:

TypeCloudFormation equivalent
CloudFormationRef{ Ref: string }
CloudFormationGetAtt{ 'Fn::GetAtt': [string, string] }
CloudFormationJoin{ 'Fn::Join': [string, ...] }
CloudFormationSub{ 'Fn::Sub': string }
CloudFormationSelect{ 'Fn::Select': [number, string[]] }
CloudFormationSplit{ 'Fn::Split': [string, string] }
CloudFormationImportValue{ 'Fn::ImportValue': string | CloudFormationSub }
CloudFormationIntrinsicUnion of all the above
CloudFormationValue<T>T | CloudFormationIntrinsic

Helpers

importValueFromParameter

Generates an Fn::ImportValue + Fn::Sub intrinsic that reads the export name from a CloudFormation parameter. This is the standard pattern for consuming cross-stack exports whose names are not known at author time.

import { importValueFromParameter } from '@ttoss/cloudformation';

importValueFromParameter('AppSyncLambdaRoleArn');
// => { 'Fn::ImportValue': { 'Fn::Sub': '${AppSyncLambdaRoleArn}' } }

Typical use in a CloudFormation template:

import { importValueFromParameter } from '@ttoss/cloudformation';
import { createApiTemplate } from '@ttoss/appsync-api';

const template = createApiTemplate({
  schemaComposer,
  dataSource: {
    roleArn: importValueFromParameter('AppSyncLambdaDataSourceIAMRoleArn'),
  },
  lambdaFunction: {
    roleArn: importValueFromParameter('AppSyncLambdaFunctionIAMRoleArn'),
    environment: {
      variables: {
        TABLE_NAME: { Ref: 'DynamoTableName' },
        EXTERNAL_ARN: importValueFromParameter('SomeOtherStackExportedName'),
      },
    },
  },
});

When a producing stack exports a value and a consuming stack imports it with Fn::ImportValue, CloudFormation protects that dependency by blocking deletion of the producer export until imports are removed.

Producer stack output example:

const outputs = {
  LambdaPostgresReadQueryFunctionArn: {
    Value: { 'Fn::GetAtt': ['LambdaPostgresReadQueryFunction', 'Arn'] },
    Export: {
      Name: {
        'Fn::Sub': '${AWS::StackName}-LambdaPostgresReadQueryFunctionArn',
      },
    },
  },
};

Consumer stack usage with parameterized export name:

import { importValueFromParameter } from '@ttoss/cloudformation';

const resources = {
  InvokePermission: {
    Type: 'AWS::Lambda::Permission',
    Properties: {
      FunctionName: importValueFromParameter('ReadQueryFunctionArnExportName'),
      Action: 'lambda:InvokeFunction',
      Principal: 'apigateway.amazonaws.com',
    },
  },
};

Reading Templates

findAndReadCloudFormationTemplate

Reads a CloudFormation template file from disk. Supports both TypeScript and YAML files.

import { findAndReadCloudFormationTemplate } from '@ttoss/cloudformation';

const template = await findAndReadCloudFormationTemplate({
  templatePath: './cloudformation.ts',
  options: { environment: 'Production' },
});

FAQs

Package last updated on 14 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts