Warm tip: This article is reproduced from serverfault.com, please click

Terraform: cat command issues

发布于 2020-11-28 08:01:35

I have Terraform 0.13.5 installed on RHEL 8.3 AWS EC2 instance. I have a single file in my directory "main.tf" whose contents are as follows:

variable "myvar" {
        type = string
        default = "Hello Terraform!"
}

variable "mymap" {
        type = map(string)
        default = {
                mykey = "my value"
                }
}

variable "mylist" {
        type = list
        default = [1,2,3]
}

I have validated the syntax using "terrafom validate" command:

ec2-user@ip-172-31-XX-XX check]$ terraform validate
Success! The configuration is valid.

However, I cannot successfully run the "cat" command within the "Terraform Console":

[ec2-user@ip-172-31-XX-XX check]$ terraform console
> cat main.tf

>
Error: Extra characters after expression

  on <console-input> line 1:
  (source code not available)

An expression was successfully parsed, but extra characters were found after
it.

>

> exit

Please let me know what I'm missing here.

Questioner
Vishwas M.R
Viewed
11
Marcin 2020-11-28 16:18:08

If you want to display the content of the file you just write:

file("main.tf")

To get individual variables, e.g.:

var.myvar

Sadly, I'm not sure what do you want to achieve with a cat command. There is no such command in terraform console.