SlideShare a Scribd company logo
1 of 26
Download to read offline
멀티리전 &
멀티스테이지 인프라를
위한
모노레포 구축하기
Building a monorepo for multi-region & multi-stage
infrastructure provisioning.
Software Engineer at Superb AI
he/him
@yoosful (LinkedIn, Github)
Yonghwan
Yoo
About Superb AI
Democratize AI
Suite
Data platform for computer vision
Global SaaS service using AWS
Intro: Our Backend
01
AWS Cloud
VPC
System Architecture
AWS Services
use1
apne2
ECS
CI/CD, Scaling, Monitoring, etc.
Database
VPC
multi-region
Separate regions (apne2 & use1) by cluster
- serve clients in S. Korea & USA
System Backend
VPC & Cluster
use1
apne2
VPC
multi-region
Separate regions (apne2 & use1) by cluster
- serve clients in S. Korea & USA
multi-stage
Separate environments (dev & prod) by cluster
- each cluster has different specs
=> Terraform, save us…
System Backend
VPC & Cluster
use1
apne2
dev
prod
VPC VPC
VPC VPC
Infra Provisioning
Hello Terraform!
efficiency
More application => need for automation
- repetitive steps in multi-stage & -region
- console / ad-hoc scripts are not enough
service A
service B
service C
service D
efficiency
More application => need for automation
- repetitive steps in multi-stage & -region
- console / ad-hoc scripts are not enough
Infra Provisioning
Hello Terraform!
Let’s add to our backend.
But first...
service A
X4
Let’s add to our backend.
But first...
service A
efficiency
More application => need for automation
- repetitive steps in multi-stage & -region
- console / ad-hoc scripts are not enough
standardization
Define and share reusable components
- increases consistency b/w applications
Infra Provisioning
Hello Terraform!
Let’s add to our backend.
We need for our backend.
service B
service C
How about in our backend?
service D
X4
Towards Monorepo
02
Don’t reinvent the wheel
Fork and customize AWS registry modules.
Initial Layout
Initiatives
fork
Don’t reinvent the wheel
Fork and customize AWS registry modules.
Build once, deploy many
Build custom module with reference modules.
Set vars for multi-stage & -region deployment.
Initial Layout
Initiatives
service A
module
fork
variable "fargate_desired_count" {
type = number
}
variable "fargate_deployment_maximum_percent" {
type = number
}
variable "fargate_deployment_minimum_healthy_percent" {
type = number
}
…
apne2-dev
apne2-prod
use1-dev
use1-prod
Don’t reinvent the wheel
Fork and customize AWS registry modules.
Build once, deploy many
Build custom module with reference modules.
Set vars for multi-stage & -region deployment.
Fast development cycle
No CI/CD pipeline. No branch protection.
One repository for each module / deployment.
Initial Layout
Initiatives
service A
module
A: apne2-dev
A: apne2-prod
A: use1-dev
A: use1-prod
fork
complexity
ex) one additional service
= (1 module repo + 4 deployment repos)
x (number of modules)
Problems
Unwanted Result
service A
static
A: apne2-dev
A: apne2-prod
A: use1-dev
A: use1-prod
service A
dynamic
A: apne2-dev
A: apne2-prod
A: use1-dev
A: use1-prod
Problems
Unwanted Result
complexity
ex) one additional service
= (1 module repo + 4 deployment repos)
x (number of modules)
inefficiency
More repositories => consistency gradually lost
Scattered documents => high barrier to entry
The Great Debate
Multi Repo vs Mono Repo
Multi Repo
Good
- submodule versioning
- independent testing
- separate access control
Bad
- multiple source of truth
(= more PRs which leads to inefficiency)
- inconsistency across projects
The Great Debate
https://www.hashicorp.com/blog/terraform-mono-repo-vs-multi-repo-the-great-debate
Mono Repo
Good
- single source of truth
(= lower barrier to entry)
- consistency across projects
Bad
- submodule versioning is hard
- separate CI pipelines is hard
- separate access control is hard
Multi Repo
Good
- submodule versioning
- independent testing
- separate access control
Bad
- multiple source of truth
(= more PRs which leads to inefficiency)
- inconsistency across projects
Mono Repo
Good
- single source of truth
(= lower barrier to entry)
- consistency across projects
Bad
- submodule versioning is hard
- separate CI pipelines is hard
- separate access control is hard
The Great Debate
https://www.hashicorp.com/blog/terraform-mono-repo-vs-multi-repo-the-great-debate
Multi Repo
Good
- submodule versioning
- independent testing
- separate access control
Bad
- multiple source of truth
(= more PRs which leads to inefficiency)
- inconsistency across projects
Mono Repo
Good
- single source of truth
(= lower barrier to entry)
- consistency across projects
Bad
- submodule versioning is hard
- separate CI pipelines is hard
- separate access control is hard
The Great Debate
https://www.hashicorp.com/blog/terraform-mono-repo-vs-multi-repo-the-great-debate
<-> initial goals
hard but doable
3 mono repos
- Reference Modules
- Service Modules
- Live Deployments
Q. why not just 1 big mono repo?
- Separate modules from deployments
- Prevent self-reference
New Layout
Improvement
Reference Modules
Source Tree [GITHUB]
> terraform-aws-alb
> terraform-aws-bastion
> terraform-aws-code-deploy
> terraform-aws-dynamodb
> terraform-aws-ecr
> terraform-aws-ecs
…
Service Modules
Source Tree [GITHUB]
> module-service-A
> module-service-B
> module-service-C
> module-service-D
…
Live Repository
Source Tree [GITHUB]
> suite-service-A
> dev
> apne2
> use1
> prod
> apne2
> use1
…
CODE EDITOR
Continuous
Integration
1. check formatting
2. fetch dependencies
3. validate project
# Set up terraform
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
# Checks canonical formatting
- name: Terraform Format
run: terraform fmt -check -recursive
# Initialize and validate sub-directories
- name: Terraform Validate
run: |
find "$(pwd -P)" -type d -links 2 
| while read subdir
do
cd $subdir
terraform init
terraform validate
done
Future Plans
03
collaboration
What if multiple applys happen at the same time?
=> state locking solves everything?
In reality, things can get messy…
- someone may force-unlock
- partial apply (ex. apply target)
=> CI/CD (ex. bind commands to github actions)
Can we do better?
Remaining Issues
https://quileswest.medium.com/how-to-lock-terraform-state-with-s3-bucket-in-dynamodb-3ba7c4e637
terraform plan
terraform apply
maintenance
What if modules become stale?
=> Use git tags for versioning
How to prevent potential misconfigurations?
=> Use static analysis tools
Can we do better?
Remaining Issues
A/1.1.1 B/1.0.1 C/0.4.2
A/1.1.2
A B A C
tfsec checkov
Thank You
hugs@hashicorp.com | learn.hashicorp.com | discuss.hashicorp.com

