Pass variables from workflow to jobs to commands

Is there a way of passing values from workflow to jobs which are used as arguments in commands?

version: 2.1

commands:
  provision-k8s:
    parameters:
      customer:
        type: string
        default: mycompany
      environment:
        type: string
        default: prod
    steps:  
      - run:
          name: Provision VPC and EKS cluster
          command: |
		    export AWS_EKS_CLUSTER_NAME="<< parameters.customer >>-<< parameters.environment >>-eks"
            eksctl create cluster --name ${AWS_EKS_CLUSTER_NAME} --version 1.16 --region $AWS_DEFAULT_REGION --fargate --tags customer=${CIRCLE_BRANCH}

jobs:
  prep_k8s:
    docker:
      - image: circleci/node:14.4
    steps:
      - provision-k8s:
          parameters:
		    customer:
			  type: string
			  default: mycompany
		    environment:
			  type: string
			  default: prod

workflows:
  version: 2
  deploy_k8s_workflow:
    jobs:
      - prep_k8s:
          customer: 'BaringsBank'
          environment: 'dev'
          filters:
            branches:
              only: master

Hi @everytown! Yes, you can pass parameters down from the job level to the step! You just need to make some changes to your config as written. The parameters you have defined in prep_k8s that are set under the provision-k8s job should actually be at the same level as the steps key. So you should define your parameters under the job, just as you did under the step.

Here is an example of how to do this with an adoption of the config that you shared:

version: 2.1

commands:
  provision-k8s:
    parameters:
      customer:
        type: string
        default: mycompany
    steps:
      - run:
          name: Provision VPC and EKS cluster
          command: echo << parameters.customer >>

jobs:
  prep_k8s:
    docker:
      - image: circleci/node:14.4
    parameters: # parameters are at the job level
      customer:
        type: string
        default: mycompany
    steps:
      - provision-k8s:
          customer: << parameters.customer >> # you can pass down the parameter value to the step

workflows:
  version: 2
  deploy_k8s_workflow:
    jobs:
      - prep_k8s:
          customer: 'BaringsBank' 

I hope that helps! Please let me know if you have any questions!

Thanks Anna. That’s exactly what I was after.