Build step based on input condition

I’m trying to only run a certain step if the user selects an input option. e.g I want to run the terraform apply step if the user selects Apply. So far I have this:

  - block: "Options"
    key: "Options"
      - select: "Action"
        key: "action"
          - label: "APPLY"
            value: "apply"
          - label: "DESTROY"
            value: "destroy"
  - label: Terraform Apply
    key: "apply"
    command: <commands>
    if: (key:action == apply)

What’s the correct formatting for the if line to make this work?

Hey @Gpark!

Thanks for the message and welcome to the community!

The TL;DR is that you’d need to use the buildkite-agent meta-data command in order to get the value of the action, then determine the next steps accordingly.

You could use a command following the above in order to upload another pipeline file, or pipe in a step in a dynamic fashion.

For a little more context on the above as well as previous discussion on this issue and the potential solutions I’d recommend reading through this post: Meta-data in conditional clause - #6 by sj26