hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
41.66k stars 9.41k forks source link

Terraform 0.12.3 Crashes when using the file() command inside of your deploy.tf.json #21991

Closed cpoma closed 4 years ago

cpoma commented 5 years ago

Terraform Version

Terraform v0.12.3

Terraform Configuration Files

...

                "provisioner": {
                  "file": {
                    "source"      : "./files/prepNode.sh",
                    "destination" : "/tmp/prepNode.sh",
                    "connection": {
                      "type": "ssh",
                      "timeout": "30s",
                      "user": "${var.ami_default_user}",
                      "private_key": "${file("/Users/cpoma/Documents/CloudRelated/DeveloperDesktop/CraigPoma.pem")}",
                      "agent": "false",
                      "host" : "${aws_instance.base.public_ip}"
                    }
                  } 
                },

Debug Output

Crash Output

panic: runtime error: index out of range

goroutine 1 [running]: github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.(peeker).Read(...) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/peeker.go:20 github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseObject.func1(0x0, 0xc0003b702b, 0x1, 0x461, 0xc00003e4a0, 0xe, 0x2a, 0x2b, 0x5ab, 0x2a, ...) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:127 +0xb0 github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseObject(0xc00000cf80, 0xc000442de0, 0xc0000b5f90, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:233 +0xcb2 github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseValue(0xc00000cf80, 0xc000442d80, 0x0, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:45 +0x70b github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseObject(0xc00000cf80, 0xc0004426c0, 0xc0000b5db0, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:188 +0x43c github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseValue(0xc00000cf80, 0xc000442660, 0x0, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:45 +0x70b github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseObject(0xc00000cf80, 0xc0004424e0, 0xc0000b5d60, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:188 +0x43c github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseValue(0xc00000cf80, 0xc000442480, 0x0, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:45 +0x70b github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseObject(0xc00000cf80, 0xc0005bf980, 0xc0000b4dc0, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:188 +0x43c github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseValue(0xc00000cf80, 0xc0005bf920, 0x0, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:45 +0x70b github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseObject(0xc00000cf80, 0xc0005bf7a0, 0xc0000b4d70, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:188 +0x43c github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseValue(0xc00000cf80, 0xc0005bf740, 0x0, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:45 +0x70b github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseObject(0xc00000cf80, 0xc0005bf5c0, 0xc0000b4d20, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:188 +0x43c github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseValue(0xc00000cf80, 0xc0005bf560, 0x0, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:45 +0x70b github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseObject(0xc00000cf80, 0xc0005be4e0, 0xc00003e4a0, 0xe, 0x2a, 0x17) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:188 +0x43c github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseValue(0xc00000cf80, 0xc00000cf80, 0x461, 0xc00003e4a0, 0xe, 0x2a) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:45 +0x70b github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.parseFileContent(0xc0003b6a80, 0x80c, 0xa0c, 0xc00003e4a0, 0xe, 0x0, 0x0, 0xc0000842a0, 0x4715d88, 0x7) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/parser.go:21 +0x155 github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json.Parse(0xc0003b6a80, 0x80c, 0xa0c, 0xc00003e4a0, 0xe, 0xc0003b6a80, 0x80c, 0xa0c, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hcl/json/public.go:21 +0x77 github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hclparse.(Parser).ParseJSON(0xc0001b2038, 0xc0003b6a80, 0x80c, 0xa0c, 0xc00003e4a0, 0xe, 0xa0c, 0x0, 0x0, 0xc000531378) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl2/hclparse/parser.go:79 +0xae github.com/hashicorp/terraform/configs.(Parser).LoadHCLFile(0xc000308020, 0xc00003e4a0, 0xe, 0xc00003e550, 0xc000531508, 0xb, 0xb, 0xc00003e550) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/configs/parser.go:66 +0xfa github.com/hashicorp/terraform/configs.(Parser).loadConfigFile(0xc000308020, 0xc00003e4a0, 0xe, 0x0, 0x3, 0x0, 0x0, 0xc) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/configs/parser_config.go:34 +0x5d github.com/hashicorp/terraform/configs.(Parser).LoadConfigFile(...) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/configs/parser_config.go:22 github.com/hashicorp/terraform/configs.(Parser).loadFiles(0xc000308020, 0xc000049c00, 0x4, 0x4, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, ...) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/configs/parser_config_dir.go:76 +0x343 github.com/hashicorp/terraform/configs.(Parser).LoadConfigDir(0xc000308020, 0x298ba6d, 0x1, 0x12, 0xc0005318a8, 0x2434482, 0xc000531870) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/configs/parser_config_dir.go:36 +0x121 github.com/hashicorp/terraform/configs/configload.(Loader).LoadConfig(0xc00041c050, 0x298ba6d, 0x1, 0x0, 0x1, 0x27c5000, 0xc00047c090) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/configs/configload/loader_load.go:22 +0x5d github.com/hashicorp/terraform/command.(Meta).loadConfig(0xc000534a80, 0x298ba6d, 0x1, 0x10c72ef, 0xc0004c4020, 0x16, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/command/meta_config.go:66 +0x132 github.com/hashicorp/terraform/command.(ValidateCommand).validate(0xc000534a80, 0xc000394040, 0x34, 0x0, 0x0, 0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/command/validate.go:79 +0x5f github.com/hashicorp/terraform/command.(ValidateCommand).Run(0xc000534a80, 0xc00000c090, 0x0, 0x0, 0xc00011c8c0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/command/validate.go:70 +0x6c2 github.com/hashicorp/terraform/vendor/github.com/mitchellh/cli.(CLI).Run(0xc0003023c0, 0xc0003023c0, 0xc000531d90, 0x1) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/vendor/github.com/mitchellh/cli/cli.go:255 +0x1f1 main.wrappedMain(0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/main.go:223 +0xaff main.realMain(0x0) /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/main.go:100 +0xb4 main.main() /private/tmp/terraform-20190625-7012-173qxtw/terraform-0.12.3/src/github.com/hashicorp/terraform/main.go:36 +0x3b

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform. A crash log has been placed at "crash.log" relative to your current working directory. It would be immensely helpful if you could please report the crash with Terraform1 so that we can fix this.

When reporting bugs, please include your terraform version. That information is available on the first line of crash.log. You can also get it by running 'terraform --version' on the command line.

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Expected Behavior

Actual Behavior

Steps to Reproduce

Additional Context

References

cpoma commented 4 years ago

Turns out the crash is related to malformed JSON - needed to escape the " in the file call: "${file(\"/U.......

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.