@code-like-a-carpenter/foundation-plugin-cloudformation
TypeScript icon, indicating that this package has built-in type declarations

3.3.3 • Public • Published

@code-like-a-carpenter/foundation-plugin-cloudformation

standard-readme compliant

graphql-codegen plugin which generates CloudFormation template(s) using the Foundation parser

Table of Contents

Install

npm i @code-like-a-carpenter/foundation-plugin-cloudformation

Usage

Template Transforms

Template transforms get applied after the templates are generated, but before they are written to disk. They were originally added to address CloudFormation's lack of support for passing maps to nested stacks (thus preventing nested stacks from easily using things like Globals section of the parent stack or an arbitrary set of environment variables that cannot be known in advance).

A transform function is a synchronous or asynchronous function that receives the parent stack and all nested stacks and modifies them in place.

import {
    Config,
    ServerlessApplicationModel,
} from '@code-like-a-carpenter/foundation-cloudformation';
import type {IntermediateRepresentation} from '@code-like-a-carpenter/foundation-intermediate-representation';

type NestedStackTemplates = Model<string, ServerlessApplicationModel>;
type Transform = (
    config: Config,
    intermediateRepresentatin: IntermediateRepresentation,
    template: ServerlessApplicationModel,
    nestedTemplates: NestedStackTemplates
) => void | Promise<void>;

Transform packages must export a function named transform that agrees with the Transform type above.

There two default transforms:

  • @code-like-a-carpenter/foundation-table-names-transform - passes all tables names to nested handler stacks
  • @code-like-a-carpenter/foundation-environment-transform - passed all environment variables defined on Globals.Function.Environment.Variables

Given the complexity of the Globals object, especially if it's reading Refs, further transform of the Globals section should be handled by user-space code.

Maintainer

Ian Remmel

Contributing

Please see contributing guidelines at the project homepage.

License

MIT © Ian Remmel 2023 until at least now

Readme

Keywords

none

Package Sidebar

Install

npm i @code-like-a-carpenter/foundation-plugin-cloudformation

Weekly Downloads

24

Version

3.3.3

License

MIT

Unpacked Size

9.95 MB

Total Files

159

Last publish

Collaborators

  • ianwremmel