Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--name-pattern-value should allow variables from resource types, resource groups, or resource providers #183

Open
MohnJadden opened this issue Jul 21, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@MohnJadden
Copy link

MohnJadden commented Jul 21, 2022

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.

@magodo magodo added the think label Jul 22, 2022
@magodo
Copy link
Collaborator

magodo commented Jul 22, 2022

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

@magodo magodo added question Further information is requested and removed think labels Jul 22, 2022
@DanG-arch
Copy link

@MohnJadden .. Were you able to figure out the naming pattern syntax ? I am trying hard to get it to work :)

@magodo magodo added enhancement New feature or request and removed question Further information is requested labels Sep 28, 2022
@MohnJadden
Copy link
Author

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants