Terraform directory Structure for common infrastructure on aws for ADO pipeline

  Kiến thức lập trình

I have started working with terraform recently, I just want to understand the directory structure for design where we have common/different components as below and need to be integrated with ADO.

We have 5 overall environments dev, sit, uat, nft, prod where its organized as nonprod, nft, prod which is common with underlying infra but differentiated with RDS.

Nonprod have VPC, Subnets(private, public, databases), eks cluster, s3 in common but need to provision different databases for dev, sit, uat.

NFT have VPC, Subnets(private, public, databases), eks cluster, s3, RDS.

PROD have VPC, Subnets(private, public, databases), eks cluster, s3, RDS.

Overall i want to choose parameters from ADO which should implement as per environment. I have tried below options.

common state file for nonprod environments overall infra-provisioning and seperate one for RDS components.

I have structured like below two options but want to optimize and make it as single environment parameter. if its possible.

The below thought of choosing the environment variables as env: nonprod and application: dev

├── infrastructure
│   ├── environments
│   │   ├── prod
│   │   ├── nft
│   │   ├── nonprod
│   │   │   ├── infrastructure
│   │   │       ├── main.tf
│   │   │       ├── variables.tf
│   │   │       ├── backend.tf (common for nonprod) 
│   │   │   ├── db
│   │   │       ├── uat
│   │   │       ├── sit 
│   │   │   │       ├── main.tf
│   │   │   │       ├── backend.tf
│   │   │   │       └── variables.tf
│   │   │       ├── dev                
│   │   │   │       ├── main.tf
│   │   │   │       ├── backend.tf
│   │   │   │       └── variables.tf
│   └── modules
│       ├── vpc
│       │   ├── main.tf
│       │   ├── outputs.tf
│       │   └── variables.tf
│       ├── db
│       └── queue

Second option is to have different folder for each env, with all required terraform files, for all dev, uat, sit.

├── infrastructure
│   ├── environments
│   │   ├── prod
│   │   ├── nft
│   │   ├── uat
│   │   ├── sit
│   │   │   ├── infrastructure
│   │   │       ├── main.tf
│   │   │       ├── variables.tf
│   │   │       ├── backend.tf (common for nonprod) 
│   │   │   ├── db                
│   │   │   │   ├── main.tf
│   │   │   │   ├── backend.tf
│   │   │   │   └── variables.tf
│   │   ├── dev
│   │   │   ├── infrastructure
│   │   │       ├── main.tf
│   │   │       ├── variables.tf
│   │   │       ├── backend.tf (common for nonprod) 
│   │   │   ├── db                
│   │   │   │   ├── main.tf
│   │   │   │   ├── backend.tf
│   │   │   │   └── variables.tf
│   └── modules
│       ├── vpc
│       │   ├── main.tf
│       │   ├── outputs.tf
│       │   └── variables.tf
│       ├── db
│       └── queue

can anyone please help with better possible options or better to have independent pipelines.

Thanks in advance

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT