3

Functioning Code Using Terraform

I am more familiar with Terraform, where I can do something like:

module "storagemod" {
  source = "git::https://MyProj@dev.azure.com/MyProj/Dataplatform/_git/myrepo//storage-account?ref=v0.2.0"
  rg_name = "MyRG"
  resource_name = "mynewdatalake"
  .
  .
  .
}

where the source referenced above is a different repository of Terraform modules that I am referencing to create resources.

The repository is a private Azure repository (on Azure DevOps) that I am able to access because I have already established git credentials in a previous step of the pipeline:

steps:
  - task: PowerShell@2
    inputs:
      targetType: inline
      script: 'git config --global http.extraheader "AUTHORIZATION: bearer ${Env:SYSTEM_ACCESSTOKEN}"'
    displayName: 'Setting Git Authentication header'
    env:
      SYSTEM_ACCESSTOKEN: $(System.AccessToken)

How to Do This in Bicep?

How could I do something similar using Azure Bicep? We are trying to move over to Bicep.

I can do the same authentication of the Git headers, of course, but how can I handle the module?

Local

If it were local on the same repo, I could do:

module storagemod './storage/datalake.bicep' = {
  name: 'createDataLakeAndContainers'
  params: {
    .
    .
    .
  }
}

Separate Repo

Can I do something like this?

module storagemod 'git::https://MyProj@dev.azure.com/MyProj/Dataplatform/_git/myrepo//storage-account?ref=v0.2.0' = {
  name: 'createDataLakeAndContainers'
  params: {
    .
    .
    .
  }
}

I couldn't get that to work, but I was hoping that the capability is there and I just had the syntax wrong. I could not find any documentation on it.

Mike Williamson
  • 4,915
  • 14
  • 67
  • 104

1 Answers1

6

This is not possible in Bicep (yet).

There are two open issues in bicep's github that addresses this issue:

For now only way is to use either git submodules or maintain "remote" bicep files using some custom solutions.

Miq
  • 3,931
  • 2
  • 18
  • 32
  • Thanks for the fast response and detailed references! Too bad its not ready, but at least now I am subscribed to the issues. :) – Mike Williamson May 07 '21 at 18:21
  • 1
    bicep registry is planned for 0.5 release which I think will be released in September. stay tuned! – Miq May 07 '21 at 18:54