aws-cdk-lib.aws_config.RuleScope

class RuleScope

LanguageType name
.NETAmazon.CDK.AWS.Config.RuleScope
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsconfig#RuleScope
Javasoftware.amazon.awscdk.services.config.RuleScope
Pythonaws_cdk.aws_config.RuleScope
TypeScript (source)aws-cdk-lib » aws_config » RuleScope

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

Example

// 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_18_X,
});

// 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

NameTypeDescription
key?stringtag key applied to resources that will trigger evaluation of a rule.
resourceId?stringID of the only AWS resource that will trigger evaluation of a rule.
resourceTypes?ResourceType[]Resource types that will trigger evaluation of a rule.
value?stringtag value applied to resources that will trigger evaluation of a rule.

key?

Type: string (optional)

tag key applied to resources that will trigger evaluation of a rule.


resourceId?

Type: string (optional)

ID of the only AWS resource that will trigger evaluation of a rule.


resourceTypes?

Type: ResourceType[] (optional)

Resource types that will trigger evaluation of a rule.


value?

Type: string (optional)

tag value applied to resources that will trigger evaluation of a rule.

Methods

NameDescription
static fromResource(resourceType, resourceId?)restricts scope of changes to a specific resource type or resource identifier.
static fromResources(resourceTypes)restricts scope of changes to specific resource types.
static fromTag(key, value?)restricts scope of changes to a specific tag.

static fromResource(resourceType, resourceId?)

public static fromResource(resourceType: ResourceType, resourceId?: string): RuleScope

Parameters

  • resourceType ResourceType
  • resourceId string

Returns

  • RuleScope

restricts scope of changes to a specific resource type or resource identifier.


static fromResources(resourceTypes)

public static fromResources(resourceTypes: ResourceType[]): RuleScope

Parameters

  • resourceTypes ResourceType[]

Returns

  • RuleScope

restricts scope of changes to specific resource types.


static fromTag(key, value?)

public static fromTag(key: string, value?: string): RuleScope

Parameters

  • key string
  • value string

Returns

  • RuleScope

restricts scope of changes to a specific tag.