Replace this template with your information
I am using the Gitlab runner for terraform in this container registry:
I am experimenting using this image to deploy to Azure:
registry.gitlab.com/gitlab-org/terraform-images/stable:latest
When I am deploying using my gitlab runner to Azure I am getting this error:
│ Error: building AzureRM Client: Please ensure you have installed Azure CLI version 2.0.79 or newer. Error parsing json result from the Azure CLI: Error launching Azure CLI: exec: "az": executable file not found in $PATH.
[50](https://gitlab.com/prometheus-build-repository/sourcecontrollayout/prometheus_inventory/terraform-afd/-/jobs/1714837184#L50)│
[51](https://gitlab.com/prometheus-build-repository/sourcecontrollayout/prometheus_inventory/terraform-afd/-/jobs/1714837184#L51)│ with provider["registry.terraform.io/hashicorp/azurerm"],
[52](https://gitlab.com/prometheus-build-repository/sourcecontrollayout/prometheus_inventory/terraform-afd/-/jobs/1714837184#L52)│ on main.tf line 15, in provider "azurerm":
[53](https://gitlab.com/prometheus-build-repository/sourcecontrollayout/prometheus_inventory/terraform-afd/-/jobs/1714837184#L53)│ 15: provider "azurerm" {
My gitlab-runner gitlab-cicd.yml file for terraform looks like this:
image:
name: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
variables:
TF_ROOT: ${CI_PROJECT_DIR}/
TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/afdexample
cache:
key: example
paths:
- ${TF_ROOT}/.terraform
before_script:
- cd ${TF_ROOT}
stages:
- TERRAFORM_prepare
- TERRAFORM_validate
- TERRAFORM_build
- TERRAFORM_deploy
- TERRAFORM_destroy
TERRAFORM_init:
stage: TERRAFORM_prepare
script:
- gitlab-terraform init
TERRAFORM_validate:
stage: TERRAFORM_validate
script:
- gitlab-terraform validate
TERRAFORM_plan:
stage: TERRAFORM_build
script:
- export TF_VAR_subscriptionid=$azuresubscriptionid
- export TF_VAR_tenantid=$azuresubscriptiontenantid
- export TF_VAR_serviceprincipalappid=$azureserviceprincipalappid
- export TF_VAR_serviceprincipalsecret=$azureserviceprincipalpassword
- gitlab-terraform plan
- gitlab-terraform plan-json
artifacts:
name: plan
paths:
- ${TF_ROOT}/plan.cache
reports:
terraform: ${TF_ROOT}/plan.json
TERRAFORM_apply:
stage: TERRAFORM_deploy
tags:
- configuration
environment:
name: production
script:
- gitlab-terraform apply
dependencies:
- TERRAFORM_plan
when: manual
only:
- main
TERRAFORM_destroy:
stage: TERRAFORM_destroy
environment:
name: production
script:
- export TF_VAR_subscription_id=$subscription_id
- export TF_VAR_vtenant_id=$tenant_id
- export TF_VAR_service_principal_appid=$service_principal_appid
- export TF_VAR_service_principal_secret=$service_principal_secret
- gitlab-terraform destroy
dependencies:
- TERRAFORM_plan
when: manual
only:
- main
Is there an image that has the Azure Cli in it? Or do we have to make our own?
Many thanks… WY