Get terraform aws provider version constraints of tf modules from a git monorepo (gitlab) with versions tag

28 views Asked by At

We keep our self-team maintained terraform modules in a private git repository (gitlab). There are ~ 60 terraform modules. When we update a module we create a new annotated tag for it (not a lightweight tag).
The repository directory structure is like this:

  compute
    ec2
    eks-cluster
    lambda
    ...
  database
    redis
    dynamodb
  ...


The terraform aws provider version constraints are in the main.tf or version.tf:

terraform {
  required_version = ">= 0.13.6"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 3.30.0, < 6.0.0"
    }
  }
}


I would like to get for each module tag the terraform aws provider version constraints in a format similar to this:

compute-ec2/v1.8.0  source  = "hashicorp/aws" version = ">= 4.30.0, < 6.0.0" 
database-redis/v1.0.1  source  = "hashicorp/aws" version = ">= 3.30.0, < 4.0.0" 
...

How do you do this in your team? Can python-gitlab be used in this case? Thank you.

0

There are 0 answers