我使用工作空间,本地变量和-backend-config使用terraform为不同环境(测试/生产)创建了基础结构,因此只有两个不同文件,其他文件在这两种环境中都是相同的。
不幸的是,我找不到以相同方式销毁特定环境的方法(没有为每个环境创建大量特定文件)。
我想念什么吗?有办法吗?
任何帮助将不胜感激。
谢谢!
此致
佛罗伦萨
编辑:感谢您的回答,我设法使用工作区,本地人和backend-config来做我想做的事!
答案 0 :(得分:0)
请勿混合使用init/workspace
至plan/apply/destroy
的地形命令。
所以我想您使用以下命令来设置后端(保存tfstate文件的位置)
terraform init -backend-config=<path>
terraform get
terraform workspace select <env>
然后,对于所有计划,应用和销毁命令,应在带有相同-var-file=<file>
或-var 'foo=bar'
选项的命令下运行。
terraform plan -var-file=dev/terraformtfvars -var 'foo=bar'
terraform apply -var-file=dev/terraformtfvars -var 'foo=bar'
terraform destroy -var-file=dev/terraformtfvars -var 'foo=bar'
让我知道这是否能解释您的担忧。
答案 1 :(得分:0)
您可以使用2019-01-20T19:17:07.354392Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-01-20T19:17:07.354481Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2019-01-20T19:17:07.355021Z 0 [ERROR] Cannot open Windows EventLog; check privileges, or start server with --log_syslog=0
2019-01-20T19:17:07.355045Z 0 [Note] C:\MAMP\\bin\mysql\bin\mysqld.exe (mysqld 5.7.24-log) starting as process 12444 ...
2019-01-20T19:19:42.728216Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-01-20T19:19:42.728309Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2019-01-20T19:19:42.728909Z 0 [ERROR] Cannot open Windows EventLog; check privileges, or start server with --log_syslog=0
2019-01-20T19:19:42.728934Z 0 [Note] C:\MAMP\\bin\mysql\bin\mysqld.exe (mysqld 5.7.24-log) starting as process 4224 ...
2019-01-20T19:21:28.706864Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-01-20T19:21:28.706960Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2019-01-20T19:21:28.707537Z 0 [ERROR] Cannot open Windows EventLog; check privileges, or start server with --log_syslog=0
2019-01-20T19:21:28.707565Z 0 [Note] C:\MAMP\\bin\mysql\bin\mysqld.exe (mysqld 5.7.24-log) starting as process 5944 ...
定位要销毁的特定资源。
dateAxis._gridInterval
答案 2 :(得分:0)
使用Terraform V 0.13
我试图传递tfvars
文件来破坏这样的命令:
terraform destroy -auto-approve -var-file="env/stage.tfvars"