python中的第三方库 cdk_Python aws-cdk.aws-codepipeline包_程序模块 - PyPI - Python中文网...

AWS代码管道构造库

管道

构造空管道:importcodepipeline=require('@aws-cdk/aws-codepipeline');constpipeline=newcodepipeline.Pipeline(this,'MyFirstPipeline');

给管道取一个人类可读的好名字:constpipeline=newcodepipeline.Pipeline(this,'MyFirstPipeline',{pipelineName:'MyPipeline',});

阶段

您可以在创建管道时提供阶段:constpipeline=newcodepipeline.Pipeline(this,'MyFirstPipeline',{stages:[{stageName:'Source',actions:[// see below...],},],});

或将一个阶段附加到现有管道:constsourceStage=pipeline.addStage({stageName:'Source',actions:[// optional property// see below...],});

您可以在管道中的任意点插入新阶段:constsomeStage=pipeline.addStage({stageName:'SomeStage',placement:{// note: you can only specify one of the below propertiesrightBefore: anotherStage,justAfter: anotherStage}});

动作

操作存在于单独的包中,@aws-cdk/aws-codepipeline-actions。

要向阶段添加操作,可以在创建阶段时提供,

在actions属性中,

或者可以使用^ {CD3>}方法来改变现有的阶段:sourceStage.addAction(someAction);

跨区域代码管道

您还可以使用跨区域功能来部署资源

(目前,仅支持cloudformation堆栈)

进入一个不同的区域。

工作原理如下:constpipeline=newcodepipeline.Pipeline(this,'MyFirstPipeline',{// ...crossRegionReplicationBuckets:{// note that a physical name of the replication Bucket must be known at synthesis time'us-west-1':s3.Bucket.fromBucketName(this,'UsWest1ReplicationBucket','my-us-west-1-replication-bucket'),},});// later in the code...newcodepipeline_actions.CloudFormationCreateUpdateStackAction({actionName:'CFN_US_West_1',// ...region:'us-west-1',});

这样,CFN_US_West_1作用将在us-west-1区域中操作,

不管你的管道在哪个区域。

如果没有为区域(管道区域除外)提供bucket

你用它来做一个动作,

将有一个新堆栈,名为-support-,

为您定义,包含复制存储桶。

这个新堆栈将取决于您的管道堆栈,

因此部署管道堆栈将首先部署支持堆栈。

示例:$ cdk ls

MyMainStack

MyMainStack-support-us-west-1

$ cdk deploy MyMainStack

# output of cdk deploy here...

事件

使用管道作为事件目标

管道可以用作CloudWatch事件规则的目标:importtargets=require('@aws-cdk/aws-events-targets');importevents=require('@aws-cdk/aws-events');// kick off the pipeline every dayconstrule=newevents.Rule(this,'Daily',{schedule: events.Schedule.rate(Duration.days(1)),});rule.addTarget(newtargets.CodePipeline(pipeline));

当管道用作事件目标时,

“codepipline:startpipelineexecution”权限已授予aws

CloudWatch事件服务。

事件源

管道会发出CloudWatch事件。为发出的事件定义事件规则

管道、阶段或操作,分别使用

构造:myPipeline.onStateChange('MyPipelineStateChange',target);myStage.onStateChange('MyStageStateChange',target);myAction.onStateChange('MyActionStateChange',target);

欢迎加入QQ群-->: 979659372

推荐PyPI第三方库

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值