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

code examples include resource names that go against naming convention best practices. #5030

Open
65156 opened this issue Jan 8, 2024 · 0 comments

Comments

@65156
Copy link

65156 commented Jan 8, 2024

It is poor practice to include in a declaration of a resource (excluding the resource block contents), any name-part of the resource type, as this leads to longer than necessary names in state-files and longer processing time for engineers to infer resources. These code examples set the standards for new engineers and they should not be led away from best practices, especially in these early stages.

Below is an example where the ibm_resource_instance has a new declaration of pdns-instance, thus duplicating the word instance in the statefile. Its already clear that its an instance by the declaration of the resource type, it does not need to be mentioned again in the name.

Example:

resource "ibm_resource_instance" "pdns-instance" {
  name              = "pdns-instance"
  resource_group_id = data.ibm_resource_group.rg-dns.id
  location          = "global"
  service           = "dns-svcs"
  plan              = "standard-dns"
}

An easy substitute would be to use an integer in resource identifiers like example-01, instead of example-instance.

Solution:

resource "ibm_resource_instance" "pdns-01" {
  name              = "pdns-instance-01"
  resource_group_id = data.ibm_resource_group.rg-dns.id
  location          = "global"
  service           = "dns-svcs"
  plan              = "standard-dns"
}

Direct Example: https://github.com/IBM-Cloud/terraform-provider-ibm/blob/b991118092aebc153f86b113b9a82f5bd4410520/examples/ibm-dns-linked-zone/main.tf#L1C44-L1C45

This is throughout all IBM provider documentation

@65156 65156 changed the title examples include names that go against naming convention best practices, and du code examples include resource names that go against naming convention best practices. Jan 8, 2024
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

No branches or pull requests

1 participant