1.6.22.3.1. new

terraform workspace new命令用来创建新的工作区。

1.6.22.3.1.1. 用法

terraform workspace new [NAME]

该命令使用给定名字创建一个新的工作区。不可存在同名工作区。

如果使用了-state参数,那么给定路径的状态文件会被拷贝到新工作区。

该命令支持以下可选参数:

  • -state=path:用来初始化新环境所使用的状态文件路径

创建新工作区:

$ terraform workspace new example
Created and switched to workspace "example"!

You're now on a new, empty workspace. Workspaces isolate their state,
so if you run "terraform plan" Terraform will not see any existing state
for this configuration.

使用状态文件创建新工作区:

$ terraform workspace new -state=old.terraform.tfstate example
Created and switched to workspace "example".

You're now on a new, empty workspace. Workspaces isolate their state,
so if you run "terraform plan" Terraform will not see any existing state
for this configuration.

results matching ""

    No results matching ""