UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

52 lines (51 loc) 1.82 kB
import type { IConstruct } from 'constructs'; import { CfnResource } from '../cfn-resource'; /** * Matches CfnResources by CloudFormation type and a custom predicate. */ export interface ICfnResourceMatcher { /** * The CloudFormation resource type to match (e.g. 'AWS::S3::Bucket'). */ readonly cfnResourceType: string; /** * Whether the candidate CfnResource matches. */ matches(candidate: CfnResource): boolean; } /** * Reflection utilities for searching the construct tree. * * Use `ConstructReflection.of(construct)` to create an instance, then * call methods to search for related CfnResources or inspect the construct's * position in the tree. */ export declare class ConstructReflection { /** * Create a reflection for the given construct. */ static of(construct: IConstruct): ConstructReflection; private readonly construct; private constructor(); /** * The owner of this construct, if it is a default child. * * Returns the parent scope when the construct has an id of `'Resource'` or * `'Default'`, indicating it was created as a default child by a * higher-level construct. Returns `undefined` otherwise. */ get defaultChildOwner(): IConstruct | undefined; /** * Finds the CfnResource backing this construct. * * Checks in order: the construct itself, its default child, then searches * the broader construct tree for the closest match. */ findCfnResource(matcher: ICfnResourceMatcher): CfnResource | undefined; /** * Finds the closest related CfnResource in the construct tree. * * Searches children first (depth-first), then ancestors (breadth-first). */ findRelatedCfnResource(matcher: ICfnResourceMatcher): CfnResource | undefined; }