Class Aspects
Aspects can be applied to CDK tree scopes and can operate on the tree before synthesis.
Inheritance
Namespace: Amazon.CDK
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Aspects : DeputyBase
Syntax (vb)
Public Class Aspects
Inherits DeputyBase
Remarks
ExampleMetadata: nofixture infused
Examples
using Amazon.CDK;
using Constructs;
class MyAspect : IAspect
{
public void Visit(IConstruct node)
{
if (node instanceof CfnResource && node.CfnResourceType == "Foo::Bar")
{
Error(node, "we do not want a Foo::Bar resource");
}
}
protected void Error(IConstruct node, string message)
{
Annotations.Of(node).AddError(message);
}
}
class MyStack : Stack
{
public MyStack(Construct scope, string id) : base(scope, id)
{
var stack = new Stack();
new CfnResource(stack, "Foo", new CfnResourceProps {
Type = "Foo::Bar",
Properties = new Dictionary<string, object> {
{ "Fred", "Thud" }
}
});
Aspects.Of(stack).Add(new MyAspect());
}
}
Synopsis
Constructors
Aspects(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Aspects(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Properties
All | The list of aspects which were directly applied on this scope. |
Methods
Add(IAspect) | Adds an aspect to apply this scope before synthesis. |
Of(IConstruct) | Returns the |
Constructors
Aspects(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Aspects(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Aspects(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Aspects(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Properties
All
The list of aspects which were directly applied on this scope.
public virtual IAspect[] All { get; }
Property Value
IAspect[]
Methods
Add(IAspect)
Adds an aspect to apply this scope before synthesis.
public virtual void Add(IAspect aspect)
Parameters
- aspect IAspect
The aspect to add.
Of(IConstruct)
Returns the Aspects
object associated with a construct scope.
public static Aspects Of(IConstruct scope)
Parameters
- scope Constructs.IConstruct
The scope for which these aspects will apply.
Returns