Using variables in the environment names for manual steps

Overriding variables used in environment name does not work as expected

I’d like to implement the following procedure: I have regular pipeline that runs test cases, creates docker image, pushes it into registry, then updates ECS service in the environment bounded to the given branch. At this works as a charm. But at the end of the pipeline I’d like to put one more manual deployment task, that allows user to push the image to any non-prod region, taking the environment name in a variable. Specifically I put something like:

manual_deploy:
    when: manual
    environment:
        name: $DEPLOYMENT_ENV_NAME
#other actions and configs to make it work

Now I can either leave the variable uninitialized or define the variable on the job/pipeline level.

if the former, then the job initially goes into failed status with the message:
This job could not be executed because it would create an environment with an invalid parameter.

Obviously I can re-run it with the name I need. then it turns green after the successful deployment.

If the latter and I specify on the pipeline level:

variables:
  DEPLOYMENT_ENV_NAME: UAT

Then even I’m trying to override the variable value during the manual trigger, environment does not change, like the configuration of the environment happened at the earliest possible stage and is never changed.

Anyone knows how can I prevent the job from failing (so my pipelines does not turn amber/red) and let me override environment name on the startup?