# Terraform apply and get value in prompt

**URL:** <https://discuss.hashicorp.com/t/terraform-apply-and-get-value-in-prompt/34223>\
**Category:** Terraform\
**Created:** [January 13, 2022, 1:40pm UTC](https://discuss.hashicorp.com/t/terraform-apply-and-get-value-in-prompt/34223 "2022-01-13T13:40:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohsen](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/mohsen/32/25179_2.png) [@mohsen](https://discuss.hashicorp.com/u/mohsen)\
**Post date:** [January 13, 2022, 1:40pm UTC](https://discuss.hashicorp.com/t/terraform-apply-and-get-value-in-prompt/34223/1 "2022-01-13T13:40:42Z")

</div>

I have variable.tf and ,main.tf , when I use `terrform apply` , terraform wants to get data in command line:

```auto
$ terraform apply
var.ENVIRONMENT_CONTEXT __VARIABLES__ IPV4_NETMASK
  The IPv4 subnet mask, in bits (example: 24 for 255.255.255.0).

  Enter a value:

```

How to tell terraform to discard get value?

---

<div class="post-metadata">

**Author:** ![stuart-c](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/stuart-c/32/10789_2.png) [@stuart-c](https://discuss.hashicorp.com/u/stuart-c)\
**Post date:** [January 13, 2022, 2:25pm UTC](https://discuss.hashicorp.com/t/terraform-apply-and-get-value-in-prompt/34223/2 "2022-01-13T14:25:26Z")

</div>

If there is a variable defined without a default and the value isn’t obtainable from elsewhere (i.e. being set on the command line, via an environment variable or from a tfvars file) it will prompt you to enter it.

If you don’t want it to prompt you will need to either make it optional (by setting a default, which might not be possible depending what it is representing) or specifying it using another method (tfvar file/env var/command line).

---

<div class="post-metadata">

**Author:** ![apparentlymart](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/apparentlymart/32/702_2.png) [@apparentlymart](https://discuss.hashicorp.com/u/apparentlymart)\
**Post date:** [January 13, 2022, 8:20pm UTC](https://discuss.hashicorp.com/t/terraform-apply-and-get-value-in-prompt/34223/3 "2022-01-13T20:20:57Z")

</div>

In addition to @stuart-c’s answer, which covers the main points, I want to note that you can also choose to run Terraform in non-interactive mode using either the `-input=false` command line option or the `TF_INPUT=0` environment variable.

In that case, instead of showing a prompt Terraform will show an error message to tell you that this required variable must be assigned a value. You can then assign it a value in one of the ways discussed in the previous reply in order to get past that error.
