Skip to content
v2.275.0

CloudFormationExecuteChangeSetAction Class ​

CodePipeline action to execute a prepared change set.

Example ​

ts
// Source stage: read from repository
const repo = new codecommit.Repository(stack, 'TemplateRepo', {
  repositoryName: 'template-repo',
});
const sourceOutput = new codepipeline.Artifact('SourceArtifact');
const source = new cpactions.CodeCommitSourceAction({
  actionName: 'Source',
  repository: repo,
  output: sourceOutput,
  trigger: cpactions.CodeCommitTrigger.POLL,
});
const sourceStage = {
  stageName: 'Source',
  actions: [source],
};

// Deployment stage: create and deploy changeset with manual approval
const stackName = 'OurStack';
const changeSetName = 'StagedChangeSet';

const prodStage = {
  stageName: 'Deploy',
  actions: [
    new cpactions.CloudFormationCreateReplaceChangeSetAction({
      actionName: 'PrepareChanges',
      stackName,
      changeSetName,
      adminPermissions: true,
      templatePath: sourceOutput.atPath('template.yaml'),
      runOrder: 1,
    }),
    new cpactions.ManualApprovalAction({
      actionName: 'ApproveChanges',
      runOrder: 2,
    }),
    new cpactions.CloudFormationExecuteChangeSetAction({
      actionName: 'ExecuteChanges',
      stackName,
      changeSetName,
      runOrder: 3,
    }),
  ],
};

new codepipeline.Pipeline(stack, 'Pipeline', {
  crossAccountKeys: true,
  stages: [
    sourceStage,
    prodStage,
  ],
});
python
# Source stage: read from repository
repo = codecommit.Repository(stack, "TemplateRepo",
    repository_name="template-repo"
)
source_output = codepipeline.Artifact("SourceArtifact")
source = cpactions.CodeCommitSourceAction(
    action_name="Source",
    repository=repo,
    output=source_output,
    trigger=cpactions.CodeCommitTrigger.POLL
)
source_stage = {
    "stage_name": "Source",
    "actions": [source]
}

# Deployment stage: create and deploy changeset with manual approval
stack_name = "OurStack"
change_set_name = "StagedChangeSet"

prod_stage = {
    "stage_name": "Deploy",
    "actions": [
        cpactions.CloudFormationCreateReplaceChangeSetAction(
            action_name="PrepareChanges",
            stack_name=stack_name,
            change_set_name=change_set_name,
            admin_permissions=True,
            template_path=source_output.at_path("template.yaml"),
            run_order=1
        ),
        cpactions.ManualApprovalAction(
            action_name="ApproveChanges",
            run_order=2
        ),
        cpactions.CloudFormationExecuteChangeSetAction(
            action_name="ExecuteChanges",
            stack_name=stack_name,
            change_set_name=change_set_name,
            run_order=3
        )
    ]
}

codepipeline.Pipeline(stack, "Pipeline",
    cross_account_keys=True,
    stages=[source_stage, prod_stage
    ]
)
java
// Source stage: read from repository
Repository repo = Repository.Builder.create(stack, "TemplateRepo")
        .repositoryName("template-repo")
        .build();
Artifact sourceOutput = new Artifact("SourceArtifact");
CodeCommitSourceAction source = CodeCommitSourceAction.Builder.create()
        .actionName("Source")
        .repository(repo)
        .output(sourceOutput)
        .trigger(CodeCommitTrigger.POLL)
        .build();
Map<String, Object> sourceStage = Map.of(
        "stageName", "Source",
        "actions", List.of(source));

// Deployment stage: create and deploy changeset with manual approval
String stackName = "OurStack";
String changeSetName = "StagedChangeSet";

Map<String, Object> prodStage = Map.of(
        "stageName", "Deploy",
        "actions", List.of(
            CloudFormationCreateReplaceChangeSetAction.Builder.create()
                    .actionName("PrepareChanges")
                    .stackName(stackName)
                    .changeSetName(changeSetName)
                    .adminPermissions(true)
                    .templatePath(sourceOutput.atPath("template.yaml"))
                    .runOrder(1)
                    .build(),
            ManualApprovalAction.Builder.create()
                    .actionName("ApproveChanges")
                    .runOrder(2)
                    .build(),
            CloudFormationExecuteChangeSetAction.Builder.create()
                    .actionName("ExecuteChanges")
                    .stackName(stackName)
                    .changeSetName(changeSetName)
                    .runOrder(3)
                    .build()));

Pipeline.Builder.create(stack, "Pipeline")
        .crossAccountKeys(true)
        .stages(List.of(sourceStage, prodStage))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Source stage: read from repository
var repo = new Repository(stack, "TemplateRepo", new RepositoryProps {
    RepositoryName = "template-repo"
});
var sourceOutput = new Artifact("SourceArtifact");
var source = new CodeCommitSourceAction(new CodeCommitSourceActionProps {
    ActionName = "Source",
    Repository = repo,
    Output = sourceOutput,
    Trigger = CodeCommitTrigger.POLL
});
IDictionary<string, object> sourceStage = new Dictionary<string, object> {
    { "stageName", "Source" },
    { "actions", new [] { source } }
};

