# Build step based on input condition

**URL:** <https://forum.buildkite.community/t/build-step-based-on-input-condition/3214>\
**Category:** Pipelines\
**Created:** [August 29, 2023, 5:43am UTC](https://forum.buildkite.community/t/build-step-based-on-input-condition/3214 "2023-08-29T05:43:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gpark](https://avatars.discourse-cdn.com/v4/letter/g/58956e/32.png) [@Gpark](https://forum.buildkite.community/u/Gpark)\
**Post date:** [August 29, 2023, 5:43am UTC](https://forum.buildkite.community/t/build-step-based-on-input-condition/3214/1 "2023-08-29T05:43:39Z")

</div>

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:

```auto
steps:
  - block: "Options"
    key: "Options"
    fields:
      - select: "Action"
        key: "action"
        options:
          - 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?

---

<div class="post-metadata">

**Author:** ![benmc](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/benmc/32/1159_2.png) [@benmc](https://forum.buildkite.community/u/benmc)\
**Post date:** [August 29, 2023, 11:24pm UTC](https://forum.buildkite.community/t/build-step-based-on-input-condition/3214/2 "2023-08-29T23:24:43Z")

</div>

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](https://forum.buildkite.community/t/meta-data-in-conditional-clause/1190/6)

Cheers!
