Closed aprilmintacpineda closed 1 week ago
I opted out of using this orb and instead used this:
terraformation:
machine:
image: ubuntu-2004:202010-01
steps:
- attach_workspace:
at: ~/project
- run:
name: Install terraform
command: |
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update
sudo apt-get install terraform
terraform --version
- run:
name: TFVars
command: |
rm -rf variables.tfvars
touch variables.tfvars
// ... setup tf vars
- run:
name: Terraform deployment
command: |
terraform init
terraform apply
This works.
The first error most likely comes from using an image with dash as sh not bash. When looking at the orb's code one can see the <<<
redirection that won't work on dash.
The first error most likely comes from using an image with dash as sh not bash. When looking at the orb's code one can see the
<<<
redirection that won't work on dash.
If the Orb requires bash, it should probably ask for bash. The default shell is bash unless bash isn't installed, then it's sh. If bash is required, the script should at least check for it and report a meaningful error if it isn't available.
But, it's not like the script does anything terribly complex so it could probably also just be written as valid sh.
The first problem as was already mentioned, is related to bash not being part of the executor, using an executor with bash installed should solve the problem.
The second problem is also related to the executor, you removed the terraform/install step, so you are using the terraform on the image, and you were using the default executor without parameters so it uses terraform 1.0.0. The message you showed was about the error message you used on the validation of the variable, which was not valid on terraform 1.0.0, you probably were using a newer version locally and that's why it worked
I'm closing this as I consider these two problems solved with this explanation, but we will update the orb to make it more consistent.
Orb Version circleci/terraform@3.2.1
I have the following code in my circle ci file
I'm getting 2 errors here,
Here's the first one:
The 2nd one is when I remove the
terraform/install
step, I will get the followingI have tested these variables locally and when I run
terraform validate
, I don't get any errors.The
variables.tf
file:To Reproduce
Expected behavior
Additional context