Terraform-我应该使用user_data还是Provisioner来引导资源? [英] Terraform - should I use user_data or provisioner to bootstrap a resource?

查看:163
本文介绍了Terraform-我应该使用user_data还是Provisioner来引导资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎我可以将 user_data 与模板文件一起使用,也可以将 remote-exec provisioner 与内联命令进行引导。那么哪个被认为更惯用呢?

It seems like I can use either user_data with a template file or a "remote-exec" provisioner with inline commands to bootstrap. So which one is considered more idiomatic?

推荐答案

您应使用 user_data 用户数据字段是惯用的,因为它是AWS固有的,而remote-exec提供者特定于Terraform,这只是调用AWS API的多种方式之一。

You should use user_data. The user data field is idiomatic because it's native to AWS, whereas the remote-exec provisioner is specific to Terraform, which is just one of many ways to call the AWS API.

此外,用户数据在AWS控制台,并且通常是在AWS中使用Auto Scaling组的重要部分,您希望每个EC2实例在启动时执行相同的配置代码。使用Terraform的远程执行程序配置器无法做到这一点。

Also, the user-data is viewable in the AWS console, and often an important part of using Auto Scaling Groups in AWS, where you want each EC2 Instance to execute the same config code when it launches. It's not possible to do that with Terraform's remote-exec provisioner.

这篇关于Terraform-我应该使用user_data还是Provisioner来引导资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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