Skip to content
v2.275.0

RuleScope Class ​

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

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 ​

keymay be undefinedstringkeymay be undefinedstrkeymay be undefinedStringKeymay be undefinedstringKeymay be undefined*string#
tag key applied to resources that will trigger evaluation of a rule.
resourceIdmay be undefinedstringresource_idmay be undefinedstrresourceIdmay be undefinedStringResourceIdmay be undefinedstringResourceIdmay be undefined*string#
ID of the only AWS resource that will trigger evaluation of a rule.
resourceTypesmay be undefinedResourceType[]resource_typesmay be undefinedtyping.List[ResourceType]resourceTypesmay be undefinedList<ResourceType>ResourceTypesmay be undefinedResourceType[]ResourceTypesmay be undefined*[]ResourceType#
Resource types that will trigger evaluation of a rule.
valuemay be undefinedstringvaluemay be undefinedstrvaluemay be undefinedStringValuemay be undefinedstringValuemay be undefined*string#
tag value applied to resources that will trigger evaluation of a rule.

Methods ​

fromResource(resourceType: ResourceType, resourceId?: string): RuleScope // chainable@staticmethod def from_resource(resource_type: ResourceType, resource_id: typing.Optional[str] = None) -> RuleScopepublic static RuleScope fromResource(ResourceType resourceType, String resourceId)public static RuleScope FromResource(ResourceType resourceType, string? resourceId = null)func FromResource(ResourceType ResourceType, ResourceId *string) RuleScopestatic#
restricts scope of changes to a specific resource type or resource identifier.
fromResources(resourceTypes: ResourceType[]): RuleScope // chainable@staticmethod def from_resources(resource_types: typing.List[ResourceType]) -> RuleScopepublic static RuleScope fromResources(List<ResourceType> resourceTypes)public static RuleScope FromResources(ResourceType[] resourceTypes)func FromResources(ResourceTypes *[]ResourceType) RuleScopestatic#
restricts scope of changes to specific resource types.
fromTag(key: string, value?: string): RuleScope // chainable@staticmethod def from_tag(key: str, value: typing.Optional[str] = None) -> RuleScopepublic static RuleScope fromTag(String key, String value)public static RuleScope FromTag(string key, string? value = null)func FromTag(Key *string, Value *string) RuleScopestatic#
restricts scope of changes to a specific tag.