使用 AWS ebextensions,根据他们的文档传递一组命令的正确方法是什么?

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

Docs

我试图在 conainter_commands 条目中传递多个命令,但不断出现错误。然而,当我传递与单个条目相同的命令时,它工作正常。

作品:

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

失败 /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')

没关系,我只是用 YAML 块打破了这些行并且有效:

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

注意: 删除了这个,它似乎不起作用(总是 returns true):

    test: |
      [[ ! $ENVIRONMENT = "PRODUCTION" ]] && \
      [[ $RDS_HOSTNAME ]] && \
      echo "Refreshing database..."