简体   繁体   中英

Terraform aws_codepipeline failed to satisfy constraint

I am creating an AWS CodePipeline resource with terraform:

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"
    }
  }
}

When running terraform apply , after 2min of aws_codepipeline.codepipeline: Still creating. it returns

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]

Edit:

The new deploy stage is:

stage {
    name = "Deploy"

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

I have this app created using:

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

And the group using:

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
  }
}

Your "Deploy" action has not 'configuration' properties which is required.

CodeDeploy action requires two configuration parameter:

  1. Application name
  2. Deployment group

Please add them to this Action.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM