terraform validate 仅检查语法而不检查其他内容
目前我在 shell 命令下运行
@if [ -x "$$(command -v terraform)" ]; then \
echo "==> Checking terraform formatting of files"; \
(terraform validate ./test && echo "Terraform format check passed successfully") \
|| (echo "validation failed" && exit 1); \
else \
echo "No terraform command found"; \
exit 1; \
fi
,我不想初始化后端,但似乎确实如此,而且我还看到
? on test/policy.tf line 320:
? 320: module "service_admin_policy" {
?
? This module is not yet installed. Run "terraform init" to install all
? modules required by this configuration.
terraform version = 1.1.6
使用 terraform 验证时出现错误,我只想检查目录中的 .tf 文件在语法上是否正确,例如缺少大括号和逗号之类的东西。 有关如何忽略这些错误的任何帮助。
currently I am running below shell command
@if [ -x "$(command -v terraform)" ]; then \
echo "==> Checking terraform formatting of files"; \
(terraform validate ./test && echo "Terraform format check passed successfully") \
|| (echo "validation failed" && exit 1); \
else \
echo "No terraform command found"; \
exit 1; \
fi
here I dont want to initialize the backend but it seems it does that and I also see error as
? on test/policy.tf line 320:
? 320: module "service_admin_policy" {
?
? This module is not yet installed. Run "terraform init" to install all
? modules required by this configuration.
terraform version = 1.1.6
using terraform validate I just want to check if the .tf files in a directory are just syntactically correct like braces missing and comma kind of stuff.
any help on how I can ignore these errors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
验证的工作原理是检查代码的健全性,包括加载模块并确保变量命名正确。
如果您只需要本地文件的基本语法,请考虑使用
terraform fmt -write=false
。如果格式化程序无法解析该文件,则会抛出错误。Validate works at the level of checking your code for soundness, including loading modules and ensuring that variables are correctly named.
If you only want basic syntax of a local file, consider using
terraform fmt -write=false
. If the formatter is unable to parse the file, it will throw an error.