class RuleScope
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Config.RuleScope |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsconfig#RuleScope |
Java | software.amazon.awscdk.services.config.RuleScope |
Python | aws_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
Name | Type | Description |
---|---|---|
key? | string | tag key applied to resources that will trigger evaluation of a rule. |
resource | string | ID of the only AWS resource that will trigger evaluation of a rule. |
resource | Resource [] | Resource types that will trigger evaluation of a rule. |
value? | string | tag 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:
Resource
[]
(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
Name | Description |
---|---|
static from | restricts scope of changes to a specific resource type or resource identifier. |
static from | restricts scope of changes to specific resource types. |
static from | restricts scope of changes to a specific tag. |
static fromResource(resourceType, resourceId?)
public static fromResource(resourceType: ResourceType, resourceId?: string): RuleScope
Parameters
- resourceType
Resource
Type - resourceId
string
Returns
restricts scope of changes to a specific resource type or resource identifier.
static fromResources(resourceTypes)
public static fromResources(resourceTypes: ResourceType[]): RuleScope
Parameters
- resourceTypes
Resource
Type []
Returns
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
restricts scope of changes to a specific tag.