Have you used ready-made Terraform modules or written your own? Which do you prefer?
sobes.tech AI
Answer from AI
Used both ready-made Terraform modules and wrote my own. Ready modules are convenient for quick start and standardization, especially if they are well-supported and cover typical tasks (for example, setting up VPC, IAM, basic cloud services). However, I often have to write my own modules to account for specific project requirements, ensure flexibility, and enable component reusability.
I prefer to combine approaches: use proven ready-made modules as a base, and create custom ones for unique logic and integrations. This allows for faster development while maintaining control over the infrastructure.
An example of a simple custom module for creating an S3 bucket in AWS:
// modules/s3_bucket/main.tf
resource "aws_s3_bucket" "this" {
bucket = var.bucket_name
acl = var.acl
}
variable "bucket_name" {
type = string
}
variable "acl" {
type = string
default = "private"
}
This module can be used in different projects by passing different parameters.