Search code examples
azure-devopsazure-cliazure-bicep

az cli/bicep targeted/single module deploys?


Is there an az/bicep equivalent to terraform apply -target=module.my_app.module.something?

Given a root bicep file:

module app '../../../projects/my/application/app.bicep' = {
  name: 'app'
}

module test '../../../projects/my/application/test.bicep' = {
  name: 'test'
}

module sample '../../../projects/my/application/sample.bicep' = {
  name: 'sample'
  params {
    p1: 'p1'
  }
}

Can I provision just the sample module somehow?

I could do something like: az deployment sub create --template-file ../../../projects/my/application/sample.bicep -l germanywestcentral

But this is not really the same thing, because this bypasses the params passed from the root module (which provides env separations) down to the actual module.


Solution

  • The command you have: az deployment sub create --template-file ../../../projects/my/application/sample.bicep -l germanywestcentral will work just fine, you just pass the parameters you would normally pass to root.bicep that are needed by that module (e.g. p1)

    If you have params that are created/manipulated in root.bicep you'd have to decide how you marshal those values manually.