CodeCommitSourceActionProps Struct
Construction properties of the CodeCommitSourceAction CodeCommit source CodePipeline Action.
| Source | aws-codepipeline-actions/lib/codecommit/source-action.ts |
|---|---|
| Type last changed |
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', {
crossAccountKeys: true,
stages: [
sourceStage,
prodStage,
],
});
# 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
]
)
// 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();
// 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 }
});
// 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,
},
})
Properties
Note that Action names must be unique within a single Stage.
branchoptionalstringbranchoptionalstrbranchoptionalStringBranchoptionalstringBranchoptional*string = 'master' #codeBuildCloneOutputoptionalbooleancode_build_clone_outputoptionalboolcodeBuildCloneOutputoptionalBooleanCodeBuildCloneOutputoptionalboolCodeBuildCloneOutputoptional*bool = false #Note: if this option is true, then only CodeBuild actions can use the resulting output.
customEventRuleoptionalICustomEventRulecustom_event_ruleoptionalICustomEventRulecustomEventRuleoptionalICustomEventRuleCustomEventRuleoptionalICustomEventRuleCustomEventRuleoptionalICustomEventRule #Default: Event rule which is triggered by CodeCommit repository on commit
You must provide the eventPattern and target properties in the customEventRule object. Check which eventPattern to use: https://docs.aws.amazon.com/codecommit/latest/userguide/monitoring-events.html
eventRoleoptionalIRoleevent_roleoptionalIRoleeventRoleoptionalIRoleEventRoleoptionalIRoleEventRoleoptionalIRole #Default: a new role will be created.
Used only when trigger value is CodeCommitTrigger.EVENTS.
repositoryIRepositoryrepositoryIRepositoryrepositoryIRepositoryRepositoryIRepositoryRepositoryIRepository required #Default: a new Role will be generated
notes
The Pipeline's Role will assume this Role (the required permissions for that will be granted automatically) right before executing this Action. This Action will be passed into your IAction.bind method in the ActionBindOptions.role property.
runOrderoptionalnumberrun_orderoptionalint | floatrunOrderoptionalNumberRunOrderoptionaldoubleRunOrderoptional*float64 = 1 #RunOrder determines the relative order in which multiple Actions in the same Stage execute.
triggeroptionalCodeCommitTriggertriggeroptionalCodeCommitTriggertriggeroptionalCodeCommitTriggerTriggeroptionalCodeCommitTriggerTriggeroptionalCodeCommitTrigger = CodeCommitTrigger.EVENTS #variablesNamespaceoptionalstringvariables_namespaceoptionalstrvariablesNamespaceoptionalStringVariablesNamespaceoptionalstringVariablesNamespaceoptional*string #Default: a name will be generated, based on the stage and action names, if any of the action's variables were referenced - otherwise, no namespace will be set