tongueroo / infra-malform-output

example for debugging
0 stars 0 forks source link

Error: Invalid value for input variable #1

Closed JimBeam2019 closed 3 years ago

JimBeam2019 commented 3 years ago

About the issue length1 = <= output("b1.makebelieveoutput") %>, even if I change it from b1.makebelieveoutput to b1.length, it still return Error: Invalid value for input variable when compiling terraspace all plan.

I have no idea what I did it wrong, hope you could give me a hint, please. Cheers

tongueroo commented 3 years ago

Looks like it's missing a %. IE:

length1 = <= output("b1.makebelieveoutput") %>

vs

length1 = <%= output("b1.makebelieveoutput") %>
JimBeam2019 commented 3 years ago

Thank you, but I've just added that %, as now length1 = <%= output("b1.length") %>. It's still the same error.

tongueroo commented 3 years ago

Need a little more debugging info.

JimBeam2019 commented 3 years ago

Need a little more debugging info.

Should I post the whole error message?

JimBeam2019 commented 3 years ago

Here's the log.

terraspace log     
Showing: log/init/a1.log
[2021-04-30T11:30:27 #6563 terraspace init a1]: 
[2021-04-30T11:30:27 #6563 terraspace init a1]: Terraform has been successfully initialized!
[2021-04-30T11:30:27 #6563 terraspace init a1]: 
[2021-04-30T11:30:27 #6563 terraspace init a1]: You may now begin working with Terraform. Try running "terraform plan" to see
[2021-04-30T11:30:27 #6563 terraspace init a1]: any changes that are required for your infrastructure. All Terraform commands
[2021-04-30T11:30:27 #6563 terraspace init a1]: should now work.
[2021-04-30T11:30:27 #6563 terraspace init a1]: 
[2021-04-30T11:30:27 #6563 terraspace init a1]: If you ever set or change modules or backend configuration for Terraform,
[2021-04-30T11:30:27 #6563 terraspace init a1]: rerun this command to reinitialize your working directory. If you forget, other
[2021-04-30T11:30:27 #6563 terraspace init a1]: commands will detect it and remind you to do so if necessary.
Showing: log/init/b1.log
[2021-04-30T11:29:21 #6447 terraspace init b1]: 
[2021-04-30T11:29:21 #6447 terraspace init b1]: Terraform has been successfully initialized!
[2021-04-30T11:29:21 #6447 terraspace init b1]: 
[2021-04-30T11:29:21 #6447 terraspace init b1]: You may now begin working with Terraform. Try running "terraform plan" to see
[2021-04-30T11:29:21 #6447 terraspace init b1]: any changes that are required for your infrastructure. All Terraform commands
[2021-04-30T11:29:21 #6447 terraspace init b1]: should now work.
[2021-04-30T11:29:21 #6447 terraspace init b1]: 
[2021-04-30T11:29:21 #6447 terraspace init b1]: If you ever set or change modules or backend configuration for Terraform,
[2021-04-30T11:29:21 #6447 terraspace init b1]: rerun this command to reinitialize your working directory. If you forget, other
[2021-04-30T11:29:21 #6447 terraspace init b1]: commands will detect it and remind you to do so if necessary.
Showing: log/plan/a1.log
[2021-04-30T11:48:01 #7854 terraspace plan a1]: Releasing state lock. This may take a few moments...
[2021-04-30T11:48:04 #7854 terraspace plan a1]: ╷
[2021-04-30T11:48:04 #7854 terraspace plan a1]: │ Error: Invalid value for input variable
[2021-04-30T11:48:04 #7854 terraspace plan a1]: │ 
[2021-04-30T11:48:04 #7854 terraspace plan a1]: │   on 1-base.auto.tfvars line 1:
[2021-04-30T11:48:04 #7854 terraspace plan a1]: │    1: length1 = "(Output length was not found for the a1 tfvars file. Either b1 stack has not been deployed yet or it does not have this output: length)"
[2021-04-30T11:48:04 #7854 terraspace plan a1]: │ 
[2021-04-30T11:48:04 #7854 terraspace plan a1]: │ The given value is not valid for variable "length1": a number is required.
[2021-04-30T11:48:04 #7854 terraspace plan a1]: ╵
[2021-04-30T11:48:04 #7854 terraspace plan a1]: Error running command: terraform plan -input=false
Showing: log/plan/b1.log
[2021-04-30T11:47:34 #7676 terraspace plan b1]: 
[2021-04-30T11:47:34 #7676 terraspace plan b1]: Changes to Outputs:
[2021-04-30T11:47:34 #7676 terraspace plan b1]:   + length = 2
[2021-04-30T11:47:34 #7676 terraspace plan b1]:   + pet    = (known after apply)
[2021-04-30T11:47:34 #7676 terraspace plan b1]: 
[2021-04-30T11:47:34 #7676 terraspace plan b1]: ─────────────────────────────────────────────────────────────────────────────
[2021-04-30T11:47:34 #7676 terraspace plan b1]: 
[2021-04-30T11:47:34 #7676 terraspace plan b1]: Note: You didn't use the -out option to save this plan, so Terraform can't
[2021-04-30T11:47:34 #7676 terraspace plan b1]: guarantee to take exactly these actions if you run "terraform apply" now.
[2021-04-30T11:47:35 #7676 terraspace plan b1]: Releasing state lock. This may take a few moments...
tongueroo commented 3 years ago

Unsure what's going on. Would double check the app/stacks/a1/tfvars/base.tfvars file. Here's some debugging:

$ git clone https://github.com/tongueroo/infra-malform-output
Cloning into 'infra-malform-output'...
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 53 (delta 14), reused 43 (delta 7), pack-reused 0
Unpacking objects: 100% (53/53), done.
$ cd infra-malform-output/
$ terraspace all up -y
Building one stack to build all stacks
Building .terraspace-cache/us-west-2/dev/stacks/b1
Downloading tfstate files for dependencies defined in tfvars...
Built in .terraspace-cache/us-west-2/dev/stacks/b1
Running:
    terraspace up b1 # batch 1
    terraspace up a1 # batch 2
Batch Run 1:
Running: terraspace up b1 Logs: log/up/b1.log
terraspace up b1:  Changes to Outputs:
terraspace up b1:  Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Batch Run 2:
Running: terraspace up a1 Logs: log/up/a1.log
terraspace up a1:  Error: Invalid value for input variable
Error running: terraspace up a1. Check logs and fix the error.
$ cat app/stacks/a1/tfvars/base.tfvars
length1 = <%= output("b1.makebelieveoutput") %>
$ vim app/stacks/a1/tfvars/base.tfvars
$ cat app/stacks/a1/tfvars/base.tfvars
length1 = <%= output("b1.length") %>
$ terraspace all up -y
Building one stack to build all stacks
Building .terraspace-cache/us-west-2/dev/stacks/b1
Downloading tfstate files for dependencies defined in tfvars...
Built in .terraspace-cache/us-west-2/dev/stacks/b1
Running:
    terraspace up b1 # batch 1
    terraspace up a1 # batch 2
Batch Run 1:
Running: terraspace up b1 Logs: log/up/b1.log
terraspace up b1:  No changes. Infrastructure is up-to-date.
terraspace up b1:  Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Batch Run 2:
Running: terraspace up a1 Logs: log/up/a1.log
terraspace up a1:  Changes to Outputs:
terraspace up a1:  Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
Time took: 5s
$ 
JimBeam2019 commented 3 years ago

Interesting. When I run terraspace all up, it went through with no error at all. When doing the same thing on AWS API Gateway, VPC and Lambda yesterday, I kept getting the same error.