Home > Enterprise >  how can i pass a powershell variable to terraform
how can i pass a powershell variable to terraform

Time:08-18

I need to pass a powershell/devops variable to terraform, is there a way of doing this? As in the below example i want the below PR number to be used as a variable in terraform.

testvalue-$(System.PullRequest.PullRequestNumber)

CodePudding user response:

As far as I know, there is no way to define a variable by the output of a command (shell ..), but you can take a look at this data source external data source ,

the idea is that you define a bash script or any program and use it's output as parameters for other resources.

Example

data "external" "PullRequest" {
  program = [
    "${path.module}/scriptWhichReturnsPullRequestName.sh",
  ]
  result {

  }
}

...
resource ...  {
  value = data.external.PullRequest.property
}

CodePudding user response:

OK it appears you can do this!

Its documented here and it works for me

https://gaunacode.com/terraform-input-variables-using-azure-devops

  • Related