Professional Documents
Culture Documents
Code in:
15 minutes
Agenda
• Traditional infrastructure deployment
• What is Infrastructure as Code (a.k.a IaC)
• Benefits of IaC
• Imperative vs Declarative
• IaC with Terraform
• IaC in DevOps Pipelines
• Sample Setup
• Q&A
Traditional infrastructure
deployment
• Graphical user interface
• Scripts (platform specific)
Limitations
• Manual and time-consuming process
• Error-prone
• Inconsistency
• Configuration drift
• Difficulty to keep multiple environments in lockstep
• Scalability
• Difficult to document
What is Infrastructure
as Code?
• Managing and provisioning of infrastructure
through code:
• CI/CD Pipelines
• Simplify, standardize, and scale at ease Infrastructure as
Code
• Forward 1 mile
• Turn right • Go to the pizza restaurant
• Forward 2 miles
• Turn left
• Forward 3 miles
• Arrive at pizza restaurant
Imperative vs Declarative
What to do. What is wanted.
• RBAC workspaces
• Policy as code (approve and reject
automation) terraform.tfvars
output.tf
IaC with DevOps
Pipelines
• Leverage DevOps methodology with CI/CD VM
Storage
• Seamless integration of software Check the code into GitHub Run the build pipeline Resources get deployed
software development
2. Install terraform on the build agent
3. Initialize Terraform
4. Select Environment
5. Validate Terraform Code
6. Terraform Dry Run
deploy stages
• Support for multiple release strategies such
as blue/green, canary or rolling releases
Sample Setup
Prerequisites
• Jenkins installed
• Install Jenkins Terraform Plugin terraform.tfstate
Network SQL
provider.tf provider.tf
stages {
stage('Checkout') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/terenceluk/tf-
iac-az-repo']]])
}
}
stage ("terraform init") {
steps {
sh ('terraform init')
}
}
stage ("terraform plan") {
steps {
sh ('terraform plan')
}
}
stage ("terraform Action") {
steps {
echo "Terraform action is --> ${action}"
sh ('terraform ${action} --auto-approve')
}
}
}
}
Build Pipeline
• Navigate to Build with Parameters and
initiate build of infrastructure
Thank you for your time!