'How to add cloud-config yaml to DO droplet through Terraform?
I'm not able to pass a yaml file through the user-data parameter as pointed out in this Terraform Tutorial. Not sure why the yaml file is not working. To test I was able to pass a shell script. So no reason for the yaml file not to work unless im missing something...
Here is my replication:
resource "digitalocean_droplet" "web" {
image = "docker-20-04"
name = "web"
region = "nyc3"
size = "s-1vcpu-1gb"
...
user_data = file("scripts/cloud-config.yaml") #This does not work!
}
Building the droplet like so causes an VM error and does not allow me to SSH into my droplet...
I am however able to literally write the #cloud-config as the parameter like so:
user_data = <<EOF
#cloud-config
packages:
- build-essential
- libjpeg62-dev
- zlib1g-dev
- libwebp-dev
- libpq-dev
- postgresql
- postgresql-contrib
runcmd:
- sed -i -e '/^Port/s/^.*$/Port 4444/' /etc/ssh/sshd_config
- sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
- sed -i -e '$aAllowUsers safeplate' /etc/ssh/sshd_config
- service ssh restart
EOF
# This works, but I would rather pass a config file.
Is the Terraform Tutorial out-dated? Why can I not pass a config yaml in the way I replicated above?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
