Learn Idem

Learn Idem

Powered by Idem Project


In order to create a new Azure Resource Group, we craft the my_resource_group_state.sls: file with the following contents:

<Your Azure Resource Group Name>:
  - resource_group_name: <Your Azure Resource Group Name>
  - parameters:
    location: <Azure Region>
    tags: {}

We refer first to the Azure Idem Plug-In’s Resource Group - “ azure.resource_management.resource_groups ” and we append the state directive present , for instructing idem to create a new resource group in Azure.

Please note that you can map Azure REST API’s URI and Body Parameters to the state parameters, e.g. for the Azure Resource Group

Then State SLS file can be executed with:

idem state <file_path>/my_resource_group_state.sls

In this example:

idem state states/my_resource_group_state.sls

After that you will see Idem appending our tag information to meet our new intentention and state.

      ID: moff-idem-01
Function: azure.resource_management.resource_groups.present
  Result: True
 Comment: Created
 Changes: new:

You can further verify by the idem describe and filter by the resource group name.

idem describe azure.resource_management.resource_groups  --filter="[?resource[?resource_group_name=='moff-idem-01']]"

State Present:

The resource parameters in an SLS yaml file follow the exact structure as what’s in the Azure REST API doc . URI Parameters should be specified in each case with “-” in front. All parameters of the API request body should be specified in exactly the same way as what’s in the Azure REST API doc . Please note that we can use the state describe for creating SLS files with most parameters.

You can include multiple resources in a single SLS yaml file. Some resources may have dependencies among them, for that you include reconciler=basic flag , This allows Idem-azure-auto to run Idem state with Idem’s reconciliation loop.

Last updated on 8 Feb 2022
 Edit on GitHub