Takomo v9.0.1
    Preparing search index...

    Interface CustomStackHandler<CONFIG, STATE>

    Interface for handling custom stack operations in Takomo.

    A custom stack handler provides the core functionality for managing custom stacks throughout their lifecycle, including creation, updates, deletion, and state management. Custom stack handlers enable extending Takomo's capabilities beyond standard CloudFormation stacks to support other infrastructure provisioning tools or custom deployment logic.

    interface CustomStackHandler<CONFIG, STATE extends CustomStackState> {
        create: (
            props: CreateCustomStackProps<CONFIG>,
        ) => Promise<CreateCustomStackResult<STATE>>;
        delete: (
            props: DeleteCustomStackProps<CONFIG, STATE>,
        ) => Promise<DeleteCustomStackResult>;
        getChanges?: (
            props: GetChangesProps<CONFIG, STATE>,
        ) => Promise<GetChangesResult>;
        getCurrentState?: (
            props: GetCurrentStateProps<CONFIG>,
        ) => Promise<GetCurrentStateResult<STATE>>;
        parseConfig: (
            props: ParseConfigProps,
        ) => Promise<ParseConfigResult<CONFIG>>;
        type: string;
        update: (
            props: UpdateCustomStackProps<CONFIG, STATE>,
        ) => Promise<UpdateCustomStackResult<STATE>>;
    }

    Type Parameters

    • CONFIG

      The configuration type for this custom stack handler

    • STATE extends CustomStackState

      The state type that extends CustomStackState, representing the current state of the stack

    Index

    Properties

    create: (
        props: CreateCustomStackProps<CONFIG>,
    ) => Promise<CreateCustomStackResult<STATE>>

    Creates a new instance of the custom stack in the target environment.

    This function should:

    • Provision all necessary infrastructure resources
    • Apply the specified parameters and tags
    • Return the final state of the created stack

    The implementation should ensure idempotency where possible and provide detailed error information if the creation fails.

    Type Declaration

    delete: (
        props: DeleteCustomStackProps<CONFIG, STATE>,
    ) => Promise<DeleteCustomStackResult>

    Removes the custom stack and all its associated resources from the target environment.

    This function should:

    • Clean up all resources created by the stack
    • Ensure complete removal without leaving orphaned resources
    • Handle cases where some resources have already been deleted

    The implementation should be as thorough as possible in cleanup while being resilient to partial failures and resource dependencies.

    Type Declaration

    getChanges?: (
        props: GetChangesProps<CONFIG, STATE>,
    ) => Promise<GetChangesResult>

    Analyzes and returns the changes that would be applied to bring the stack from its current state to the desired state defined by the configuration.

    This function is invoked during deployment of existing stacks to:

    • Show users what changes will be made before applying them
    • Determine if any changes are actually required
    • Enable dry-run functionality for planning purposes

    The implementation should compare the current stack state with the desired configuration and return a detailed list of changes that would be applied. The format and granularity of changes is up to the implementation.

    Implementing this function is optional; if not provided, Takomo will assume that changes are always present but no detailed change information is available.

    Type Declaration

    getCurrentState?: (
        props: GetCurrentStateProps<CONFIG>,
    ) => Promise<GetCurrentStateResult<STATE>>

    Retrieves the current state of the custom stack from the target environment.

    This function is crucial for determining the stack's lifecycle operations:

    • During deployment: determines whether to create a new stack or update an existing one
    • During undeployment: determines whether a stack exists and needs to be deleted

    The implementation should query the actual infrastructure to determine the real state, not just return cached or assumed values.

    Implementing this function is optional; if not provided, the stack will be assumed to be in a "UNKNOWN" state.

    • During deployment; stacks with "UNKNOWN" state are assumed to require creation (i.e. create function is always invoked).
    • During undeployment; stacks with "UNKNOWN" state are assumed to require deletion (i.e. delete function is always invoked).

    Type Declaration

    parseConfig: (props: ParseConfigProps) => Promise<ParseConfigResult<CONFIG>>

    Validates and parses the raw configuration for this custom stack type.

    This function is responsible for:

    • Validating the configuration against the expected schema
    • Converting raw configuration data into a typed configuration object
    • Providing meaningful error messages for invalid configurations
    • Applying default values where appropriate

    The parsed configuration object will be passed to all subsequent operations, such as create, update, and delete.

    Type Declaration

    type: string

    The type identifier for this custom stack handler.

    This unique identifier is used to match custom stack configurations with their corresponding handler implementation. It should be a descriptive string that clearly identifies the type of infrastructure or deployment tool this handler manages.

    update: (
        props: UpdateCustomStackProps<CONFIG, STATE>,
    ) => Promise<UpdateCustomStackResult<STATE>>

    Updates an existing custom stack to match the desired configuration.

    This function should:

    • Apply configuration changes to the existing stack
    • Update parameters and tags as specified
    • Handle resource modifications, additions, and removals
    • Return the updated state of the stack

    The implementation should handle update conflicts gracefully and provide detailed information about what changes were actually applied.

    Type Declaration