Azure account not showing on Terraform steps when VCS is enabled

Hi, we are having issues with Terraform steps not seeing azure account variables in the project when VCS is enabled.

We are running on Octopus Cloud (v2022.4 currently), and this project has VSC enabled pointing to a git repo in Azure DevOps. The VSC is authenticated with a library credential and seems to be working as expected.
Then adding a new terraform step to this project, the azure account section does not display the azure account variable that is added to the project.

When I replicate this on a different project that does not have VCS enabled, it works fine.

Reproduction steps:

  • Create a new VCS project.
  • Add a new project variable of type Azure Account. Populate this with a scoped value pointing to an azure account.
  • Define the project process, add a single step based on the template “Plan to apply a Terraform template”.
  • Under the Managed accounts section, select Azure account. Drop down the account list, and note that no accounts are visible.

I should add that I can reproduce this on demand in new projects. The terraform step used does not make a difference, all terraform step templates fail to list the Azure accounts when VCS is enabled.

Hi Dan,

Thanks for getting in touch! I’m sorry to see you’re hitting this issue, and I appreciate your clear repro steps you’ve outlined. I have been able to reproduce this issue with Terraform steps in a version controlled project, however other steps containing an identical account dropdown (e.g. Deploy an Azure Resource Manager Template) populates the accounts correctly in the same project. I’m working on writing up a bug report, but I’m hoping a workaround will be as straight forward as manually adding the account variable into the field using the variable binding syntax (e.g. #{AccountVar}). Does that get your Terraform steps working as needed?

Let me know how you go, and I’ll get in touch with a link to the bug report soon. :slight_smile:

Best regards,

Kenny

Hi Dan,

I just wanted to quickly follow up with a link to the bug report I just submitted. :slight_smile:

Best regards,

Kenny

1 Like

Awesome, just testing this workaround. Will let you know how we get on.

Ok, I have tested using the variable reference as a work around and can confirm that it does not work.
I have 2 projects with the exact same process and variables for testing, one is VCS integrated, one is not.

On the non-VCS version, I use the account variable via the dropdown “azure.account” (which is a project variable pointing to the account). This plan step all runs as expected.

On the VCS project, I use the azure account binding, and populate the variable reference “#{azure.account}”. When running a deployment with this configuration I get the error:

Error: building AzureRM Client: obtain subscription() from Azure CLI: parsing json result from the Azure CLI: waiting for the Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account. 
October 18th 2022 13:16:23Error

Which seems to be complaining that az login has not be run.

I saw this same behaviour in my real project when I attempted to use the variable reference in the terraform step.

The account binding in the VCS project:

Hi Dan,

Thank you for following up! Darn, that’s unfortunate that workaround didn’t work. The only option may end up being to create/update the step via the API as I imagine it’s a front-end bug. I’ll give that a crack shortly and let you know how I go.

I appreciate your report, though my apologies for the inconvenience this has caused you.

Best regards,

Kenny

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.