0

我通过在本地运行 terraform init && terraform 计划并在 Terraform Enterprise 中创建了一个工作区,并将 Terraform 企业设置为我的后端:

    # Using a single workspace:
    terraform {
     backend "remote" {
      hostname = "dep.app.example.io"
      organization = "nnnn"

      workspaces {
       name = "create-workspace"
      }
     }
    }

Terraform Apply 有效,我可以使用以下代码通过 Terraform Enterprise 启动 ec2:

    provider "aws" {
     region = "${var.region}"
    }

    resource "aws_instance" "feature" {
     count = 1
     ami = "${var.ami}"
     availability_zone = "${var.availability_zone}"
     instance_type = "${var.instance_type}"
     tags = {
      Name = "${var.name_tag}"
     }
    }

现在,当我运行 terraform destroy 时,出现此错误:

    Error: error creating run: Invalid Attribute Infrastructure is 
    not destroyable

    The configured "remote" backend encountered an unexpected 
    error. Sometimes this is caused by network connection problems, 
    in which case you could retry the command. If the issue 
    persists please open a support ticket to get help resolving the 
    problem.

我在这里做错了什么?我希望能够运行 terraform destroy 来破坏我的新 Terraform 企业工作区启动的基础设施。

编辑:日志:

2019/04/03 09:11:54 [INFO] Terraform version: 0.11.11  ac4fff416318bf0915a0ab80e062a99ef3724334
2019/04/03 09:11:54 [INFO] Go runtime version: go1.11.1
2019/04/03 09:11:54 [INFO] CLI args: []string{"/usr/local/bin/terraform", "destroy"}
2019/04/03 09:11:54 [DEBUG] Attempting to open CLI config file: /Users/nlegorrec/.terraformrc
2019/04/03 09:11:54 Loading CLI configuration from /Users/nlegorrec/.terraformrc
2019/04/03 09:11:54 [INFO] CLI command args: []string{"destroy"}
2019/04/03 09:11:54 [TRACE] Preserving existing state lineage "f7abdc54-236c-c906-e701-049f3e2cc00c"
2019/04/03 09:11:54 [TRACE] Preserving existing state lineage "f7abdc54-236c-c906-e701-049f3e2cc00c"
2019/04/03 09:11:54 [DEBUG] Service discovery for dep.app.redbull.com at https://dep.app.redbull.com/.well-known/terraform.json
2019/04/03 09:11:56 [DEBUG] Retrieve version constraints for service tfe.v2 and product terraform
2019/04/03 09:11:57 [INFO] command: backend initialized: *remote.Remote
2019/04/03 09:11:57 [DEBUG] checking for provider in "."
2019/04/03 09:11:57 [DEBUG] checking for provider in "/usr/local/bin"
2019/04/03 09:11:57 [DEBUG] checking for provider in ".terraform/plugins/darwin_amd64"
2019/04/03 09:11:57 [DEBUG] found provider "terraform-provider-aws_v2.4.0_x4"
2019/04/03 09:11:57 [DEBUG] found valid plugin: "aws", "2.4.0", "/Users/nlegorrec/dev/Software Engineering/emp-kpi-tracker_web/dep/.terraform/plugins/darwin_amd64/terraform-provider-aws_v2.4.0_x4"
2019/04/03 09:11:57 [DEBUG] checking for provisioner in "."
2019/04/03 09:11:57 [DEBUG] checking for provisioner in "/usr/local/bin"
2019/04/03 09:11:57 [DEBUG] checking for provisioner in ".terraform/plugins/darwin_amd64"
2019/04/03 09:11:57 [INFO] backend/remote: starting Apply operation

2019/04/03 09:12:00 [DEBUG] plugin: waiting for all plugin processes to complete...
Error: error creating run: Invalid Attribute Infrastructure is not destroyable

The configured "remote" backend encountered an unexpected error. Sometimes
this is caused by network connection problems, in which case you could retry
the command. If the issue persists please open a support ticket to get help
resolving the problem.
4

1 回答 1

1

即使它有点晚了,希望这个答案可以在未来帮助其他人。

使用 Terraform Enterprise 或 Terraform Cloud 时,您需要确保遵循他们关于从工作区中销毁和删除的指导

这方面的文档位于此处

要将由工作区管理的基础设施的销毁排队,您需要确保在工作区的变量中,您已分配名称CONFIRM_DESTROY为值为的变量1

重要的是,对工作区的任何更改都需要管理员权限

完成后,您应该能够像在本地 Terraform 中一样使用 CLI 工作流。

于 2019-11-28T08:56:20.393 回答