我正在使用Terraform设置AWS CodeBuild项目。查看Terraform文档https://www.terraform.io/docs/providers/aws/r/codebuild_project.html,我无法弄清楚使用哪个参数来定义源版本,如图像中突出显示的那样:
Terraform是否支持此选项?我希望CodeBuild项目从master以外的另一个分支的源代码构建。
答案 0 :(得分:2)
您可以使用source_version
参数
resource "aws_codebuild_project" "example" {
name = "test-project"
description = "test_codebuild_project"
build_timeout = "5"
service_role = "${aws_iam_role.example.arn}"
source_version = "master"
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/standard:1.0"
type = "LINUX_CONTAINER"
image_pull_credentials_type = "CODEBUILD"
...
...
source {
type = "GITHUB"
location = "https://github.com/mitchellh/packer.git"
git_clone_depth = 1
git_submodules_config {
fetch_submodules = true
}
}
}
该功能正在开发中。现在可用,请在下面找到文档和问题。
答案 1 :(得分:2)
您可以使用 source_version ,如您所引用的文档中所述 https://www.terraform.io/docs/providers/aws/r/codebuild_project.html
source_version = "master"
在 source_version 中指定分支的工作方式与在AWS控制台中相同,例如
source_version = "refs/heads/my-feature-branch"
其他带有标签,请求请求的示例可以在这里找到: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-source-version.html