Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/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文件夹设置版本吗?_Terraform - Fatal编程技术网

我应该为.terraform文件夹设置版本吗?

我应该为.terraform文件夹设置版本吗?,terraform,Terraform,我开始使用Terraform,我有一个由“Terraform init/apply”创建的.Terraform文件夹,其中包含: ./plugins/linux_amd64/lock.json ./plugins/linux_amd64/地形提供商谷歌 ./plugins/modules/modules.json terraform.tfstate 我应该对这些文件进行版本设置吗?我想说不…terraform目录是一个本地缓存,terraform会在其中保留一些文件,以便对该配置进行后续操作

我开始使用Terraform,我有一个由“Terraform init/apply”创建的.Terraform文件夹,其中包含:

  • ./plugins/linux_amd64/lock.json
  • ./plugins/linux_amd64/地形提供商谷歌
  • ./plugins/modules/modules.json
  • terraform.tfstate

我应该对这些文件进行版本设置吗?我想说不…

terraform目录是一个本地缓存,terraform会在其中保留一些文件,以便对该配置进行后续操作。其内容不包含在版本控制中

但是,您可以通过在配置中指定某些东西来确保在其他系统上忠实地复制此目录,这些东西将通知Terraform将在其中放置什么:

  • terraform
    块中使用
    required\u providers
    ,为谷歌云平台提供商指定精确的版本约束:

    terraform {
      required_providers {
        google = "3.0.0"
      }
    }
    
    (这与
    .terraform/plugins
    目录有关)

  • 在您调用的每个模块中(到目前为止似乎没有,但将来可能会有),确保其
    引用的是精确版本,而不是浮动分支(对于VCS模块),或者将
    版本
    设置为精确版本(对于来自的模块):

    (这与
    .terraform/modules
    目录有关)

  • 如果您使用的是远程后端,请在
    terraform
    块内的
    后端
    块中包括完整配置,而不是使用
    -backend config
    参数来
    terraform init

    (这与
    .terraform/terraform.tfstate
    文件有关,该文件会记住您的活动后端配置,以便以后进行操作)

module "example"
  source = "git::https://github.com/example/example.git?ref=v2.0.0"
  # ...
}
module "example"
  source  = "hashicorp/consul/aws"
  version = "v1.2.0
}