Problem scenario
You are trying to get user data to create a file on a server in Terraform. It is in a directory that requires sudo privileges. You use the “sudo” command in the Bash script. The Bash script executes except a file is never transferred. How do you get Terraform to copy a file to a new server?
Solution
Use the Terraform-supported cloud_config option instead of having a Bash script transfer the file.
…
Continue reading “How Do You Create a File on a Server with Terraform?”