More Related Content

Similar to 멀티리전 & 멀티스테이지 인프라를 위한 모노레포 구축하기

EMC SRM vs. Sentinel Navigator - Deep dive
EMC SRM vs. Sentinel Navigator - Deep diveEMC SRM vs. Sentinel Navigator - Deep dive
EMC SRM vs. Sentinel Navigator - Deep divesansentinel
 
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with Spinnaker
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with SpinnakerSpinnaker Summit 2018: CI/CD Patterns for Kubernetes with Spinnaker
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with SpinnakerAndrew Phillips
 
Deploying your web application with AWS ElasticBeanstalk
Deploying your web application with AWS ElasticBeanstalkDeploying your web application with AWS ElasticBeanstalk
Deploying your web application with AWS ElasticBeanstalkJulien SIMON
 
Tokyo azure meetup #12 service fabric internals
Tokyo azure meetup #12   service fabric internalsTokyo azure meetup #12   service fabric internals
Tokyo azure meetup #12 service fabric internalsTokyo Azure Meetup
 
Production Experience: Some Insights from Using Vercel and Next.js for Over 3...
Production Experience: Some Insights from Using Vercel and Next.js for Over 3...Production Experience: Some Insights from Using Vercel and Next.js for Over 3...
Production Experience: Some Insights from Using Vercel and Next.js for Over 3...KosukeMatano1
 
Kubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF WebinarKubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF WebinarEtienne Tremel
 
Production Grade Kubernetes Applications
Production Grade Kubernetes ApplicationsProduction Grade Kubernetes Applications
Production Grade Kubernetes ApplicationsNarayanan Krishnamurthy
 
Ravello webinar - Creating smart labs on AWS/Google for sales demos, training...
Ravello webinar - Creating smart labs on AWS/Google for sales demos, training...Ravello webinar - Creating smart labs on AWS/Google for sales demos, training...
Ravello webinar - Creating smart labs on AWS/Google for sales demos, training...shrutib
 
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...Arthur Berezin
 
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018Mandi Walls
 
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Amazon Web Services
 
Pivotal Container Service Overview
Pivotal Container Service Overview Pivotal Container Service Overview
Pivotal Container Service Overview VMware Tanzu
 
Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Platonov Sergey
 
Getting Started with MariaDB with Docker
Getting Started with MariaDB with DockerGetting Started with MariaDB with Docker
Getting Started with MariaDB with DockerMariaDB plc
 
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...Lightbend
 
Continuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWSContinuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWSAmazon Web Services
 
Software Variability Management
Software Variability ManagementSoftware Variability Management
Software Variability ManagementXavierDevroey
 
OS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of MLOS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of MLNordic APIs
 

Similar to 멀티리전 & 멀티스테이지 인프라를 위한 모노레포 구축하기 (20)

EMC SRM vs. Sentinel Navigator - Deep dive
EMC SRM vs. Sentinel Navigator - Deep diveEMC SRM vs. Sentinel Navigator - Deep dive
EMC SRM vs. Sentinel Navigator - Deep dive
 
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with Spinnaker
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with SpinnakerSpinnaker Summit 2018: CI/CD Patterns for Kubernetes with Spinnaker
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with Spinnaker
 
Deploying your web application with AWS ElasticBeanstalk
Deploying your web application with AWS ElasticBeanstalkDeploying your web application with AWS ElasticBeanstalk
Deploying your web application with AWS ElasticBeanstalk
 
Tokyo azure meetup #12 service fabric internals
Tokyo azure meetup #12   service fabric internalsTokyo azure meetup #12   service fabric internals
Tokyo azure meetup #12 service fabric internals
 
Production Experience: Some Insights from Using Vercel and Next.js for Over 3...
Production Experience: Some Insights from Using Vercel and Next.js for Over 3...Production Experience: Some Insights from Using Vercel and Next.js for Over 3...
Production Experience: Some Insights from Using Vercel and Next.js for Over 3...
 
Kubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF WebinarKubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF Webinar
 
Production Grade Kubernetes Applications
Production Grade Kubernetes ApplicationsProduction Grade Kubernetes Applications
Production Grade Kubernetes Applications
 
Ravello webinar - Creating smart labs on AWS/Google for sales demos, training...
Ravello webinar - Creating smart labs on AWS/Google for sales demos, training...Ravello webinar - Creating smart labs on AWS/Google for sales demos, training...
Ravello webinar - Creating smart labs on AWS/Google for sales demos, training...
 
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
 
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
 
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
 
Pivotal Container Service Overview
Pivotal Container Service Overview Pivotal Container Service Overview
Pivotal Container Service Overview
 
Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...
 
Getting Started with MariaDB with Docker
Getting Started with MariaDB with DockerGetting Started with MariaDB with Docker
Getting Started with MariaDB with Docker
 
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
 
Continuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWSContinuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWS
 
Devops
DevopsDevops
Devops
 
Software Variability Management
Software Variability ManagementSoftware Variability Management
Software Variability Management
 
OS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of MLOS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of ML
 
Kubernetes 1001
Kubernetes 1001Kubernetes 1001
Kubernetes 1001
 

Recently uploaded

