我只想为特定资源运行 terraform [英] I would like to run terraform only for a specific resource

查看:19
本文介绍了我只想为特定资源运行 terraform的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 terraform 并等待需要很长时间.所以我想运行它以排除执行时间最长的 rds或者我只想运行 ec2 资源.有没有办法在 terraform 中做这些事情?

解决方案

你可以使用 -target=resource 像这样:

terraform plan -target=module.mymodule.aws_instance.myinstanceterraform apply -target=module.mymodule.aws_instance.myinstance

terraform plan -target=aws_instance.myinstanceterraform 应用 -target=aws_instance.myinstance

免责声明:在否决答案之前,请注意他实际上要求排除"或仅运行 ec2 资源".在所有这些时间之后,排除功能请求仍然在 terraform repo 中打开.p>

It takes a long time to run terraform and wait. So I would like to run it to exclude rds that takes the longest time to excute or I would like to run only ec2 resource. Is there a way to do such things in terraform?

解决方案

You can use -target=resource like this:

terraform plan -target=module.mymodule.aws_instance.myinstance
terraform apply -target=module.mymodule.aws_instance.myinstance

or

terraform plan -target=aws_instance.myinstance
terraform apply -target=aws_instance.myinstance

Disclaimer: Before downvoting the answer, please note that he actually asked to either "exclude" or "run only ec2 resource". And after all this time the exclude feature request is still open in the terraform repo.

这篇关于我只想为特定资源运行 terraform的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