Gitlab CI variable for S3 prefix in extends job not being passed in

I use extends to define a prefix for a aws cli s3 cp command in the parent job. But it does not seem to be passed to the main job that is being extended?

What I see is my S3 cp command is copying to the bucket level i.e. the prefix is ‘’. The BUCKET_NAME is defned globally under variables:

Running on GitLab.com

deploy_s3:
  image: "python:3.7"  # We use python for the AWS SDK
  stage: deploy
  dependencies:
    - test     # We specify dependencies explicitly
  before_script:
    - pip install awscli # Install the SDK
  script:
    - aws configure set aws_access_key_id ${DEPLOYACCESS}
    - aws configure set aws_secret_access_key ${DEPLOYSECRET}
    - aws s3 rm s3://${BUCKET_NAME}${PREFIX}/ --recursive # Remove previous version
    - aws s3 cp ./ s3://${BUCKET_NAME}${PREFIX}/ --recursive --exclude "*" --include '*.py'

  environment:
    name: ${CI_COMMIT_REF_SLUG}
    url: http://${BUCKET_NAME}.s3-website.${AWS_DEFAULT_REGION}.amazonaws.com${PREFIX}/

deploy_staging_s3:
  extends: deploy_s3
  variables:
    PREFIX: /staging
  only:
    - staging

Ideas?

Nobody?