Getting "Error: No value for required variable" (vpc_ip_range) when deploying on DigitalOcean
Description
I followed the documentation steps to deploy on DigitalOcean, and when pushing the first commit to trigger the pipelines (as described in the Provision the infrastructure section), I get the following error in the generated job:
╷ │ Error: No value for required variable │ │ on variables.tf line 106: │ 106: variable "vpc_ip_range" { │ │ The root module input variable "vpc_ip_range" is not set, and has no │ default value. Use a -var or -var-file command line argument to provide a │ value for this variable. ╵
Supporting information
Full raw logs:
Running with gitlab-runner 15.1.0~beta.20.g62206bb2 (62206bb2)
on green-2.shared.runners-manager.gitlab.com/default ns46NMmJ
Preparing the "docker+machine" executor
00:29
Using Docker executor with image registry.gitlab.com/opencraft/dev/grove/tools-container:0.1.25 ...
Authenticating with credentials from job payload (GitLab Registry)
Pulling docker image registry.gitlab.com/opencraft/dev/grove/tools-container:0.1.25 ...
Using docker image sha256:43a4f833205f1dcc713b2c962320e832a2ef69df7d998c1e7a4bbf6c8c67f206 for registry.gitlab.com/opencraft/dev/grove/tools-container:0.1.25 with digest registry.gitlab.com/opencraft/dev/grove/tools-container@sha256:b4c6814e825934fd96e9cdb4e6a18b052b27f25bc3393fc5e1586e138eab4e67 ...
Preparing environment
00:03
Running on runner-ns46nmmj-project-37537227-concurrent-0 via runner-ns46nmmj-shared-1656926873-543bab81...
Getting source from Git repository
00:03
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/african-cities-lab/grove-cluster/.git/
Created fresh repository.
Checking out 12ea5f9b as main...
Updating/initializing submodules recursively with git depth set to 50...
Submodule 'grove' (https://gitlab.com/opencraft/dev/grove.git) registered for path 'grove'
Cloning into '/builds/african-cities-lab/grove-cluster/grove'...
Submodule path 'grove': checked out 'bf43f20a80e288e2857a59e25a572724fb9b7d91'
Entering 'grove'
Entering 'grove'
Restoring cache
00:06
Checking cache for tf-12ea5f9b-protected...
Downloading cache.zip from https://storage.googleapis.com/gitlab-com-runners-cache/project/37537227/tf-12ea5f9b-protected
Successfully extracted cache
Executing "step_script" stage of the job script
00:11
Using docker image sha256:43a4f833205f1dcc713b2c962320e832a2ef69df7d998c1e7a4bbf6c8c67f206 for registry.gitlab.com/opencraft/dev/grove/tools-container:0.1.25 with digest registry.gitlab.com/opencraft/dev/grove/tools-container@sha256:b4c6814e825934fd96e9cdb4e6a18b052b27f25bc3393fc5e1586e138eab4e67 ...
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
african-cities-lab/grove-cluster:african-cities-lab gitlab agent:24138
$ kubectl config use-context ${CI_PROJECT_PATH}:${K8S_CLUSTER_AGENT_CONTEXT}
Switched to context "african-cities-lab/grove-cluster:african-cities-lab".
$ cd ${TF_ROOT}
$ $SCRIPTS_DIR/tf.sh plan
Initializing modules...
Initializing the backend...
Successfully configured the backend "http"! Terraform will automatically
use this backend unless the backend configuration changes.
Initializing provider plugins...
- Finding latest version of hashicorp/helm...
- Finding loafoe/htpasswd versions matching "1.0.1"...
- Finding latest version of hashicorp/external...
- Finding gitlabhq/gitlab versions matching "3.13.0"...
- Finding latest version of hashicorp/random...
- Finding latest version of hashicorp/null...
- Finding digitalocean/digitalocean versions matching ">= 2.19.0, 2.21.0"...
- Finding gavinbunney/kubectl versions matching "1.14.0"...
- Finding latest version of hashicorp/kubernetes...
- Finding latest version of hashicorp/tls...
- Installing gitlabhq/gitlab v3.13.0...
- Installed gitlabhq/gitlab v3.13.0 (signed by a HashiCorp partner, key ID BC097C3333027B14)
- Installing gavinbunney/kubectl v1.14.0...
- Installed gavinbunney/kubectl v1.14.0 (self-signed, key ID AD64217B5ADD572F)
- Installing digitalocean/digitalocean v2.21.0...
- Installed digitalocean/digitalocean v2.21.0 (signed by a HashiCorp partner, key ID F82037E524B9C0E8)
- Installing hashicorp/kubernetes v2.12.0...
- Installed hashicorp/kubernetes v2.12.0 (signed by HashiCorp)
- Installing hashicorp/tls v3.4.0...
- Installed hashicorp/tls v3.4.0 (signed by HashiCorp)
- Installing hashicorp/helm v2.6.0...
- Installed hashicorp/helm v2.6.0 (signed by HashiCorp)
- Installing loafoe/htpasswd v1.0.1...
- Installed loafoe/htpasswd v1.0.1 (self-signed, key ID C0E4EB79E9E6A23D)
- Installing hashicorp/external v2.2.2...
- Installed hashicorp/external v2.2.2 (signed by HashiCorp)
- Installing hashicorp/random v3.3.2...
- Installed hashicorp/random v3.3.2 (signed by HashiCorp)
- Installing hashicorp/null v3.1.1...
- Installed hashicorp/null v3.1.1 (signed by HashiCorp)
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
╷
│ Error: No value for required variable
│
│ on variables.tf line 106:
│ 106: variable "vpc_ip_range" {
│
│ The root module input variable "vpc_ip_range" is not set, and has no
│ default value. Use a -var or -var-file command line argument to provide a
│ value for this variable.
╵
Uploading artifacts for failed job
00:01
Uploading artifacts...
WARNING: /builds/african-cities-lab/grove-cluster/grove/provider-digitalocean/plan.json: no matching files. Ensure that the artifact path is relative to the working directory
ERROR: No files to upload
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
What should I do to address this error? Thanks in advance, Martí
Edited by Martí Bosch