Hi.
I have been trying to prase the terraform files since last few days atleast with not much success.
So I want to post a question over here , if something I am missing or can be improve upon.
My main.tf file is as below.
terraform {
backend "s3" {
bucket = "bucket"
key = "c2an8q6a0brja8jaq3k0.tfstate"
region = "us-west-2"
dynamodb_table = "terraform-lock"
skip_region_validation = true
}
}
provider "null" {
version = "2.1"
}
provider "random" {
version = "2.3"
}
provider "template" {
version = "2.1"
}
provider "archive" {
version = "1.3"
}
provider "aws" {
version = "<= 4.0"
region = "us-west-2"
}
output "aws_vpc_main" {
value = module.dev-c2an8q6a0brja8jaq3k0-Network.vpc_id
}
module "dev-c2an8q6a0brja8jaq3k0-Network" {
source = "gitsource"
cidr = "10.0.0.0/16"
cluster_id = "c2an8q6a0brja8jaq3k0"
env = "dev"
owner = "me"
region = "us-west-2"
super_cluster = "dev"
platform_api = "api"
proj = "this"
}
Rest of the other modules..
I want to parse the above .tf file and want to use the parameters that is getting passed on to the Network module ( i.e cidr,env,region,super_cluster etc etc ).
I just want to know some pointers about parsing this file and the arguments we are passing to the module
I have looked at the terraform-config-inspect package, however it doesn’t support parsing the parameters/body passed on the modules. GitHub - hashicorp/terraform-config-inspect: A helper library for shallow inspection of Terraform configurations
I have some POC code, that can use LoadFile method from config · pkg.go.dev , however that is not supported from Terraform 0.14 and onwards.
I have looked at the other packages in recent version of terraform like configs · pkg.go.dev and its Parser struct type , however I am not getting much success there either.
Any pointer, would be much appreciated.
I am happy to share the work / code , I have written so far upon further request.
Thank You.