Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bitbucket Pipeline replaces word "bitbucket" within url with variable

hemp0r
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 21, 2022

Hey,

in our pipeline defintions we're trying to use a custom terraform module which is hosted in a private bitbucket cloud repository. 

Our config looks like the following:

"bitbucket-pipelines.yml"

main:

- step: *build

- step:

name: Deploy to Staging

image: hashicorp/terraform:latest

deployment: Staging

script:

- echo "$BITBUCKET_SA" | base64 -d >> /tmp/gcloud.json

- export GOOGLE_APPLICATION_CREDENTIALS=/tmp/gcloud.json

- cd terraform/

- terraform init -backend-config=./backend/file-for-backend..hcl

- terraform apply -auto-approve -var-file='./setup.tfvars' -var-file='./backend/file-for-vars.tfvars'

"terraform - main.tf"

module "cloud_function" {

source = "git::https://bitbucket.org/<company-workspace>/tfm-gcp.git//cloud_function"

for_each = var.functions

project_id = var.project_id

region = var.region

name = each.value.name

entry_point = each.value.entry_point

trigger_event = each.value.trigger_event

trigger_resource = each.value.trigger_resource

environment_variables = each.value.environment_variables

runtime = var.runtime

source_path = "../functions/"

permissions = ["roles/bigquery.dataEditor"]

}
So no magic involed or substitions but while running the pipline we get the following 
+ terraform init -backend-config=./backend/dspl-dev-fs.hcl

Initializing modules...

Downloading git::https://$AZR_IMG_USERNAME.org/dmk-group/tfm-gcp.git for cloud_function...



Error: Failed to download module

$AZR_IMG_USERNAME is the first variable defined in our workspace variables for pipelines but is not used within the repository or project... so it seems like a bug within the pipeline runtime or am I wrong?
It should just download the defined module, specified in main.tf, but theres an substitution with the word "bitbucket" in URL. 

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 23, 2022

Hello @hemp0r ,

Thank you for reaching out to Atlassian Community!

What I think might be happening here is that your workspace variable  $AZR_IMG_USERNAME is configured as a secure variable and the value of this variable is most likely bitbucketSince secure variables are masked from the pipeline build logs, if a value matching a secured variable appears in the logs (in this case bitbucket), Pipelines will replace it with $VARIABLE_NAME. The value your script/terraform will see is the actual value for the variable, but it will not be revealed in the logs.

Even though you are not directly using the variable in this repository, all the workspace variables are made available to the build container, and in the run time if we find any value in the logs matching a secure variable, it will be masked with the variable name.

Hope that helps to clarify your questions! Let me know in case you have any doubt.

Thank you, @hemp0r .

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events