# ConstructSelector

Selects constructs from a construct tree based on various criteria.

- Source: [`core/lib/mixins/selectors.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/core/lib/mixins/selectors.ts#L17)
- Type last changed: v2.241.0 · 2 Mar 2026

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
const constructSelector = new cdk.ConstructSelector();
```

## Initializer

```ts
new ConstructSelector()
```

## Methods

- `all(): IConstructSelector` (static) — Selects all constructs in the tree.

- `byId(pattern: string): IConstructSelector` (static) — Selects constructs whose construct IDs match a pattern.

  Uses glob like matching.

- `byPath(pattern: string): IConstructSelector` (static) — Selects constructs whose construct paths match a pattern.

  Uses glob like matching.

- `cfnResource(): IConstructSelector` (static) — Selects CfnResource constructs or the default CfnResource child.

- `onlyItself(): IConstructSelector` (static) — Selects only the provided construct.

- `resourcesOfType(...types: string[]): IConstructSelector` (static) — Selects constructs of a specific type.
