aws-cdk-lib.aws_codepipeline_actions.CloudFormationCreateUpdateStackAction

class CloudFormationCreateUpdateStackAction

LanguageType name
.NETAmazon.CDK.AWS.CodePipeline.Actions.CloudFormationCreateUpdateStackAction
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscodepipelineactions#CloudFormationCreateUpdateStackAction
Javasoftware.amazon.awscdk.services.codepipeline.actions.CloudFormationCreateUpdateStackAction
Pythonaws_cdk.aws_codepipeline_actions.CloudFormationCreateUpdateStackAction
TypeScript (source)aws-cdk-lib » aws_codepipeline_actions » CloudFormationCreateUpdateStackAction

Implements IAction

Extends Action

CodePipeline action to deploy a stack.

Creates the stack if the specified stack doesn't exist. If the stack exists, AWS CloudFormation updates the stack. Use this action to update existing stacks.

AWS CodePipeline won't replace the stack, and will fail deployment if the stack is in a failed state. Use ReplaceOnFailure for an action that will delete and recreate the stack to try and recover from failed states.

Use this action to automatically replace failed stacks without recovering or troubleshooting them. You would typically choose this mode for testing.

Example

import { PhysicalName } from 'aws-cdk-lib';

// in stack for account 123456789012...
declare const otherAccountStack: Stack;
const actionRole = new iam.Role(otherAccountStack, 'ActionRole', {
  assumedBy: new iam.AccountPrincipal('123456789012'),
  // the role has to have a physical name set
  roleName: PhysicalName.GENERATE_IF_NEEDED,
});

// in the pipeline stack...
const sourceOutput = new codepipeline.Artifact();
new codepipeline_actions.CloudFormationCreateUpdateStackAction({
  actionName: 'CloudFormationCreateUpdate',
  stackName: 'MyStackName',
  adminPermissions: true,
  templatePath: sourceOutput.atPath('template.yaml'),
  role: actionRole, // this action will be cross-account as well
});

Initializer

new CloudFormationCreateUpdateStackAction(props: CloudFormationCreateUpdateStackActionProps)

Parameters

  • props CloudFormationCreateUpdateStackActionProps

Properties

NameTypeDescription
actionPropertiesActionPropertiesThe simple properties of the Action, like its Owner, name, etc.
deploymentRoleIRole

actionProperties

Type: ActionProperties

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

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


deploymentRole

Type: IRole

Methods

NameDescription
addToDeploymentRolePolicy(statement)Add statement to the service role assumed by CloudFormation while executing this action.
bind(scope, stage, options)The callback invoked when this Action is added to a Pipeline.
onStateChange(name, target?, options?)Creates an Event that will be triggered whenever the state of this Action changes.
protected bound(scope, stage, options)This is a renamed version of the IAction.bind method.

addToDeploymentRolePolicy(statement)

public addToDeploymentRolePolicy(statement: PolicyStatement): boolean

Parameters

  • statement PolicyStatement

Returns

  • boolean

Add statement to the service role assumed by CloudFormation while executing this action.


bind(scope, stage, options)

public bind(scope: Construct, stage: IStage, options: ActionBindOptions): ActionConfig

Parameters

  • scope Construct
  • stage IStage
  • options ActionBindOptions

Returns

  • ActionConfig

The callback invoked when this Action is added to a Pipeline.


onStateChange(name, target?, options?)

public onStateChange(name: string, target?: IRuleTarget, options?: RuleProps): Rule

Parameters

  • name string
  • target IRuleTarget
  • options RuleProps

Returns

  • Rule

Creates an Event that will be triggered whenever the state of this Action changes.


protected bound(scope, stage, options)

protected bound(scope: Construct, stage: IStage, options: ActionBindOptions): ActionConfig

Parameters

  • scope Construct
  • stage IStage
  • options ActionBindOptions

Returns

  • ActionConfig

This is a renamed version of the IAction.bind method.