【问题标题】:Terraform Error: The "remote" backend does not support resource targeting at this timeTerraform 错误:“远程”后端目前不支持资源定位
【发布时间】:2019-09-27 17:50:48
【问题描述】:

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

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。

【问题讨论】:

  • 您能否提供更多信息,例如您使用的是哪个版本的 terraform?我没有遇到上述错误
  • @AndyAldo 我应该指定我在 Terraform Cloud 中使用远程执行器。当我尝试使用远程执行器时,我只会收到此错误。

标签: terraform


【解决方案1】:

如果您引用 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

【讨论】:

    【解决方案2】:
    # 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 plan 时没有遇到上述错误:

    ❯ 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
    

    【讨论】:

      猜你喜欢
      • 2019-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      • 2018-01-04
      • 2019-11-03
      相关资源
      最近更新 更多