python-terrascript
python-terrascript copied to clipboard
azure / azurerm provider availability
TLDR
azurerm provider have ben restructured, so that it does no get parsed properly
Description
So apparently Microsoft decided to refactor their azurerm provider with the side-effect that the makecode.py are no longer able to parse any resources or datasources out of it.
After some digging, it seems they;
a) Moved the provider code into azurerm/internal/provider/provider.go (added an extra /provider
in path)
b) Build the map of datasources and resources dynamically now:
c) Do this individually in the code for each service: https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/internal/services/appconfiguration/registration.go#L24
I can see how this make sense from a code perspective for them, but it make the current method of generating classes for datasources and resources in terrascript unable to do anything useful.
As a result of this, there is no classes for azurerm currently available in terrascript.
Possible workaround
def custom_data(data_type: str, name: str, *args, **kwargs):
""" Get a terrascript data object of the given type and name
:param data_type:
:param name:
:param args:
:param kwargs:
:return:
"""
return type(data_type, (terrascript.Data,), {})(name, *args, **kwargs)
Questions
- What is the proposed way to handle such situations?
- Does my workaround make sense, or is there a better way?
- Should terrascript have such a helper included (since this is hardly the first nor last time it will happen)?
@ilons any updates regarding this issue?!
@ilons any updates regarding this issue?!
No updates yet I'm afraid. I'll have a stab at it when the (delayed) 0.9.0 release is out the door.
@ilons have you worked on this on the 0.9 version? if not how can I help and contribute to this issue?
Hi @AmrMKayid, have a look at discussion #149 which is about re-writing the mechanism how provider bindings are generated. In summary, instead of parsing the Go source code, makecode.py
now queries the Terraform Provider Registry. I am in the process of implementing this so it should be in develop soon and make it into release 0.9.1