在AWS Codestar中,如何将分支部署配置到特定环境?

时间:2017-09-23 22:42:35

标签: amazon-web-services aws-api-gateway amazon-cloudformation aws-codestar

我刚刚创建了一个全新的AWS Codestar项目。

据我所知,Codestar只是一个集成了多个AWS产品的仪表板。

有一件事我还不知道如何配置,而且它是分支部署。

在我的git存储库中,我有3个分支:masterdevelopstaging

在理想的世界中,master部署到生产,develop部署到开发环境,staging部署到QA环境。

我不知道如何使用AWS配置此管道,并且我无法在其开发人员门户中找到相关文档。

这是我的buildspec.yml文件,以防它可以在那里配置:

version: 0.2

phases:
  install:
    commands:
      - echo Installing NPM Packages...
      - npm install
  build:
    commands:
      - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template template-export.yml

artifacts:
  type: zip
  files:
    - template-export.yml

这是一个使用AWS API Gateway将请求路由到AWS Lambda函数的项目,如果这很重要的话。

1 个答案:

答案 0 :(得分:2)

可悲的是,AWS CodePipline并不支持传入git分支。去年他们只增加了对传递git commit sha1的支持(更多可以找到here)。

我建议您按照CodePipline文档here,为每个分支创建一个管道(您甚至可以创建一个特殊的buildspec_dev.yaml或buildspec_prod.yaml,查看更多示例{{3 }})。