1) Public a module terraform
https://developer.hashicorp.com/terraform/registry/modules/publish#requirements
Bạn cần tạo 1 repo github public nhé
Cách đặt tên như sau:
Named terraform-<PROVIDER>-<NAME>
ví dụ như là: terraform-google-vault
or terraform-aws-ec2-instance
Mính đã tạo: https://github.com/mrnim94/terraform-aws-eks-ebs-csi




Bạn cần tạo release để terraform sẽ thấy được tag của release đó






Dưới đây là module của mình
mrnim94/eks-ebs-csi/aws | Terraform Registry
Trong 1 folder của terraform bình thường thì sau khi lên module bạn cần bỏ cái j?
Backend.

Bạn cứ tạo 1 release là terraform module sẽ auto nhận
2) Exciting things are regarding terraform (helpful)
2.1) Use conditionally created resource’s output
You can access dynamically created modules and resources as follows
output "vpc_id" { value = length(module.vpc) > 0 ? module.vpc[*].id : null }
- If count = 0, output is null
- If count > 0, output is list of vpc ids
If count = 1 and you want to receive a single vpc id you can specify:
output "vpc_id" { value = length(module.vpc) > 0 ? one(module.vpc).id : null }