Hello
Here is my provider config:
variable "provider_development_json" {
type = string
description = "Input variable from environment for development provider configuration"
}
provider "google" {
credentials = var.provider_development_json
project = "XXXXXXXXXXXXXXXXX"
region = "us-central1"
alias = "myalias"
}
When im exporting such variable locally:
export TF_VAR_provider_development_json=/home/user/Downloads/myenv.json
It is working when im staring it on my local machine.
Problem is when i will start it with below CI/CD configuration and “File” variable for project set up with name: TF_VAR_provider_development_json
im getting such error:
Error: Error creating Service: googleapi: Error 403: Permission 'run.services.create' denied on resource 'namespaces/XXXXXXXXX/services/application' (or resource may not exist).
default:
image:
name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
cache:
key: "$CI_BUILD_REF_NAME"
untracked: true
paths:
- .terraform
variables:
GIT_CLEAN_FLAGS: -x -f -e terraform.out
stages:
- prep
- check
- changes
- execute
init:
stage: prep
script:
- echo $TF_VAR_provider_development_json
- terraform init
validate:
stage: check
script:
- terraform validate
plan:
stage: changes
script:
- terraform plan -out=terraform.out
apply:
stage: execute
script:
- echo $TF_VAR_provider_development_json
- cat $TF_VAR_provider_development_json
- terraform apply terraform.out
when: manual
in last step first and second line is checking this variable and it looks its showing proper path to file with proper content. why in gitlab CI/CD its doesnt work like on local machine?