Day-16 | Infrastructure as Code | #terraform #IaC
Introduction to Infrastructure as Code
Overview of the Session
- Abhishek introduces the session, marking it as Day 16 of a complete DevOps course.
- The focus for today is on "Infrastructure as Code," with an emphasis on understanding the underlying problems and solutions.
Understanding Infrastructure Needs
- Abhishek sets the context by describing a hypothetical scenario where a DevOps engineer works for Flipkart.
- He explains that Flipkart has numerous applications (300), necessitating various compute resources like CPU and RAM.
Deployment Options
- Flipkart can deploy applications across multiple platforms: AWS, Azure, Google Cloud Platform, or on-premises servers.
- The choice of deployment platform is crucial; there are many options beyond just the major cloud providers.
Automation in AWS
Decision-Making Process
- As a DevOps engineer, one might decide to host infrastructure on AWS after evaluating all options.
Automation Tools
- The engineer automates resource creation using tools like AWS CLI and CloudFormation Templates (CFT).
- CFT allows for efficient management of resources such as EC2 instances and S3 buckets through scripts.
Challenges with Vendor Lock-In
Migration Issues
- A shift from AWS to another provider (e.g., Microsoft Azure) presents challenges due to vendor lock-in.
- Existing scripts written for AWS become obsolete when migrating to Azure since they are not compatible.
Rewriting Scripts
- The need arises to rewrite hundreds of automation scripts into Azure Resource Manager templates, which requires significant effort.
Further Transitions
On-Premise Solutions
- If dissatisfaction continues with Azure, organizations may opt for an on-premise solution using OpenStack.
Building Custom Infrastructure
- This transition involves purchasing servers and creating a private cloud environment using OpenStack.
Understanding Hybrid Cloud and Terraform
Migration to Heat Templates
- The speaker discusses the migration of scripts from AWS CloudFormation Templates (CFT) to Azure Resource Manager, and then to OpenStack's Heat templates for automation.
- Emphasizes that Heat templates are essential for automating infrastructure on OpenStack, highlighting the complexity involved in migrating these scripts.
The Hybrid Cloud Model
- Defines the hybrid cloud model where organizations can host parts of their infrastructure on different cloud providers like AWS and Azure based on specific needs.
- Explains that companies choose hybrid clouds due to varying strengths of cloud services; for instance, using AWS for storage services while opting for Azure DevOps for project management.
Learning Requirements for DevOps Engineers
- Asserts that DevOps engineers must learn both AWS CFT and Azure Resource Manager to effectively manage automation across platforms.
- Notes that some organizations may prefer on-premise solutions over public clouds, necessitating knowledge of various tools including Heat templates.
Challenges with Multiple Tools
- Discusses the challenge of learning numerous tools as more cloud providers emerge, leading to potential confusion among DevOps engineers.
- Introduces Terraform as a solution developed by HashiCorp aimed at simplifying this learning curve by allowing engineers to use one tool instead of many.
Benefits of Using Terraform
- Highlights Terraform's role in addressing the problem of managing multiple tools by enabling infrastructure as code across various cloud providers seamlessly.
- Mentions that while Terraform simplifies processes, it does not eliminate all challenges associated with migrations between different cloud environments.
Automation Across Providers
- Describes how Terraform allows users to write scripts that automate resources across multiple platforms like AWS, Azure, and GCP without needing extensive knowledge about each provider's specific tools.
Understanding API as Code and Terraform
Introduction to API as Code
- The concept of API as Code allows for automation across various infrastructure providers like AWS, Azure, or OpenStack using their APIs.
- Terraform interacts with these APIs without requiring users to write extensive code; it translates user-defined scripts into API requests that the cloud provider can understand.
How Terraform Works
- Users specify the provider (e.g., AWS) in a file called
provider.tf, and Terraform converts the script into an API request tailored for that provider.
- This process enables users to automate resource management on any cloud platform through a single tool—Terraform.
Understanding APIs
- An API (Application Programming Interface) serves as a bridge allowing applications to communicate programmatically rather than through manual user interfaces.
- For example, instead of manually searching Google via a browser, one could run a script that communicates directly with Google's API to retrieve information.
Programmatic Interaction with Applications
- Developers create APIs so applications can be accessed programmatically. This eliminates the need for manual interaction and streamlines processes.
- Examples include using terminal commands like
curlor HTTP requests to interact with services such as GitHub or Google without needing to log in through a web interface.
Terraform's Role in Simplifying API Interactions
- Terraform abstracts direct interactions with cloud provider APIs by allowing users to write simple configuration files instead of complex programming code.
- It actively manages these interactions by converting user inputs into appropriate API calls behind the scenes, making it easier for users who may not have programming expertise.
Summary of Key Concepts Learned
- Two main concepts discussed are Infrastructure as Code (IaC) and API as Code, both essential for automating infrastructure management effectively.
Understanding Infrastructure as Code and Terraform
The Concept of Infrastructure as Code
- Infrastructure as Code (IaC) is a methodology that allows the management of infrastructure through code, enabling automation and consistency in deployment.
- Terraform is presented as a solution to common challenges associated with IaC, offering advanced capabilities referred to as "API as Code."
- Instead of requiring knowledge of multiple cloud-specific languages (like AWS CloudFormation or Azure Resource Manager), Terraform simplifies the process by allowing users to learn just one language.
Benefits of Using Terraform
- By using Terraform, users can interact with various cloud providers seamlessly, leveraging its API capabilities without needing extensive knowledge about each provider's specific tools.