ArtifactPath Class
A specific file within an output artifact.
The most common use case for this is specifying the template file for a CloudFormation action.
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
Properties
Methods
artifactPath(artifactName: string, fileName: string): ArtifactPath // chainable@staticmethod def artifact_path(artifact_name: str, file_name: str) -> ArtifactPathpublic static ArtifactPath artifactPath(String artifactName, String fileName)public static ArtifactPath ArtifactPath(string artifactName, string fileName)func ArtifactPath(ArtifactName *string, FileName *string) ArtifactPathstatic#