Outputs not working inside docker container on gitlab pipeline

Hi everyone, I’m using terraspace on gitlab for building environments dynamically. Basically I have 3 stacks, vpc, bastion, k3s-cloud that builds the whole infrastructure. When I run it locally on my machine. (Linux machine) runs fine. When I try to do the same on the pipeline. I got for example this errors on bastion, even vpc runs fine and generates outputs:

# Logfile created on 2021-01-21 13:50:06 +0000 by logger.rb/v1.4.2
[2021-01-21T13:50:06 #407 terraspace up bastion]: Current directory: .terraspace-cache/us-east-1/ci-test/stacks/bastion
[2021-01-21T13:50:06 #407 terraspace up bastion]: => terraform init -get -input=false >> /tmp/terraspace/log/init/bastion.log
[2021-01-21T13:50:16 #407 terraspace up bastion]: => terraform plan -input=false -out /tmp/terraspace/plans/bastion-20210121135006.plan
[2021-01-21T13:50:21 #407 terraspace up bastion]: 
[2021-01-21T13:50:21 #407 terraspace up bastion]: Error: No value for required variable
[2021-01-21T13:50:21 #407 terraspace up bastion]: 
[2021-01-21T13:50:21 #407 terraspace up bastion]:   on variables.tf line 2:
[2021-01-21T13:50:21 #407 terraspace up bastion]:    2: variable "vpc_id" {
[2021-01-21T13:50:21 #407 terraspace up bastion]: 
[2021-01-21T13:50:21 #407 terraspace up bastion]: The root module input variable "vpc_id" is not set, and has no default value.
[2021-01-21T13:50:21 #407 terraspace up bastion]: Use a -var or -var-file command line argument to provide a value for this
[2021-01-21T13:50:21 #407 terraspace up bastion]: variable.

on my base.tfvars I have this:

vpc_id = <%= output('vpc.vpc_id') %>
vpc_public_subnets = <%= output('vpc.public_subnets') %>
vpc_private_subnets = <%= output('vpc.private_subnets') %>
vpc_cidr = <%= output('vpc.vpc_cidr_block') %>
default_security_group_id = <%= output('vpc.default_security_group_id') %>

I’m not sure where else to look to solve this.

Wondering what’s in the generated *.auto.tfvars files in .terraspace-cache/us-east-1/ci-test/stacks/bastion/

Thinking add a debugging line in the CI script that ls and cat those files for more info. Maybe something like this:

ls .terraspace-cache/us-east-1/ci-test/stacks/bastion/*.auto.tfvars
for in $(ls .terraspace-cache/us-east-1/ci-test/stacks/bastion/*.auto.tfvars) ; do
  echo $i
  cat $i
done

Note, didn’t test it. That’s an idea to start though.

Thank you very much, basically the .gitignore I was using, had *.tfvars so the pipelines never had them.

1 Like