# RuleScope

Determines which resources trigger an evaluation of an AWS Config rule.

- Source: [`aws-config/lib/rule.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-config/lib/rule.ts#L172)

## Example

```ts
// Lambda function containing logic that evaluates compliance with the rule.
const evalComplianceFn = new lambda.Function(this, "CustomFunction", {
  code: lambda.AssetCode.fromInline(
    "exports.handler = (event) => console.log(event);"
  ),
  handler: "index.handler",
  runtime: lambda.Runtime.NODEJS_LATEST,
});

// A custom rule that runs on configuration changes of EC2 instances
const customRule = new config.CustomRule(this, "Custom", {
  configurationChanges: true,
  lambdaFunction: evalComplianceFn,
  ruleScope: config.RuleScope.fromResource(config.ResourceType.EC2_INSTANCE),
});
```

## Properties

- `key`: string — tag key applied to resources that will trigger evaluation of a rule.

- `resourceId`: string — ID of the only AWS resource that will trigger evaluation of a rule.

- `resourceTypes`: [ResourceType](/cdk/api/v2/docs/aws-cdk-lib.aws_config.ResourceType.html)[] — Resource types that will trigger evaluation of a rule.

- `value`: string — tag value applied to resources that will trigger evaluation of a rule.

## Methods

- `fromResource(resourceType: ResourceType, resourceId?: string): RuleScope // chainable` (static) — restricts scope of changes to a specific resource type or resource identifier.

- `fromResources(resourceTypes: ResourceType[]): RuleScope // chainable` (static) — restricts scope of changes to specific resource types.

- `fromTag(key: string, value?: string): RuleScope // chainable` (static) — restricts scope of changes to a specific tag.