(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 

Recently uploaded (20)

(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 

멀티리전 & 멀티스테이지 인프라를 위한 모노레포 구축하기

  • 1. 멀티리전 & 멀티스테이지 인프라를 위한 모노레포 구축하기 Building a monorepo for multi-region & multi-stage infrastructure provisioning.
  • 2. Software Engineer at Superb AI he/him @yoosful (LinkedIn, Github) Yonghwan Yoo
  • 3. About Superb AI Democratize AI Suite Data platform for computer vision Global SaaS service using AWS
  • 5. AWS Cloud VPC System Architecture AWS Services use1 apne2 ECS CI/CD, Scaling, Monitoring, etc. Database
  • 6. VPC multi-region Separate regions (apne2 & use1) by cluster - serve clients in S. Korea & USA System Backend VPC & Cluster use1 apne2 VPC
  • 7. multi-region Separate regions (apne2 & use1) by cluster - serve clients in S. Korea & USA multi-stage Separate environments (dev & prod) by cluster - each cluster has different specs => Terraform, save us… System Backend VPC & Cluster use1 apne2 dev prod VPC VPC VPC VPC
  • 8. Infra Provisioning Hello Terraform! efficiency More application => need for automation - repetitive steps in multi-stage & -region - console / ad-hoc scripts are not enough service A service B service C service D
  • 9. efficiency More application => need for automation - repetitive steps in multi-stage & -region - console / ad-hoc scripts are not enough Infra Provisioning Hello Terraform! Let’s add to our backend. But first... service A X4
  • 10. Let’s add to our backend. But first... service A efficiency More application => need for automation - repetitive steps in multi-stage & -region - console / ad-hoc scripts are not enough standardization Define and share reusable components - increases consistency b/w applications Infra Provisioning Hello Terraform! Let’s add to our backend. We need for our backend. service B service C How about in our backend? service D X4
  • 12. Don’t reinvent the wheel Fork and customize AWS registry modules. Initial Layout Initiatives fork
  • 13. Don’t reinvent the wheel Fork and customize AWS registry modules. Build once, deploy many Build custom module with reference modules. Set vars for multi-stage & -region deployment. Initial Layout Initiatives service A module fork variable "fargate_desired_count" { type = number } variable "fargate_deployment_maximum_percent" { type = number } variable "fargate_deployment_minimum_healthy_percent" { type = number } … apne2-dev apne2-prod use1-dev use1-prod
  • 14. Don’t reinvent the wheel Fork and customize AWS registry modules. Build once, deploy many Build custom module with reference modules. Set vars for multi-stage & -region deployment. Fast development cycle No CI/CD pipeline. No branch protection. One repository for each module / deployment. Initial Layout Initiatives service A module A: apne2-dev A: apne2-prod A: use1-dev A: use1-prod fork
  • 15. complexity ex) one additional service = (1 module repo + 4 deployment repos) x (number of modules) Problems Unwanted Result service A static A: apne2-dev A: apne2-prod A: use1-dev A: use1-prod service A dynamic A: apne2-dev A: apne2-prod A: use1-dev A: use1-prod
  • 16. Problems Unwanted Result complexity ex) one additional service = (1 module repo + 4 deployment repos) x (number of modules) inefficiency More repositories => consistency gradually lost Scattered documents => high barrier to entry
  • 17. The Great Debate Multi Repo vs Mono Repo
  • 18. Multi Repo Good - submodule versioning - independent testing - separate access control Bad - multiple source of truth (= more PRs which leads to inefficiency) - inconsistency across projects The Great Debate https://www.hashicorp.com/blog/terraform-mono-repo-vs-multi-repo-the-great-debate Mono Repo Good - single source of truth (= lower barrier to entry) - consistency across projects Bad - submodule versioning is hard - separate CI pipelines is hard - separate access control is hard
  • 19. Multi Repo Good - submodule versioning - independent testing - separate access control Bad - multiple source of truth (= more PRs which leads to inefficiency) - inconsistency across projects Mono Repo Good - single source of truth (= lower barrier to entry) - consistency across projects Bad - submodule versioning is hard - separate CI pipelines is hard - separate access control is hard The Great Debate https://www.hashicorp.com/blog/terraform-mono-repo-vs-multi-repo-the-great-debate
  • 20. Multi Repo Good - submodule versioning - independent testing - separate access control Bad - multiple source of truth (= more PRs which leads to inefficiency) - inconsistency across projects Mono Repo Good - single source of truth (= lower barrier to entry) - consistency across projects Bad - submodule versioning is hard - separate CI pipelines is hard - separate access control is hard The Great Debate https://www.hashicorp.com/blog/terraform-mono-repo-vs-multi-repo-the-great-debate <-> initial goals hard but doable
  • 21. 3 mono repos - Reference Modules - Service Modules - Live Deployments Q. why not just 1 big mono repo? - Separate modules from deployments - Prevent self-reference New Layout Improvement Reference Modules Source Tree [GITHUB] > terraform-aws-alb > terraform-aws-bastion > terraform-aws-code-deploy > terraform-aws-dynamodb > terraform-aws-ecr > terraform-aws-ecs … Service Modules Source Tree [GITHUB] > module-service-A > module-service-B > module-service-C > module-service-D … Live Repository Source Tree [GITHUB] > suite-service-A > dev > apne2 > use1 > prod > apne2 > use1 …
  • 22. CODE EDITOR Continuous Integration 1. check formatting 2. fetch dependencies 3. validate project # Set up terraform - name: Setup Terraform uses: hashicorp/setup-terraform@v1 # Checks canonical formatting - name: Terraform Format run: terraform fmt -check -recursive # Initialize and validate sub-directories - name: Terraform Validate run: | find "$(pwd -P)" -type d -links 2 | while read subdir do cd $subdir terraform init terraform validate done
  • 24. collaboration What if multiple applys happen at the same time? => state locking solves everything? In reality, things can get messy… - someone may force-unlock - partial apply (ex. apply target) => CI/CD (ex. bind commands to github actions) Can we do better? Remaining Issues https://quileswest.medium.com/how-to-lock-terraform-state-with-s3-bucket-in-dynamodb-3ba7c4e637 terraform plan terraform apply
  • 25. maintenance What if modules become stale? => Use git tags for versioning How to prevent potential misconfigurations? => Use static analysis tools Can we do better? Remaining Issues A/1.1.1 B/1.0.1 C/0.4.2 A/1.1.2 A B A C tfsec checkov
  • 26. Thank You hugs@hashicorp.com | learn.hashicorp.com | discuss.hashicorp.com