嗨,我已经为我的基础设施部署创建了自变异的CDK管道。
我为这个管道添加了不同的应用程序阶段,比如部署到DEV,部署到UAT,部署到PROD管道正在按预期工作,并部署对DEV的更改->UAT->PROD环境,但在部署到UAT和PROD之前,我希望有手动审批操作,这样更改就不会自动部署到UAD和PROD,在该按钮点击后,必须有手动审批动作按钮。更改应升级到更高的环境。
我可以在代码管道中找到这个选项,但在CdkPipeline构造中找不到这样的选项。
这是示例代码-
const pipeline = new CdkPipeline(this, 'Pipeline', {
// The main pipeline name
pipelineName: 'Infra-Inception-Pipeline',
cloudAssemblyArtifact,
// Where the cdk source can be found
sourceAction: new codepipeline_actions.CodeCommitSourceAction({
actionName: "CloneCodeCommitRepo",
repository: cdkSourceCodeRepo,
output: cdkSourceOutput,
// branch: "develop"
}),
// How will cdk be built and synthesized
synthAction: SimpleSynthAction.standardNpmSynth({
sourceArtifact: cdkSourceOutput,
cloudAssemblyArtifact,
// We need a build step to compile the TypeScript
buildCommand: 'npm run build'
}),
});
pipeline.addApplicationStage(new CreateInfrastructureStage(this, 'DEV',
{
env: { "account":"1111" "region":"us-east-1" }
}));
//I would like to add Manual Approval gate here
pipeline.addApplicationStage(new CreateInfrastructureStage(this, 'UAT',
{
env: { "account":"2222" "region":"us-east-1" }
}));
我在AWS文档中找到了答案。
addApplicationStage((添加的每个应用程序阶段都会导致添加一个单独的管道阶段,该阶段由addApplicationStage((调用返回。该阶段由CdkStage结构表示。您可以通过调用其addActions((方法向阶段添加更多操作。例如:
// import { ManualApprovalAction } from '@aws-cdk/aws-codepipeline-actions';
const testingStage = pipeline.addApplicationStage(new MyApplication(this, 'Testing', {
env: { account: '111111111111', region: 'eu-west-1' }
}));
// Add an action -- in this case, a Manual Approval action
// (testingStage.addManualApprovalAction() is an equivalent convenience method)
testingStage.addActions(new ManualApprovalAction({
actionName: 'ManualApproval',
runOrder: testingStage.nextSequentialRunOrder(),
}));