Description
Hi Magic Modules maintainers,
This is a minor documentation feedback item for the "Add a field to an existing resource" guide: https://googlecloudplatform.github.io/magic-modules/develop/add-fields/#add-fields
Area: Develop -> Add fields -> MMv1 -> Map Example
Description:
In the code example provided for the Map
field type, the key_name
placeholder is shown as 'KEY_NAME'
. This uses the same all-caps style as the name
field placeholder ('API_FIELD_NAME'
).
While name
typically maps to an API field often using camelCase, the key_name
is used to define the key field within the resulting Terraform TypeSet structure. According to Terraform conventions mentioned elsewhere in the docs (e.g., for handwritten fields), Terraform field names should use snake_case.
Using the placeholder's implied camelCase convention for key_name
(e.g., exampleKeyName
) can lead to a downstream InternalValidate
error during provider generation, stating: Field name may only contain lowercase alphanumeric characters & underscores.
This reinforces that key_name
must adhere to the snake_case format.
Suggestion:
To avoid potential confusion and better guide developers towards the correct convention for key_name
, consider updating the placeholder in the example. Perhaps something like 'my_key_name'
or 'example_key_name'
would more clearly suggest the expected snake_case format for this specific field and prevent the validation error mentioned above.
This is a small enhancement suggestion to improve documentation clarity.
Thanks!