# StackFiltersProperty

The `StackFilters` property type specifies stack level filters for a Hook.

The `StackNames` or `StackRoles` properties are optional. However, you must specify at least one of these properties.

For more information, see [CloudFormation Hooks stack level filters](https://docs.aws.amazon.com/cloudformation-cli/latest/hooks-userguide/hooks-stack-level-filtering.html) .

- Source: Generated at build time
- Type last changed: v2.168.0 · 20 Nov 2024

## 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 stackFiltersProperty: cdk.CfnGuardHook.StackFiltersProperty = {
  filteringCriteria: 'filteringCriteria',

  // the properties below are optional
  stackNames: {
    exclude: ['exclude'],
    include: ['include'],
  },
  stackRoles: {
    exclude: ['exclude'],
    include: ['include'],
  },
};
```

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

stack_filters_property = cdk.CfnGuardHook.StackFiltersProperty(
    filtering_criteria="filteringCriteria",

    # the properties below are optional
    stack_names=cdk.CfnGuardHook.StackNamesProperty(
        exclude=["exclude"],
        include=["include"]
    ),
    stack_roles=cdk.CfnGuardHook.StackRolesProperty(
        exclude=["exclude"],
        include=["include"]
    )
)
```

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.*;

StackFiltersProperty stackFiltersProperty = StackFiltersProperty.builder()
        .filteringCriteria("filteringCriteria")

        // the properties below are optional
        .stackNames(StackNamesProperty.builder()
                .exclude(List.of("exclude"))
                .include(List.of("include"))
                .build())
        .stackRoles(StackRolesProperty.builder()
                .exclude(List.of("exclude"))
                .include(List.of("include"))
                .build())
        .build();
```

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 stackFiltersProperty = new StackFiltersProperty {
    FilteringCriteria = "filteringCriteria",

    // the properties below are optional
    StackNames = new StackNamesProperty {
        Exclude = new [] { "exclude" },
        Include = new [] { "include" }
    },
    StackRoles = new StackRolesProperty {
        Exclude = new [] { "exclude" },
        Include = new [] { "include" }
    }
};
```

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 cdk "github.com/aws/aws-cdk-go/awscdk"

stackFiltersProperty := &StackFiltersProperty{
	FilteringCriteria: jsii.String("filteringCriteria"),

	// the properties below are optional
	StackNames: &StackNamesProperty{
		Exclude: []*string{
			jsii.String("exclude"),
		},
		Include: []*string{
			jsii.String("include"),
		},
	},
	StackRoles: &StackRolesProperty{
		Exclude: []*string{
			jsii.String("exclude"),
		},
		Include: []*string{
			jsii.String("include"),
		},
	},
}
```

## Properties

- `filteringCriteria`: string (required) = "ALL" — The filtering criteria.

  - All stack names and stack roles ( `All` ): The Hook will only be invoked when all specified filters match.
  - Any stack names and stack roles ( `Any` ): The Hook will be invoked if at least one of the specified filters match.

- `stackNames`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnGuardHook.StackNamesProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnGuardHook.StackNamesProperty.html) — Includes or excludes specific stacks from Hook invocations.

- `stackRoles`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnGuardHook.StackRolesProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnGuardHook.StackRolesProperty.html) — Includes or excludes specific stacks from Hook invocations based on their associated IAM roles.
