Terraform Bitbucket管道工件

发布于 2025-02-13 05:20:43 字数 1151 浏览 0 评论 0原文

我想用Bitbucket管道来dpeloy Terraform,一切都延伸到应用阶段。 在应用步骤中,我会遇到此错误: `

terraform apply -auto-approve output-${ENVIRONMENT}.plan

Error: Failed to load "output-development.plan" as a plan file

Error: stat output-development.plan: no such file or directory

我如何将工件转移到应用阶段,以便Bitbucket可以阅读并继续使用申请步骤?

这是我的管道 图像:Hashicorp/Terraform

definitions:
  steps:
    - step: &pre-deploy
        name: Initilize the terraform environment
        script:
          - terraform init -backend-config ${ENVIRONMENT}-backend.tfvars
          - terraform validate
          - terraform plan -var-file=${ENVIRONMENT}.tfvars -out output-${ENVIRONMENT}.plan
        artifacts:
          - output-${ENVIRONMENT}.plan
    - step: &terraform-apply
        name: Deploy terraform code
        script:
          - terraform apply -auto-approve output-${ENVIRONMENT}.plan

pipelines:
  branches:
    develop:
      - step: 
          <<: *pre-deploy
          deployment: terraform-prepare
      - step: 
          <<: *terraform-apply
          trigger: manual
          deployment: terraform-deploy

I want to dpeloy terraform with bitbucket pipelines and everything works up to the apply stage.
On apply step I'm getting this error:
`

terraform apply -auto-approve output-${ENVIRONMENT}.plan

Error: Failed to load "output-development.plan" as a plan file

Error: stat output-development.plan: no such file or directory

How can I transfer the artifact to the apply stage so bitbucket can read it and proceed with the apply step?

This is my pipeline
image: hashicorp/terraform

definitions:
  steps:
    - step: &pre-deploy
        name: Initilize the terraform environment
        script:
          - terraform init -backend-config ${ENVIRONMENT}-backend.tfvars
          - terraform validate
          - terraform plan -var-file=${ENVIRONMENT}.tfvars -out output-${ENVIRONMENT}.plan
        artifacts:
          - output-${ENVIRONMENT}.plan
    - step: &terraform-apply
        name: Deploy terraform code
        script:
          - terraform apply -auto-approve output-${ENVIRONMENT}.plan

pipelines:
  branches:
    develop:
      - step: 
          <<: *pre-deploy
          deployment: terraform-prepare
      - step: 
          <<: *terraform-apply
          trigger: manual
          deployment: terraform-deploy

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文