Using AWS ebextensions, what is the proper way to pass an array of commands per their docs?
Asked Answered
P

1

8

Docs

I'm trying to pass multiple commands in a conainter_commands entry and keep getting errors. Yet when I pass the same commands as individual entries it works fine.

Works:

container_commands:
  01_remove_old_dump:
    command: 'rm -f /tmp/db.dump'
  02_get_new_dump:
    command: 'aws s3 cp s3://bucket/db.dump'

Fails with /bin/sh: rm -f /tmp/db.dump: No such file or directory.

container_commands:
  01_remove_old_dump:
    command: ('rm -f /tmp/db.dump' 'aws s3 cp s3://bucket/db.dump')
Puck answered 4/6, 2016 at 0:38 Comment(0)
P
11

Never mind, I just broke the lines up with a YAML block and that works:

01_command:
    command: |
      if [[ ! $ENVIRONMENT = "PROD" ]] && [[ $RDS_HOSTNAME ]]
          rm -f /tmp/db.dump
          aws s3 cp s3://bucket/db.dump
          pg_restore -H $RDS_HOSTNAME dbname /tmp/db.dump
          echo "Refreshing database..."
      else
          Echo "Environment is ${ENVIRONMENT}. Skipping database refresh..."
      fi

NOTE: Removed this, it doesn't seem to work (always returns true):

    test: |
      [[ ! $ENVIRONMENT = "PRODUCTION" ]] && \
      [[ $RDS_HOSTNAME ]] && \
      echo "Refreshing database..."
Puck answered 4/6, 2016 at 2:58 Comment(2)
Thank you! I was banging my ahead against the wall on this forever. Their docs are wrong.Pastrami
Note, the test syntax here doesn't seem to work. I thought it was working, but found out that it was returning true every time. I ended up wrapping my command in an if statement that conducts the same test.Puck

© 2022 - 2024 — McMap. All rights reserved.