Class Rule
Represents a rule in AWS CodePipeline that can be used to add conditions and controls to pipeline execution.
Inheritance
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(IRule |
Creates a new Rule instance. |
Rule(By |
Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Rule(Deputy |
Used by jsii to construct an instance of this class from DeputyProps |
Properties
Rule |
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 IRule
Props - Configuration properties for the rule.
Remarks
Throws: {Error} If the rule name is invalid
Rule(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Rule(ByRefValue reference)
Parameters
- reference Amazon.
JSII. Runtime. Deputy. By Ref Value The Javascript-owned object reference
Rule(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Rule(DeputyBase.DeputyProps props)
Parameters
- props Amazon.
JSII. Runtime. Deputy. Deputy Base. Deputy Props The deputy props
Properties
RuleName
The name of the rule, if specified in the properties.
public virtual string RuleName { get; }
Property Value
System.
Methods
Reference()
Returns a reference to the rule that can be used in pipeline stage conditions.
public virtual string Reference()
Returns
System.
A string in the format "#{rule.ruleName}" that can be used to reference this rule