Aspects
- class aws_cdk.core.Aspects(*args: Any, **kwargs)
- Bases: - object- Aspects can be applied to CDK tree scopes and can operate on the tree before synthesis. - ExampleMetadata:
- nofixture infused 
 - Example: - import aws_cdk.core as cdk from constructs import Construct, IConstruct class MyAspect(cdk.IAspect): def visit(self, node): if node instanceof cdk.CfnResource && node.cfn_resource_type == "Foo::Bar": self.error(node, "we do not want a Foo::Bar resource") def error(self, node, message): cdk.Annotations.of(node).add_error(message) class MyStack(cdk.Stack): def __init__(self, scope, id): super().__init__(scope, id) stack = cdk.Stack() cdk.CfnResource(stack, "Foo", type="Foo::Bar", properties={ "Fred": "Thud" } ) cdk.Aspects.of(stack).add(MyAspect()) - Methods - add(aspect)
- Adds an aspect to apply this scope before synthesis. - Parameters:
- aspect ( - IAspect) – The aspect to add.
- Return type:
- None
 
 - Attributes - aspects
- The list of aspects which were directly applied on this scope. 
 - Static Methods - classmethod of(scope)
- Returns the - Aspectsobject associated with a construct scope.- Parameters:
- scope ( - IConstruct) – The scope for which these aspects will apply.
- Return type: