Search code examples
amazon-web-servicesamazon-elastic-beanstalkebextensions

Can I put a eb extension container command on multiple lines and if I can how?


All I've found about this is: https://forums.aws.amazon.com/thread.jspa?threadID=112988

I know that I can do this:

container_commands:
   07_run_command:
      "mkdir -p /var/cache/tomcat8/temp/.m2/repository && chmod 777"

But can I do this?

container_commands:
   07_run_command:
      mkdir -p /var/cache/tomcat8/temp/.m2/repository && 
      chmod 777

And do I still need the && to separate the commands or are they executed as separate commands? or is it still only one command?


Solution

  • This can be done via YAML's literal block scalar, as follows:

    container_commands:
      07_run_command: |
          mkdir -p /var/cache/tomcat8/temp/.m2/repository
          chmod 777
    

    More documentation on the same can be found here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#linux-commands-options