aztfexport
aztfexport copied to clipboard
--name-pattern-value should allow variables from resource types, resource groups, or resource providers
I'd like to be able to use --name-pattern-value to name resources based on their resource group and what type of resource it is, and to add a unique name to each. The logic here is that I'm taking Azure RGs based on their use case, and I want to have them pull names according to a standardized naming convention for ease of future management.
The way aztfy works now is that I can't figure out how to use --name-pattern-value to pull these details. For example, if I'm using aztfy to pull in resources from the MarketingVDI resource group, I'd like the resources to be managed within Terraform as follows:
Host pool: azurerm_virtual_desktop_host_pool.MarketingVDI VM login assignment: azurerm_role_assignment.MarketingVDI
Whereas if I'm using it to pull from LegalDeepStorage, the resource names should be:
Storage account: azurerm_storage_account.LegalDeepStorage Activity log alert: azurerm_monitor_activity_log_alert.LegalDeepStorage
(These are just examples - I know aztfy doesn't do every resource provider yet)
The end goal would be something like aztfy rg LegalDeepStorage --name-pattern-value %HCLResourceProviderType%_%ResourceGroupName%
, or other identifying placeholders - maybe %SubscriptionName%
, %ValueOfTagKeyNamedX%
, or other details that ARM might be able to pull.
@MohnJadden When you are running the aztfy
against a resource group, you already has the resource group name and the including subscription id? Then you can just use, e.g. --name-pattern <rg name>
, to specify the name pattern. It worth noting that we are now supporting terrafying a single resource via aztfy resource
, in which case, not all resources reside within a resource group (e.g. a subscription/mgmt group level resource).
@MohnJadden .. Were you able to figure out the naming pattern syntax ? I am trying hard to get it to work :)
@MohnJadden When you are running the
aztfy
against a resource group, you already has the resource group name and the including subscription id? Then you can just use, e.g.--name-pattern <rg name>
, to specify the name pattern. It worth noting that we are now supporting terrafying a single resource viaaztfy resource
, in which case, not all resources reside within a resource group (e.g. a subscription/mgmt group level resource).
The thing is that aztfexport doesn't take the name of the RG and apply it to the Terraform resource ID. Nor does it do so based on wildcards - if we have Legal1, Legal2, Legal3, etc., we have to run aztfexport multiple times. Or what if we want to take a bunch of RGs in a naming convention and have them conform to a different resource ID in Terraform? Or what if we want to have them in a mapped variable?
Same thing applies to single resources - if we want to wildcard-search for all resources starting with "Legal", we can't do so.