Terraform - should I use user_data or provisioner to bootstrap a resource?

前端 未结 2 1093
礼貌的吻别
礼貌的吻别 2021-02-20 15:15

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 consi

2条回答
  •  死守一世寂寞
    2021-02-20 15:27

    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.

    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.

提交回复
热议问题