使用terraform v0.11.11和aws插件v2.0.0_x4,尝试在AWS中创建Codebuild项目时,我刚刚开始收到错误消息。
与Codebuild有关的terraform部分如下:
resource "aws_codebuild_project" "codebuild-bitbucket" {
name = "validation-SD_REPOSITORY-SD_COUNTRY-SD_ENVIRONMENT"
description = "Validate Bitbucket Code from PR"
service_role = "${aws_iam_role.codebuild-role.arn}"
artifacts {
type = "S3"
location = "${aws_s3_bucket.artifact-store.bucket}"
packaging = "NONE"
}
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/docker:18.09.0"
type = "LINUX_CONTAINER"
privileged_mode = "true"
environment_variable {
"name" = "ECRID"
"value" = "${var.codebuild_docker_ecr_id}"
}
environment_variable {
"name" = "ECRREGION"
"value" = "${var.region}"
}
}
source {
type = "BITBUCKET"
buildspec = "configuration/buildspec.yml"
location = "${var.specific_repo}"
auth {
type = "OAUTH"
}
report_build_status = "true"
}
tags = {
country = "${var.country_tag}"
}
}
resource "aws_codebuild_webhook" "codebuild-webhook-bitbucket" {
project_name = "${aws_codebuild_project.codebuild-bitbucket.name}"
}
在对我的Codebuild配置进行更新后,添加了新的环境变量,我收到以下错误:
Error: Error applying plan:
1 error(s) occurred:
* aws_codebuild_webhook.codebuild-webhook-bitbucket: 1 error(s) occurred:
* aws_codebuild_webhook.codebuild-webhook-bitbucket: ValidationException: 1 validation error detected: Value '' at 'newProjectVersion.webhook.branches' failed to satisfy constraint: Member must have length greater than or equal to 1
status code: 400, request id: 55dcfe4b-3ffe-11e9-ae77-a3b085c34d60
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
2019/03/06 10:55:22 [DEBUG] plugin: waiting for all plugin processes to complete...
2019-03-06T10:55:22.081Z [DEBUG] plugin.terraform-provider-aws_v2.0.0_x4: 2019/03/06 10:55:22 [ERR] plugin: plugin server: accept unix /tmp/plugin325591570: use of closed network connection
2019-03-06T10:55:22.082Z [DEBUG] plugin: plugin process exited: path=/tmp/working/.terraform/plugins/linux_amd64/terraform-provider-aws_v2.0.0_x4
make: *** [Makefile:6: apply] Error 1
问题在哪?我该怎么解决?
谢谢。
答案 0 :(得分:1)
我不确定是什么原因导致的,但是最近,在固定的,已知的提供程序版本上,我也开始看到这种情况。要使其再次工作,只需将 branch_filter 添加到您的webhook资源中,如下所示:
resource "aws_codebuild_webhook" "codebuild-webhook-bitbucket" {
project_name = "${aws_codebuild_project.codebuild-bitbucket.name}"
branch_filter = ".*"
}
答案 1 :(得分:0)
这是一个错误。我们正在还原引入它的更改,这应该可以解决此问题。感谢您引起我们的注意。