starhawking / python-terrascript

Create Terraform files using Python scripts.
BSD 2-Clause "Simplified" License
516 stars 76 forks source link

azure / azurerm provider availability #108

Open ilons opened 4 years ago

ilons commented 4 years ago

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

AmrMKayid commented 4 years ago

@ilons any updates regarding this issue?!

ilons commented 4 years ago

@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.

AmrMKayid commented 3 years ago

@ilons have you worked on this on the 0.9 version? if not how can I help and contribute to this issue?

mjuenema commented 3 years ago

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