equinix / terraform-provider-equinix

Terraform Equinix provider
https://deploy.equinix.com/labs/terraform-provider-equinix/
MIT License
47 stars 45 forks source link

Improve discoverability and usability of examples/ #384

Open displague opened 11 months ago

displague commented 11 months ago

Community Note

Description

In #100, we moved the Fabric examples/ to their own GitHub repos. We've slid back from this position in recent updates. This can be seen in the project today with some inconsistent between resource families:

The main advantage of having the examples in the terraform-provider-equinix examples/ directory is that they are easier to maintain when making provider changes.

The main advantage of having examples included or referenced in the docs/ directory is that they are discoverable and alongside the primary reference for the resource.

The main advantage of having examples published in modules is that they can be consumed by Terraform directly. Their use can be measured. They can be modified to continue working even when the underlying resources have changed.

In order to make our examples more discoverable, usage measurable, reusable, and well maintained, the community would benefit from:

Alternatives and evolved presentations to consider:

displague commented 11 months ago

A counter argument is that the examples/ are tested, as evidenced in files like tests/connection_e2e_cloudRouter2serviceprofile_test.go

thogarty commented 11 months ago

A counter argument is that the examples/ are tested, as evidenced in files like tests/connection_e2e_cloudRouter2serviceprofile_test.go

This is actually a very good counter argument because Fabric will begin to use these integration tests for its Terraform additions for regression testing while we continue to meet parity with the available features available from the API.

displague commented 11 months ago

@thogarty There's some extra discussion around this in the upstream, wrt how modules are sourced. https://github.com/hashicorp/terraform/issues/31134#issuecomment-1741744663

My leaning for this issue, and with E2E testing and module discovery in mind, is that we move from:

equinix/terraform-provider-equinix /examples/fabric/v4/cloudRouterConnectivity/cloudRouter2aws to equinix-labs/terraform-equinix-fabric-cloudrouter-aws

This follows the pattern of the existing equinix-labs/terraform-equinix-fabric-connection-* modules.

Alternatively,

equinix-labs/terraform-equinix-fabric-cloudrouter/
   modules/{cloudrouter,aws,google,azure,...}
   examples/cloudrouter2{aws,google,azure}/

In either case, the E2E tests in this project would source the published version of those modules. This would help to prevent breaking changes from being introduced. If/when a breaking change is introduced, we'll have to be more deliberate in updating the E2E tests to refer to a branch of the published module repo updated with the breaking changes. Upon merge and release, change the branch reference to a tag reference. This should not be of immediate concerns since those tests are not run in this project's CI today.

The examples/ in this project would then follow the Network Edge examples/ne/README.md pattern, where we link out to external, published, reusable modules and their examples.

displague commented 7 months ago

The examples would benefit from a lint check:

displague commented 2 months ago

Fabric and NE examples are now located in:

https://github.com/equinix/terraform-equinix-fabric https://github.com/equinix/terraform-equinix-network-edge

https://github.com/equinix/terraform-provider-equinix/tree/main/examples is now using conventional paths.

There are some exceptions in examples/, guideposts to the modules. These should probably be moved out of the examples/ directory. Some possible homes for that content: the root README.md, Equinix Labs, Terraform Guides, or the provider index.md.