Show / Hide Table of Contents

Class Rule

Represents a rule in AWS CodePipeline that can be used to add conditions and controls to pipeline execution.

Inheritance
object
Rule
Namespace: Amazon.CDK.AWS.CodePipeline
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Rule : DeputyBase
Syntax (vb)
Public Class Rule Inherits DeputyBase
Remarks

ExampleMetadata: infused

Examples
CodeStarConnectionsSourceAction sourceAction;
            CodeBuildAction buildAction;


            new Pipeline(this, "Pipeline", new PipelineProps {
                PipelineType = PipelineType.V2,
                Stages = new [] { new StageProps {
                    StageName = "Source",
                    Actions = new [] { sourceAction }
                }, new StageProps {
                    StageName = "Build",
                    Actions = new [] { buildAction },
                    // BeforeEntry condition - checks before entering the stage
                    BeforeEntry = new Conditions {
                        Conditions = new [] { new Condition {
                            Rules = new [] { new Rule(new RuleProps {
                                Name = "LambdaCheck",
                                Provider = "LambdaInvoke",
                                Version = "1",
                                Configuration = new Dictionary<string, string> {
                                    { "FunctionName", "LambdaFunctionName" }
                                }
                            }) },
                            Result = Result.FAIL
                        } }
                    },
                    // OnSuccess condition - checks after successful stage completion
                    OnSuccess = new Conditions {
                        Conditions = new [] { new Condition {
                            Result = Result.FAIL,
                            Rules = new [] { new Rule(new RuleProps {
                                Name = "CloudWatchCheck",
                                Provider = "LambdaInvoke",
                                Version = "1",
                                Configuration = new Dictionary<string, string> {
                                    { "AlarmName", "AlarmName1" },
                                    { "WaitTime", "300" },  // 5 minutes
                                    { "FunctionName", "funcName2" }
                                }
                            }) }
                        } }
                    },
                    // OnFailure condition - handles stage failure
                    OnFailure = new FailureConditions {
                        Conditions = new [] { new Condition {
                            Result = Result.ROLLBACK,
                            Rules = new [] { new Rule(new RuleProps {
                                Name = "RollBackOnFailure",
                                Provider = "LambdaInvoke",
                                Version = "1",
                                Configuration = new Dictionary<string, string> {
                                    { "AlarmName", "Alarm" },
                                    { "WaitTime", "300" },  // 5 minutes
                                    { "FunctionName", "funcName1" }
                                }
                            }) }
                        } }
                    }
                } }
            });

Synopsis

Constructors

Rule(IRuleProps)

Creates a new Rule instance.

Properties

RuleName

The name of the rule, if specified in the properties.

Methods

Reference()

Returns a reference to the rule that can be used in pipeline stage conditions.

Constructors

Rule(IRuleProps)

Creates a new Rule instance.

public Rule(IRuleProps props)
Parameters
props IRuleProps
  • Configuration properties for the rule.
Remarks

Throws: {Error} If the rule name is invalid

Properties

RuleName

The name of the rule, if specified in the properties.

public virtual string? RuleName { get; }
Property Value

string

Remarks

ExampleMetadata: infused

Methods

Reference()

Returns a reference to the rule that can be used in pipeline stage conditions.

public virtual string Reference()
Returns

string

A string in the format "#{rule.ruleName}" that can be used to reference this rule

Remarks

ExampleMetadata: infused

Back to top Generated by DocFX