1

I want to file from .ebextentions/td-agent.conf to /etc/td-agent/td-agent.conf. But its not working and getting below error.

enter image description here

if you see attached image, there are 3 files in .ebextentions. I had put copy command in 01-main.config.

--- 

container_commands: 
  01_cron_job: 
    command: "touch /tmp/is_leader"
    leader_only: true
  01_tdconfcopy_job: 
    command: "yes | cp .ebextensions/td-agent.conf /etc/td-agent/td-agent.conf"

error is as given below

Command failed on instance. Return code: 1 Output: cp: cannot create regular file '/etc/td-agent/td-agent.conf': No such file or directory
Jaishree Mishra
  • 545
  • 2
  • 5
  • 24

1 Answers1

1

The issue is you're copying a file to a directory that doesn't exist. You should create the output directory first and then copy config files.

So it would be:

--- 

container_commands: 
01_cron_job: 
    command: "touch /tmp/is_leader"
    leader_only: true
01_create_dir: 
    command: "sudo mkdir -p /etc/td-agent/"
02_tdconfcopy_job: 
    command: "yes | cp .ebextensions/td-agent.conf /etc/td-agent/td-agent.conf"

Alternatively, you could to create a file on the server directly with files command.

files:
    "/etc/td-agent/td-agent.conf":
        mode: "000644"
        owner: root
        group: root
        content: |
            content of your config file that you want to copy
Nikolai Kiselev
  • 6,201
  • 2
  • 27
  • 37