Skip to content

Display module versions in a similar fashion that provider versions are displayed with version #3270

@grimm26

Description

@grimm26

Community note

Tip

👋 Hi there, OpenTofu community! The OpenTofu team prioritizes issues based on upvotes. Please make sure to upvote this issue and describe how it affects you in detail in the comments to show your support.

OpenTofu Version

OpenTofu v1.10.6
on linux_amd64

The problem in your OpenTofu project

I'd like to be able to see what versions of modules in a unit have been downloaded. Not all modules will have an associated version since a module source can be one of a few things that do not have a version (at least that tofu knows about).
This is probably only appropriate for modules sourced from a module registry and I see that the version is indeed recorded for these in .terraform/modules/modules.json after an init. This is important information in any instance where anything but an exact version for a module is specified.

Attempted Solutions

I could not find any tofu command that would show me the version of a module that has been downloaded to be used in a plan/apply. My only solution at this point is to consume .terraform/modules/modules.json with a custom tool.

Proposal

Today, when I run tofu version in a project, I see something like:

❯ tofu version
OpenTofu v1.10.6
on linux_amd64
+ provider registry.opentofu.org/hashicorp/aws v6.13.0

I'd like to see module version info as well:

❯ tofu version
OpenTofu v1.10.6
on linux_amd64
+ provider registry.opentofu.org/hashicorp/aws v6.13.0
+ module myregistry.foo.com/namespace/iam/aws v1.4.2

And similarly in the json output in a module_selections hash.

{
  "terraform_version": "1.10.6",
  "platform": "linux_amd64",
  "provider_selections": {
    "registry.opentofu.org/hashicorp/aws": "5.100.0"
  }
  "module_selections": {
    "myregistry.foo.com/namespace/iam/aws": "1.4.2"
  }
}

Workarounds and Alternatives

the workaround is to write a custom tool to ingest the .terraform/modules/modules.json file and output something to record along with the plan/apply or otherwise use the info.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions