Hi, I have a bunch of .tf files committed to gitlab.com. I set variables in the ci/cd setting and pass them on to my .gitlab-ci.yml as per normal.
In my .gitlab-ci.yml I have the following:
image:
name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
- 'AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}'
- 'AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}'
- 'AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}'
- 'AWS_CLUSTER_NAME=${AWS_CLUSTER_NAME}'
I also have a variables.tf file with the following:
variable “cluster-name” {
default = “name_from_gitlab ci”
type = string
description = “The name of your EKS Cluster”
}
How do I get the variable from the gitlab-ci to terraform “name_from_gitlab ci” variables file?
I have tried to use TF_VAR_AWS_CLUSTER_NAME in the variables.tf file but it seems you can’t pull a variable from a variable in this file.
Terraform v0.12.21
- provider.aws v2.49.0
- provider.http v1.1.1
- provider.null v2.1.2
- provider.random v2.2.1
Regards
Darrell