// Deployment stage: create and deploy changeset with manual approval
var stackName = "OurStack";
var changeSetName = "StagedChangeSet";

IDictionary<string, object> prodStage = new Dictionary<string, object> {
    { "stageName", "Deploy" },
    { "actions", new [] {
        new CloudFormationCreateReplaceChangeSetAction(new CloudFormationCreateReplaceChangeSetActionProps {
            ActionName = "PrepareChanges",
            StackName = stackName,
            ChangeSetName = changeSetName,
            AdminPermissions = true,
            TemplatePath = sourceOutput.AtPath("template.yaml"),
            RunOrder = 1
        }),
        new ManualApprovalAction(new ManualApprovalActionProps {
            ActionName = "ApproveChanges",
            RunOrder = 2
        }),
        new CloudFormationExecuteChangeSetAction(new CloudFormationExecuteChangeSetActionProps {
            ActionName = "ExecuteChanges",
            StackName = stackName,
            ChangeSetName = changeSetName,
            RunOrder = 3
        }) } }
};

new Pipeline(stack, "Pipeline", new PipelineProps {
    CrossAccountKeys = true,
    Stages = new [] { sourceStage, prodStage }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Source stage: read from repository
repo := codecommit.NewRepository(stack, jsii.String("TemplateRepo"), &RepositoryProps{
	RepositoryName: jsii.String("template-repo"),
})
sourceOutput := codepipeline.NewArtifact(jsii.String("SourceArtifact"))
source := cpactions.NewCodeCommitSourceAction(&CodeCommitSourceActionProps{
	ActionName: jsii.String("Source"),
	Repository: repo,
	Output: sourceOutput,
	Trigger: cpactions.CodeCommitTrigger_POLL,
})
sourceStage := map[string]interface{}{
	"stageName": jsii.String("Source"),
	"actions": []CodeCommitSourceAction{
		source,
	},
}

// Deployment stage: create and deploy changeset with manual approval
stackName := "OurStack"
changeSetName := "StagedChangeSet"

prodStage := map[string]interface{}{
	"stageName": jsii.String("Deploy"),
	"actions": []interface{}{
		cpactions.NewCloudFormationCreateReplaceChangeSetAction(&CloudFormationCreateReplaceChangeSetActionProps{
			"actionName": jsii.String("PrepareChanges"),
			"stackName": jsii.String(stackName),
			"changeSetName": jsii.String(changeSetName),
			"adminPermissions": jsii.Boolean(true),
			"templatePath": sourceOutput.atPath(jsii.String("template.yaml")),
			"runOrder": jsii.Number(1),
		}),
		cpactions.NewManualApprovalAction(&ManualApprovalActionProps{
			"actionName": jsii.String("ApproveChanges"),
			"runOrder": jsii.Number(2),
		}),
		cpactions.NewCloudFormationExecuteChangeSetAction(&CloudFormationExecuteChangeSetActionProps{
			"actionName": jsii.String("ExecuteChanges"),
			"stackName": jsii.String(stackName),
			"changeSetName": jsii.String(changeSetName),
			"runOrder": jsii.Number(3),
		}),
	},
}

codepipeline.NewPipeline(stack, jsii.String("Pipeline"), &PipelineProps{
	CrossAccountKeys: jsii.Boolean(true),
	Stages: []StageProps{
		sourceStage,
		prodStage,
	},
})

Initializer ​

ts
new CloudFormationExecuteChangeSetAction(props: CloudFormationExecuteChangeSetActionProps)
python
CloudFormationExecuteChangeSetAction(props: CloudFormationExecuteChangeSetActionProps)
java
new CloudFormationExecuteChangeSetAction(CloudFormationExecuteChangeSetActionProps props)
csharp
new CloudFormationExecuteChangeSetAction(CloudFormationExecuteChangeSetActionProps props)
go
NewCloudFormationExecuteChangeSetAction(Props CloudFormationExecuteChangeSetActionProps)

Properties ​

actionPropertiesActionPropertiesaction_propertiesActionPropertiesactionPropertiesActionPropertiesActionPropertiesActionPropertiesActionPropertiesActionProperties#
The simple properties of the Action, like its Owner, name, etc.

Note that this accessor will be called before the bind callback.

Methods ​

bind(scope: Construct, stage: IStage, options: ActionBindOptions): ActionConfigdef bind(self, scope: Construct, stage: IStage, options: ActionBindOptions) -> ActionConfigpublic ActionConfig bind(Construct scope, IStage stage, ActionBindOptions options)public ActionConfig Bind(Construct scope, IStage stage, ActionBindOptions options)func Bind(Scope Construct, Stage IStage, Options ActionBindOptions) ActionConfig#
The callback invoked when this Action is added to a Pipeline.
onStateChange(name: string, target?: IRuleTarget, options?: RuleProps): Ruledef on_state_change(self, name: str, target: typing.Optional[IRuleTarget] = None, options: typing.Optional[RuleProps] = None) -> Rulepublic Rule onStateChange(String name, IRuleTarget target, RuleProps options)public Rule OnStateChange(string name, IRuleTarget? target = null, RuleProps? options = null)func OnStateChange(Name *string, Target IRuleTarget, Options RuleProps) Rule#
Creates an Event that will be triggered whenever the state of this Action changes.