Package software.amazon.awscdk
Class Aspects
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.Aspects
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.106.0 (build e852934)",
date="2025-02-12T12:31:56.563Z")
@Stability(Stable)
public class Aspects
extends software.amazon.jsii.JsiiObject
Aspects can be applied to CDK tree scopes and can operate on the tree before synthesis.
Example:
import software.amazon.awscdk.*; import software.constructs.Construct; import software.constructs.IConstruct; public class MyAspect implements IAspect { public void visit(IConstruct node) { if (node instanceof CfnResource && node.getCfnResourceType() == "Foo::Bar") { this.error(node, "we do not want a Foo::Bar resource"); } } public void error(IConstruct node, String message) { Annotations.of(node).addError(message); } } public class MyStack extends Stack { public MyStack(Construct scope, String id) { super(scope, id); Stack stack = new Stack(); CfnResource.Builder.create(stack, "Foo") .type("Foo::Bar") .properties(Map.of( "Fred", "Thud")) .build(); Aspects.of(stack).add(new MyAspect()); } }
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an aspect to apply this scope before synthesis.void
add
(IAspect aspect, AspectOptions options) Adds an aspect to apply this scope before synthesis.getAll()
The list of aspects which were directly applied on this scope.The list of aspects with priority which were directly applied on this scope.static Aspects
of
(software.constructs.IConstruct scope) Returns theAspects
object associated with a construct scope.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Aspects
protected Aspects(software.amazon.jsii.JsiiObjectRef objRef) -
Aspects
protected Aspects(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
-
-
Method Details
-
of
Returns theAspects
object associated with a construct scope.- Parameters:
scope
- The scope for which these aspects will apply. This parameter is required.
-
add
Adds an aspect to apply this scope before synthesis.- Parameters:
aspect
- The aspect to add. This parameter is required.options
- Options to apply on this aspect.
-
add
Adds an aspect to apply this scope before synthesis.- Parameters:
aspect
- The aspect to add. This parameter is required.
-
getAll
The list of aspects which were directly applied on this scope. -
getApplied
The list of aspects with priority which were directly applied on this scope.Also returns inherited Aspects of this node.
-