version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: latest
    commands:
      - cd trivia-backend/infra/codedeploy-lifecycle-event-hooks
      - npm install -g npm@latest
      - npm ci
  build:
    commands:
      - aws cloudformation package --template-file template.yaml --s3-bucket $ARTIFACTS_BUCKET --output-template-file packaged-template.yaml
      - cp packaged-template.yaml TriviaGameHooksTest.template.yaml
      - cp packaged-template.yaml TriviaGameHooksProd.template.yaml

artifacts:
  files:
    - trivia-backend/infra/codedeploy-lifecycle-event-hooks/TriviaGameHooksTest.template.yaml
    - trivia-backend/infra/codedeploy-lifecycle-event-hooks/TriviaGameHooksProd.template.yaml
    - trivia-backend/infra/codedeploy-lifecycle-event-hooks/StackConfigTest.json
    - trivia-backend/infra/codedeploy-lifecycle-event-hooks/StackConfigProd.json
  discard-paths: yes