Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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')
like image 704
Ryan Fisher Avatar asked Jun 04 '16 00:06

Ryan Fisher


People also ask

What is Ebextensions?

ebextensions). Configuration files are YAML formatted documents with a . config file extension that you place in a folder named . ebextensions and deploy in your application source bundle. EB configuration files are so powerful that you don't have to connect to your instance through SSH to issue configuration commands.

How do I check my Ebextensions?

You can tail some logs in the web UI to see whether your . ebextensions worked (via Elastic Beanstalk → view an environment → Logs). You should see a success or fail message for each command you define. (For example, for a command named 01_setup you'll see a message like command 01_setup succeeded .)

Where should an Elastic Beanstalk configuration files?

ebextensions, see the Elastic Beanstalk Configuration Files Repository . Location – Place all of your configuration files in a single folder, named . ebextensions , in the root of your source bundle.


1 Answers

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..."
like image 152
Ryan Fisher Avatar answered Sep 23 '22 18:09

Ryan Fisher