aws-cdk-lib.aws_codepipeline_actions.CodeCommitSourceAction

class CodeCommitSourceAction

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

Implements IAction

Extends Action

CodePipeline Source that is provided by an AWS CodeCommit repository.

If the CodeCommit repository is in a different account, you must use CodeCommitTrigger.EVENTS to trigger the pipeline.

(That is because the Pipeline structure normally only has a RepositoryName field, and that is not enough for the pipeline to locate the repository's source account. However, if the pipeline is triggered via an EventBridge event, the event itself has the full repository ARN in there, allowing the pipeline to locate the repository).

Example

// 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', {
  stages: [
    sourceStage,
    prodStage,
  ],
});

Initializer

new CodeCommitSourceAction(props: CodeCommitSourceActionProps)

Parameters

  • props CodeCommitSourceActionProps

Properties

NameTypeDescription
actionPropertiesActionPropertiesThe simple properties of the Action, like its Owner, name, etc.
variablesCodeCommitSourceVariablesThe variables emitted by this action.

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.


variables

Type: CodeCommitSourceVariables

The variables emitted by this action.

Methods

NameDescription
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.

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.