Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
代码构建源阶段的terraform AWS代码管道配置_Terraform_Aws Codepipeline_Aws Codebuild - Fatal编程技术网

代码构建源阶段的terraform AWS代码管道配置

代码构建源阶段的terraform AWS代码管道配置,terraform,aws-codepipeline,aws-codebuild,Terraform,Aws Codepipeline,Aws Codebuild,我正在尝试使用terraform创建代码管道作业。我已经有了一个正在工作的代码构建项目。以下是我的资源: resource "aws_codepipeline" "my-project" { name = "my-project" role_arn = "${aws_iam_role.my-project-codepipeline.arn}" artifact_store { location = "${aws_s3_bucket.my-artifacts.buck

我正在尝试使用terraform创建代码管道作业。我已经有了一个正在工作的代码构建项目。以下是我的资源:

resource "aws_codepipeline" "my-project" {
  name     = "my-project"
  role_arn = "${aws_iam_role.my-project-codepipeline.arn}"

  artifact_store {
    location = "${aws_s3_bucket.my-artifacts.bucket}"
    type     = "S3"
  }

  stage {
    name = "Source"

    action {
      name     = "Source"
      category = "Source"
      owner    = "AWS"
      provider = "CodeCommit"
      version  = "1"

      configuration {
        ProjectName = "my-project"
        Branch      = "master"
      }
    }
  }

  stage {
    name = "Build"

    action {
      name     = "Build"
      category = "Build"
      owner    = "AWS"
      provider = "CodeBuild"
      version  = "1"

      configuration {
        ProjectName = "my-project"
      }
    }
  }
}

当我尝试
terraform apply
时,我得到的错误是
创建代码管道时出错:InvalidActionDeclarationException:Action“Source”的操作配置包含未知的配置“ProjectName”
。在哪里可以找到此配置部分的正确架构?到目前为止,我找到的所有文档和示例都是通用的,并且省略了我在这里需要的特定代码构建设置/模式。

证明我需要的源代码设置是

RepositoryName = "my-project"
BranchName = "master"

如果您最终需要访问CodeBuild sts令牌,这可能会有所帮助

version: 0.2
env:
  variables:
    AWS_DEFAULT_REGION: "us-west-2"
phases:
  install:
    commands:
      - apt-get -y update
      - apt-get -y install jq
  pre_build:
      commands:

      # load acs submodule (since codebuild doesn't pull the .git folder from the repo
      - cd common 
      - git clone https://gituser@gitlab.com/aws-account-tools/acs.git
      - cd ../

      #install terraform
      - other/install-tf-linux64.sh
      - terraform --version

      #set env variables for terraform provider
      - curl 169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI | jq 'to_entries | [ .[] | select(.key | (contains("Expiration") or contains("RoleArn"))  | not) ] |  map(if .key == "AccessKeyId" then . + {"key":"AWS_ACCESS_KEY_ID"} else . end) | map(if .key == "SecretAccessKey" then . + {"key":"AWS_SECRET_ACCESS_KEY"} else . end) | map(if .key == "Token" then . + {"key":"AWS_SESSION_TOKEN"} else . end) | map("export \(.key)=\(.value)") | .[]' -r > /tmp/cred.txt # work around https://github.com/hashicorp/terraform/issues/8746
      - chmod +x /tmp/cred.txt
      - . /tmp/cred.txt
  build:
    commands:
      - ls
      - cd your/repo's/folder/with/main.tf 
      - terraform init 
      - terraform plan 
      - terraform 
申请