Show / Hide Table of Contents

Class Aspects

Aspects can be applied to CDK tree scopes and can operate on the tree before synthesis.

Inheritance
object
Aspects
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

Properties

All

The list of aspects which were directly applied on this scope.

Applied

The list of aspects with priority which were directly applied on this scope.

Methods

Add(IAspect, IAspectOptions?)

Adds an aspect to apply this scope before synthesis.

Of(IConstruct)

Returns the Aspects object associated with a construct scope.

Properties

All

The list of aspects which were directly applied on this scope.

public virtual IAspect[] All { get; }
Property Value

IAspect[]

Remarks

ExampleMetadata: nofixture infused

Applied

The list of aspects with priority which were directly applied on this scope.

public virtual AspectApplication[] Applied { get; }
Property Value

AspectApplication[]

Remarks

Also returns inherited Aspects of this node.

Methods

Add(IAspect, IAspectOptions?)

Adds an aspect to apply this scope before synthesis.

public virtual void Add(IAspect aspect, IAspectOptions? options = null)
Parameters
aspect IAspect

The aspect to add.

options IAspectOptions

Options to apply on this aspect.

Remarks

ExampleMetadata: nofixture infused

Of(IConstruct)

Returns the Aspects object associated with a construct scope.

public static Aspects Of(IConstruct scope)
Parameters
scope IConstruct

The scope for which these aspects will apply.

Returns

Aspects

Remarks

ExampleMetadata: nofixture infused

Back to top Generated by DocFX