Package: lolite
lolitelolite is an Azure Bicep orchestration tool. The main goal is to separate environment configuration from templates. This is inspired by the AWS Sceptre tool.NOTE: lolite is still very much a WIP.There is a getting started guide on my bloghere. This is meant to be complementry to the info in this Readme.deploy with github actionslolite sample projectlolite Slack, ask questions and get help here.GoalsSeparation of Bicep configuration and templatesDeploy individual configurationsBulk deploy at different hierarchies: Resource Group, Subscription or AccountAutomated Resource Group CreationAutomated deployment hierarchy based on output bindings.Not GoalsSupport for anything other than Bicep on AzureSupport for multiple Azure tenanciesRequirementsPython 3.8+Azure CLIAzure Bicep CLINote:tested on MacOS, Linux (Ubuntu) and WSL under Windows.InstallingYou can install lolite from pypi using:pip install lolite==0.0.1Building From SourceClone this repoBuild the projectpython3 -m buildInstallpip3 install dist/lolite-0.0.1-py3-none-any.whlAssumptionsYou have a single account with multiple subscriptionsEach subscription has a unique nameAll deployments are--mode IncrementalPossible Future FeaturesParallel deploysconfigurable deploy modelolite project structureA lolite project is structured in the following way:- root/
    - bicep/
        - storage_account_and_container.bicep
    - configuration/
        - Subscription_1/
            - Resource_Group_1/
                - location.yaml
                - storage_account_and_container.yaml
                - config_2.yaml
            - Resource_Group_2/
                - location.yaml
                - config_1.yaml
        - Subscription_2/
            - Resource_Group_1/
                - location.yaml
                - config_1.yamlGiven the example structure above a few important things to note:bicep- this folder contains all of your bicep templates.configuration- this contains your configuration for deployments, the hierarchy is important.Subscription_1- This is the root level under configuration.Subscription_1matched exactly the name of a subscription in Azure.Resource_Group_1- At the root level of a given subscription. This sets the resource group for a deployment within that subscription.location.yaml- A special configuration file to set the location of the resource group.storage_account_and_container.yaml- This is a deployable configuration. It will link to a template in thebicepfolder and contain the required parameters.Samplebicepandconfigurationfolders are included in the root of this repo.Bicep filesThis is just a standard bicep template, for example when creating a storage account and container you might have a file such asstorage_account_and_container.yamlthat looks something like:param location string
param storageName string
param containerName string
param skuName string

resource StorageAccount 'Microsoft.Storage/storageAccounts@2019-06-01' = {
  name: storageName
  location: location
  kind: 'Storage'
  sku: {
    name: skuName
  }
}

resource StorageContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2019-06-01' = {
  name: '${StorageAccount.name}/default/${containerName}'
  properties: {
    publicAccess: 'None'
  }
}

output storageLocation string = StorageAccount.properties.primaryLocationConfiguration filesGiven the configuration fileconfiguration/Subscription_1/Resource_Group_1/storage_account_and_container.yaml:
This is broken down into sections as such:<discarded>/<Subscription>/<resource_group>/<config_to_deploy>in this casestorage_account_and_container.yamlmight look like the following:---
bicep_path: storage_account.bicep
scope: resource_group

pre_hooks:
  PythonScript: scripts/test_python_hook.py

params:
  storageName: storagetestlolit1
  containerName: blog
  skuName: Standard_LRS
  location: Ref:Subscription_1.Resource_Group_1.config2:storageLocation

post_hooks:
  BashScript: scripts/test_bash_hook.shThebicep_pathhere points to the template in thebicep/folder of the project. This bicep template is then deployed using the providedparamsblock to the subscription and resource group determined by the configuration files path.scopeis an optional parameter, where the default value is not specified isresource_group. The other valid value issubscription. This sets the deployment at a subscription scope rather than a resource group scope. This is particularly useful for setting upAzure Policy.pre_hooksandpost_hooksallow you to specify external scripts that should be run before or after the bicep deplloyment respectivly. If A hook returns a non-success code deployment will be terminated. At current there is only support forPython3scripts andBashscripts.pre_commitandpost_commitHooks are both optional optional.Referencing Other Deployment OutputsAny parameter in the config file prefixes withRef:is a reference to an output from a different deployment. The format for referencing an output from a different deployment is:<Ref>:<deployment_path>:<output_name>where thedeployent_pathreplaces/with..When referencing the output from a different deployment lolite will first check if the dependent deployment exists then deploy it if required. If the dependent deployment does exist lolite will look up the output value and use it for the deployment. deployment hierarchy can be of an arbitrary depth and span across the whole project.If the resource group for a deployment does not exist lolite will create it for you using the location specified by thelocation.yamlfile.location.yamlThis is a super simple file that is required for every resource group. It tells lolite what location to create the resource group in if it does not exist. Each resource deployed into that resource group inherits the location. An example of a location.yaml:---
location: australiaeastUsagelolite is designed to be easy to use and allow scoped control of deployments.Deploying a single configurationFrom the root folder of your repository run the following command:lolite deploy Subscription_1/Resource_Group_1/storage_account_and_container.yamlThis will deploy a single configuration / templateDeploying at resource group scopeFrom the root folder of your repository run the following command:lolite deploy-resource-group Subscription_1/Resource_Group_1This will deploy every configuration file under that resource groupDeploying at subscription scopeFrom the root folder of your repository run the following command:lolite deploy-subscription Subscription_1This will deploy each configuration file for each resource group in the specified subscriptionDeploying at account scopeFrom the root folder of your repository run the following command:lolite deploy-accountThis will deploy every configuration file in the project to the appropriate subscriptions and resource groups