# IgnoreStrategy

Represents file path ignoring behavior.

Superclass of: [DockerIgnoreStrategy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.DockerIgnoreStrategy.html), [GitIgnoreStrategy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.GitIgnoreStrategy.html), [GlobIgnoreStrategy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.GlobIgnoreStrategy.html)
Obtainable from: IgnoreStrategy.fromCopyOptions

- Source: [`core/lib/fs/ignore.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/core/lib/fs/ignore.ts#L18)
- Type last changed: v2.217.0 · 25 Sep 2025

## Example

TypeScript:

```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 ignoreStrategy = cdk.IgnoreStrategy.fromCopyOptions({
  exclude: ['exclude'],
  follow: cdk.SymlinkFollowMode.NEVER,
  ignoreMode: cdk.IgnoreMode.GLOB,
}, 'absoluteRootPath');
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk

ignore_strategy = cdk.IgnoreStrategy.from_copy_options(cdk.CopyOptions(
    exclude=["exclude"],
    follow=cdk.SymlinkFollowMode.NEVER,
    ignore_mode=cdk.IgnoreMode.GLOB
), "absoluteRootPath")
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;

IgnoreStrategy ignoreStrategy = IgnoreStrategy.fromCopyOptions(CopyOptions.builder()
        .exclude(List.of("exclude"))
        .follow(SymlinkFollowMode.NEVER)
        .ignoreMode(IgnoreMode.GLOB)
        .build(), "absoluteRootPath");
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;

var ignoreStrategy = IgnoreStrategy.FromCopyOptions(new CopyOptions {
    Exclude = new [] { "exclude" },
    Follow = SymlinkFollowMode.NEVER,
    IgnoreMode = IgnoreMode.GLOB
}, "absoluteRootPath");
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

ignoreStrategy := cdk.IgnoreStrategy_FromCopyOptions(&CopyOptions{
	Exclude: []*string{
		jsii.String("exclude"),
	},
	Follow: cdk.SymlinkFollowMode_NEVER,
	IgnoreMode: cdk.IgnoreMode_GLOB,
}, jsii.String("absoluteRootPath"))
```

## Initializer

TypeScript:

```ts
new IgnoreStrategy()
```

Python:

```python
IgnoreStrategy()
```

Java:

```java
new IgnoreStrategy()
```

C# / .NET:

```csharp
new IgnoreStrategy()
```

Golang:

```go
NewIgnoreStrategy()
```

## Methods

- `add(pattern: string): void` — Adds another pattern.

- `completelyIgnores(absoluteDirectoryPath: string): boolean` — Determines whether a given directory path should be ignored and have all of its children ignored.

  **Parameters**

  - `absoluteDirectoryPath` — absolute directory path to be assessed against the pattern.

  **Returns:** `true` if the directory and all of its children should be ignored

- `docker(absoluteRootPath: string, patterns: string[]): DockerIgnoreStrategy` (static) — Ignores file paths based on the [`.dockerignore specification`](https://docs.docker.com/engine/reference/builder/#dockerignore-file).

  **Parameters**

  - `absoluteRootPath` — the absolute path to the root directory of the paths to be considered.

  **Returns:** `DockerIgnorePattern` associated with the given patterns.

- `fromCopyOptions(options: CopyOptions, absoluteRootPath: string): IgnoreStrategy // chainable` (static) — Creates an IgnoreStrategy based on the `ignoreMode` and `exclude` in a `CopyOptions`.

  **Parameters**

  - `options` — the `CopyOptions` to create the `IgnoreStrategy` from.
  - `absoluteRootPath` — the absolute path to the root directory of the paths to be considered.

  **Returns:** `IgnoreStrategy` based on the `CopyOptions`

- `git(absoluteRootPath: string, patterns: string[]): GitIgnoreStrategy` (static) — Ignores file paths based on the [`.gitignore specification`](https://git-scm.com/docs/gitignore).

  **Parameters**

  - `absoluteRootPath` — the absolute path to the root directory of the paths to be considered.

  **Returns:** `GitIgnorePattern` associated with the given patterns.

- `glob(absoluteRootPath: string, patterns: string[]): GlobIgnoreStrategy` (static) — Ignores file paths based on simple glob patterns.

  **Parameters**

  - `absoluteRootPath` — the absolute path to the root directory of the paths to be considered.

  **Returns:** `GlobIgnorePattern` associated with the given patterns.

- `ignores(absoluteFilePath: string): boolean` — Determines whether a given file path should be ignored or not.

  **Parameters**

  - `absoluteFilePath` — absolute file path to be assessed against the pattern.

  **Returns:** `true` if the file should be ignored
