Accessing Terraform variables within user_data provider template file

后端 未结 2 1033
说谎
说谎 2021-01-01 22:51

I am launching a aws_launch_configuration instance using terraform.

I\'m using a shell script for the user_data variable, like so:

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 23:25

    For people coming here since Terraform 0.12 and later, the templatefile function should be used instead of using template_file resource, so for the example in the question, it would be something like

    locals {
      vars = {
        some_address = aws_instance.some.private_ip
      }
    }
    
    user-data = templatefile("router-init.sh", vars)
    

提交回复
热议问题