【问题标题】:Terraform aws_codepipeline failed to satisfy constraintTerraform aws_codepipeline 未能满足约束
【发布时间】:2020-07-24 03:32:33
【问题描述】:

我正在使用 terraform 创建 AWS CodePipeline 资源:

resource "aws_codepipeline" "codepipeline" {
  name     = "codepipeline-tst"
  role_arn = "${aws_iam_role.codepipeline_role.arn}"

  artifact_store {
    location = "codepipeline-eu-east-1-<ACC_NUM>"
    type     = "S3"
  }

  stage {
    name = "Source"

    action {
      name             = "Source"
      category         = "Source"
      owner            = "ThirdParty"
      provider         = "GitHub"
      version          = "1"
      output_artifacts = ["artifact"]

      configuration = {
        Owner  = "MyOwner"
        Repo   = "MyRepo"
        Branch = "master"
        OAuthToken = ""
      }
    }
  }

  stage {
    name = "Deploy"

    action {
      name            = "Deploy"
      category        = "Deploy"
      owner           = "AWS"
      provider        = "CodeDeploy"
      input_artifacts = ["artifact"]
      version         = "1"
    }
  }
}

运行terraform apply时,aws_codepipeline.codepipeline: Still creating. 2分钟后返回

Error: Error creating CodePipeline: ValidationException: 1 validation error detected: Value at 'pipeline.stages.1.member.actions.1.member.configuration' failed to satisfy constraint: Map value must satisfy constraint: [Member must have length less than or equal to 1000, Member must have length greater than or equal to 1]

编辑:

新的部署阶段是:

stage {
    name = "Deploy"

    action {
      name            = "Deploy"
      category        = "Deploy"
      owner           = "AWS"
      provider        = "CodeDeploy"
      input_artifacts = ["artifact"]
      version         = "1"
      configuration = {
        ApplicationName  = "my-app"
        DeploymentGroupName  = "bar"
      }
    }
  }

我使用以下方法创建了这个应用程序:

resource "aws_codedeploy_app" "my-app" {
  compute_platform = "Server"
  name             = "my-app"
}

以及使用的组:

resource "aws_codedeploy_deployment_group" "my_group-2" {
  app_name               = "my-app"
  deployment_group_name  = "bar"
  service_role_arn       = "arn..."

  ec2_tag_filter {
    key   = "aws:autoscaling:groupName"
    type  = "KEY_AND_VALUE"
    value = "MyContainerService"
  }

  auto_rollback_configuration {
    enabled = false
  }
}

【问题讨论】:

    标签: amazon-web-services terraform aws-codepipeline


    【解决方案1】:

    您的“部署”操作没有所需的“配置”属性。

    CodeDeploy 操作需要两个配置参数:

    1. 应用程序名称
    2. 部署组

    请将它们添加到此操作中。

    【讨论】:

    • 刚刚添加到设置中。仍然有同样的错误。原始帖子中的代码更改。
    猜你喜欢
    • 1970-01-01
    • 2016-09-10
    • 1970-01-01
    • 2015-08-24
    • 1970-01-01
    • 2022-11-10
    • 2021-12-01
    • 2016-02-27
    • 1970-01-01
    相关资源
    最近更新 更多