I'm trying do this simple command but it keeps failing:
echo "secret_backend_command: /home/ec2-user/dd-get-secrets.py" >> /etc/datadog-agent/datadog.yaml"
I tried all the following:
- [ sh, -c, echo "secret_backend_command: /home/ec2-user/dd-get-secrets.py" >> /etc/datadog-agent/datadog.yaml ]
- 'sh -c "echo \"secret_backend_command: /home/ec2-user/dd-get-secrets.py\" >> /etc/datadog-agent/datadog.yaml"'
- sh -c "echo 'secret_backend_command: /home/ec2-user/dd-get-secrets.py' >> /etc/datadog-agent/datadog.yaml
any idea how to fix this quotes ?
note I tested with another file rather than datadpg.yaml because I'm getting Permission denied for this one.
examples I found in here didn't work
I changed the way of doing it and instead of having it in the yaml list in runcmds, I created a script and instead put this command inside and call the script in the runcmds. By doing so, I got rid of the tricky handling of ":" and quotes in cloud-init.
UserData:
'Fn::Base64': !Sub |
#cloud-config
write_files:
- path: /home/ec2-user/update-datadog-config.sh
permissions: 0744
owner: root
content: |
#!/usr/bin/env bash
set -e
echo "secret_backend_command: /home/ec2-user/dd-get-secrets.py" >> /etc/datadog-agent/datadog.yaml
runcmd:
- bash /home/ec2-user/update-datadog-config.sh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With