Terraform错误:“远程”后端目前不支持资源定位

时间:2019-09-27 17:50:48

标签: terraform

Terraform Cloud运行-target时是否支持terraform plan...标志?

在Terraform Cloud中似乎没有打开或关闭此功能的选项。我想知道这是否表示Terraform Cloud整体上不支持模块定位,或者Terraform Cloud的我实例中是否有一个选项可以关闭此功能。

预期结果:Terraform成功创建了计划。

实际结果:Terraform报告以下错误:

Error: Resource targeting is currently not supported

The "remote" backend does not support resource targeting at this time.

编辑9/30/19:

我正在使用Terraform Cloud的“远程执行器”和Terraform版本0.12.9。

2 个答案:

答案 0 :(得分:0)

# main.tf

resource "null_resource" "test" {
}

resource "null_resource" "test2" {
}

terraform {
  backend "remote" {
    hostname = "app.terraform.io"
    organization = "<my-org>"

    workspaces {
      name = "<my-workspace>"
    }
  }
}

运行Terraform计划时,我没有遇到上述错误:

❯ terraform plan -target=null_resource.test -out=plan.tfplan 
Acquiring state lock. This may take a few moments...
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.


------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # null_resource.test will be created
  + resource "null_resource" "test" {
      + id = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

------------------------------------------------------------------------

This plan was saved to: plan.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfplan"

Releasing state lock. This may take a few moments...

这是我的版本:

❯ terraform version  
Terraform v0.12.6
+ provider.null v2.1.2

Your version of Terraform is out of date! The latest version
is 0.12.9. You can update by downloading from www.terraform.io/downloads.html

答案 1 :(得分:0)

如果您参考https://github.com/hashicorp/terraform/blob/a8d01e3940b406a3c974bfaffd0ca5f534363cc7/backend/remote/backend_plan.go#L73,则会看到Terraform Cloud后端中有一个明确的检查,该检查禁用了Plan targeting

在同一段代码中,您可以找到Terraform Cloud中当前有效的所有检查和限制。

如果需要这些功能,可以将后端迁移到aws s3之类的东西:https://www.terraform.io/docs/backends/types/s3.html

要了解有关后端的更多信息,请参阅:https://www.terraform.io/docs/backends/index.html