Skip to content

Extend --name-pattern: Support per-resource placeholders#664

Merged
magodo merged 4 commits into
Azure:mainfrom
magodo:resource_name_pattern_ext
Jun 26, 2026
Merged

Extend --name-pattern: Support per-resource placeholders#664
magodo merged 4 commits into
Azure:mainfrom
magodo:resource_name_pattern_ext

Conversation

@magodo

@magodo magodo commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Extend --name-pattern beyond the incremental index (*) to support a
set of per-resource placeholders, expanded from the parsed Azure
resource id (via armid):

  • {type} - last Azure resource type segment (e.g. virtual_machines)
  • {rp} - resource provider namespace (e.g. microsoft_compute)
  • {name} - last name segment of the resource id
  • {root_scope} - root scope name (e.g. resource group name)

Placeholder values are snake_cased and sanitized to valid Terraform
identifiers. The * index is now tracked per expanded prefix/suffix,
so e.g. --name-pattern '{type}*' yields virtual_machines0,
virtual_machines1, virtual_networks0, ... — producing more
meaningful addresses like azapi_resource.virtual_machines0 instead
of azapi_resource.res-0.

magodo added 2 commits June 19, 2026 20:32
Extend `--name-pattern` beyond the incremental index (`*`) to support a
set of per-resource placeholders, expanded from the parsed Azure
resource id (via armid):

 - `{type}`       - last Azure resource type segment (e.g. virtual_machines)
 - `{rp}`         - resource provider namespace    (e.g. microsoft_compute)
 - `{name}`       - last name segment of the resource id
 - `{root_scope}` - root scope name (e.g. resource group name)

Placeholder values are snake_cased and sanitized to valid Terraform
identifiers. The `*` index is now tracked per expanded prefix/suffix,
so e.g. `--name-pattern '{type}*'` yields `virtual_machines0`,
`virtual_machines1`, `virtual_networks0`, ... — producing more
meaningful addresses like `azapi_resource.virtual_machines0` instead
of `azapi_resource.res-0`.
@magodo magodo changed the title Extend --name-pattern: Support per-resource placeholders. Extend --name-pattern: Support per-resource placeholders Jun 22, 2026

@gerrytan gerrytan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @magodo , I left 1 minor doc feedback, but the change looks good otherwise. Approved in advance.

Comment thread internal/meta/name_pattern.go
@magodo magodo merged commit 99f3be0 into Azure:main Jun 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants