<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1562474106701642442</id><updated>2026-03-23T03:55:38.621-07:00</updated><category term="Devops"/><category term="Containerization"/><category term="Kubernetes"/><category term="Linux"/><category term="Trending"/><category term="Linux Howto"/><category term="Docker"/><category term="Orchestration"/><category term="Server"/><category term="Videos"/><category term="Ubuntu"/><category term="Devops Videos"/><category term="FTP"/><category term="Cloud Computing"/><category term="Linux FAQs"/><category term="AWS"/><category term="Linux Tutorials"/><category term="Artificial Intelligence"/><category term="Virtualization"/><category term="VirtualBox"/><category term="Linux Server Configuration"/><category term="Ubuntu Howto"/><category term="SSH"/><category term="DNS"/><category term="CentOS"/><category term="Linux Mint"/><category term="RHEL"/><category term="Kubernetes Videos"/><category term="Helm"/><category term="Helm Charts"/><category term="Vsftpd"/><category term="AWS EC2"/><category term="ArgoCD"/><category term="GCP"/><category term="GitOps"/><category term="Terraform"/><category term="Machine Learning"/><category term="Python"/><category term="Windows"/><category term="Google Cloud"/><category term="Ubuntu 22"/><category term="Cloud Computing Videos"/><category term="RHEL 8"/><category term="Ansible"/><category term="CentOS 8"/><category term="Ubuntu FAQs"/><category term="Openstack"/><category term="Jenkins"/><category term="Linux Videos"/><category term="Online Learning Platform"/><category term="Openstack Videos"/><category term="Terraform Videos"/><category term="Training Institute"/><category term="Ubuntu 20"/><category term="CentOS 7"/><category term="Cluster"/><category term="Docker Videos"/><category term="FileZilla"/><category term="GCP Cloud"/><category term="Github"/><category term="Kubeflow"/><category term="Linux Foundation"/><category term="RHEL 7"/><category term="Ansible Videos"/><category term="Cluster Videos"/><category term="Interview Questions"/><category term="Pure-FTPd"/><category term="Veritas"/><category term="Data Storages"/><category term="Datadog"/><category term="PostgreSQL"/><category term="Puppet"/><category term="Python Videos"/><category term="SpringBoot"/><category term="Virtualization Basics"/><category term="YubiKey"/><category term="CrossFTP"/><category term="Docker Hub"/><category term="GCR"/><category term="Java"/><category term="Jenkins Videos"/><category term="Kasten K10"/><category term="Linux Cluster"/><category term="Minikube"/><category term="Outsystems"/><category term="Postgres"/><category term="ProFTPd"/><category term="Puppet Videos"/><category term="Rancher"/><category term="Scripting"/><category term="Serv-U FTP"/><category term="Storage Basics"/><category term="Veritas Cluster"/><category term="AWS EKS"/><category term="ChatGPT"/><category term="Cinnamon"/><category term="Elasticsearch"/><category term="GKE"/><category term="Google Kubernetes Engine"/><category term="Mac"/><category term="Magento"/><category term="Magento 2"/><category term="MobaXterm"/><category term="MongoDB"/><category term="Oracle"/><category term="Oracle Container Engine"/><category term="Portainer"/><category term="Prometheus"/><category term="Windows 10"/><category term="Windows 11"/><category term="AWS Videos"/><category term="Cluster Basics"/><category term="DRBD Cluster"/><category term="Database"/><category term="Gatekeeper"/><category term="HPUX"/><category term="HPUX Howto"/><category term="Kubernetes Interview Questions"/><category term="Mint"/><category term="Nginx"/><category term="NodeJS"/><category term="OPA Gatekeeper"/><category term="Podman"/><category term="RedHat"/><category term="Veritas Volume Manager"/><category term="Vmware"/><category term="Artifactory"/><category term="CKA"/><category term="CertManager"/><category term="Certified Kubernetes Administrator"/><category term="Deep Learning"/><category term="Devops Interview Questions"/><category term="Fedora"/><category term="Fedora 37"/><category term="Grafana"/><category term="HP Serviceguard Cluster"/><category term="Istio"/><category term="Kasten"/><category term="Kvm"/><category term="LVM Tutorials"/><category term="Linux Interview Questions and Answers"/><category term="Nagios"/><category term="Nutanix"/><category term="Nutanix Karbon"/><category term="OpenShift"/><category term="Airflow"/><category term="Amazon Web Services"/><category term="Apache Kafka"/><category term="Azure"/><category term="Calico"/><category term="Debian"/><category term="Docker Interview Questions"/><category term="Docker free eBooks"/><category term="ELK Stack"/><category term="Flink"/><category term="Free eBooks"/><category term="Git Interview Questions"/><category term="IBM"/><category term="IBM Cloud"/><category term="K8s"/><category term="Kafka"/><category term="Kibana"/><category term="Kustomize"/><category term="Linux Academy"/><category term="Linux Commands"/><category term="Linux Mint 20"/><category term="Logstash"/><category term="MLflow"/><category term="MicroK8s"/><category term="MySQL"/><category term="RabbitMQ"/><category term="Redhat Cluster"/><category term="Redis"/><category term="Redis Cluster"/><category term="Sensu"/><category term="Solaris Howto"/><category term="Sysdig"/><category term="Velero"/><category term="Wordpress"/><title type='text'>Learnitguide.net - Learn Linux, DevOps and Cloud</title><subtitle type='html'>Get How To, Tutorials, Training, Step by Step procedures of Linux, Ubuntu, Redhat, DevOps, Cloud, AWS, Docker, Kubernetes, Jenkins, Python, Shell Scripting, Linux Tutorials, DevOps Tutorials, Jenkins Tutorials, Kubernetes Tutorials, Docker Tutorials, Ansible Tutorials, AWS Tutorials, Ubuntu Tutorials, Ansible Full Course, Docker Full Course, Kubernetes Full Course, Linux Full Course</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://www.learnitguide.net/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default?start-index=26&amp;max-results=25'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>951</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-8087569230120240037</id><published>2026-03-11T07:54:00.000-07:00</published><updated>2026-03-12T23:35:08.419-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Artificial Intelligence"/><category scheme="http://www.blogger.com/atom/ns#" term="Machine Learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="Python Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Python Pandas Tutorial: Basics to Advanced Guide</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhokC6ErI6y58b2xpdN5ip7xSoc9UaTEjARgigSWonAmr6r5jbec_amAHUdfBKzEoZWlJBgcrYFUSOmDUdwSfsb1FKi4jBeCjN-IWBX8gX9A6BCcyBzUfgIi8nV_95ZAlVHCR0HCph8w-XMrPglDVvjXmV2RTPF5zUNC-SmzyqEWr-jMHscvCJjAE9LsfNM/s1280/Python%20Pandas%20Full%20Tutorial.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Python Pandas Tutorial: Basics to Advanced Guide&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhokC6ErI6y58b2xpdN5ip7xSoc9UaTEjARgigSWonAmr6r5jbec_amAHUdfBKzEoZWlJBgcrYFUSOmDUdwSfsb1FKi4jBeCjN-IWBX8gX9A6BCcyBzUfgIi8nV_95ZAlVHCR0HCph8w-XMrPglDVvjXmV2RTPF5zUNC-SmzyqEWr-jMHscvCJjAE9LsfNM/w400-h225/Python%20Pandas%20Full%20Tutorial.png&quot; title=&quot;Python Pandas Tutorial: Basics to Advanced Guide&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Before reading this post, make sure you have a good understanding of Python basics - variables, data types, loops, functions, and lists. You should also have basic knowledge of NumPy, since Pandas is built on top of it. If you have not covered NumPy yet, go through the NumPy tutorial post first and then come back here.&lt;/p&gt;

&lt;p&gt;This tutorial works on both VS Code and Google Colab. NumPy and Pandas must be installed on your system before running any code in this post.&lt;/p&gt;

&lt;p&gt;Pandas is one of the most widely used Python libraries in data science and data analysis. Whether you are cleaning data, analysing trends, preparing datasets for machine learning, or generating reports - Pandas is the tool that gets the job done.&lt;/p&gt;

&lt;p&gt;In this post, we are going to cover Pandas from scratch - creating Series and DataFrames, loading real data, inspecting it, filtering, sorting, grouping, merging, and exporting - all with real code and real output. By the end of this post you will have a solid understanding of how Pandas works and how to use it in real projects.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;You can also watch this tutorial in youtube.&lt;/span&gt;&lt;/p&gt;

&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; src=&quot;https://www.youtube.com/embed/7wDTbooHyF0?si=Z7SAoIFwf_ubqEOL&quot; title=&quot;YouTube video player&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;

&lt;h2&gt;What is Pandas?&lt;/h2&gt;

&lt;p&gt;Pandas stands for Panel Data. It is an open source Python library built for data manipulation and analysis. It was originally developed for financial data analysis and later adopted across the entire data science community.&lt;/p&gt;

&lt;p&gt;The simplest way to understand Pandas is to think of it as Excel inside Python - but far more powerful. You can handle millions of rows, automate repetitive tasks, connect to databases, read from CSV and Excel files, and perform complex transformations - all in a few lines of code.&lt;/p&gt;

&lt;h2&gt;Installing and Importing Pandas&lt;/h2&gt;

&lt;p&gt;If you are using VS Code, open your terminal and run:&lt;/p&gt;

&lt;pre&gt;pip install pandas&lt;/pre&gt;

&lt;p&gt;If you are using Google Colab, Pandas is already available. No installation is needed.&lt;/p&gt;

&lt;p&gt;At the top of every Python file or notebook, always import Pandas and NumPy like this:&lt;/p&gt;

&lt;pre&gt;import pandas as pd
import numpy as np&lt;/pre&gt;

&lt;p&gt;The alias &lt;code&gt;pd&lt;/code&gt; is the universal convention for Pandas. Use it in every project.&lt;/p&gt;

&lt;h2&gt;Pandas Series&lt;/h2&gt;

&lt;p&gt;A Series is a one-dimensional labelled array. Think of it as a single column from a spreadsheet - with an index on the left and values on the right.&lt;/p&gt;

&lt;pre&gt;import pandas as pd

s = pd.Series([10, 20, 30, 40, 50])
print(s)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;0    10
1    20
2    30
3    40
4    50
dtype: int64&lt;/pre&gt;

&lt;p&gt;You can create a Series with custom labels instead of default numeric index:&lt;/p&gt;

&lt;pre&gt;scores = pd.Series([85, 90, 78, 95], index=[&#39;Maths&#39;, &#39;Science&#39;, &#39;English&#39;, &#39;History&#39;])
print(scores)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;Maths      85
Science    90
English    78
History    95
dtype: int64&lt;/pre&gt;

&lt;p&gt;Accessing values from a Series:&lt;/p&gt;

&lt;pre&gt;print(scores[&#39;Science&#39;])    # Access by label
print(scores[scores &amp;gt; 85])  # Boolean filtering&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;90

Science    90
History    95
dtype: int64&lt;/pre&gt;

&lt;p&gt;Creating a Series from a dictionary:&lt;/p&gt;

&lt;pre&gt;data = {&#39;Monday&#39;: 200, &#39;Tuesday&#39;: 350, &#39;Wednesday&#39;: 300}
sales = pd.Series(data)
print(sales)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;Monday       200
Tuesday      350
Wednesday    300
dtype: int64&lt;/pre&gt;

&lt;h2&gt;Pandas DataFrame&lt;/h2&gt;

&lt;p&gt;A DataFrame is a two-dimensional table with rows and columns. This is the main data structure you will use in almost every Pandas project. Think of it as a full spreadsheet or a database table.&lt;/p&gt;

&lt;pre&gt;data = {
    &#39;Name&#39;:   [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;, &#39;Diana&#39;, &#39;Eve&#39;],
    &#39;Age&#39;:    [25, 30, 35, 28, 22],
    &#39;City&#39;:   [&#39;Mumbai&#39;, &#39;Delhi&#39;, &#39;Chennai&#39;, &#39;Pune&#39;, &#39;Hyderabad&#39;],
    &#39;Salary&#39;: [50000, 70000, 65000, 80000, 45000]
}

df = pd.DataFrame(data)
print(df)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;      Name  Age       City  Salary
0    Alice   25     Mumbai   50000
1      Bob   30      Delhi   70000
2  Charlie   35    Chennai   65000
3    Diana   28       Pune   80000
4      Eve   22  Hyderabad   45000&lt;/pre&gt;

&lt;p&gt;Accessing a single column:&lt;/p&gt;

&lt;pre&gt;print(df[&#39;Name&#39;])&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;0      Alice
1        Bob
2    Charlie
3      Diana
4        Eve
Name: Name, dtype: object&lt;/pre&gt;

&lt;p&gt;Accessing multiple columns:&lt;/p&gt;

&lt;pre&gt;print(df[[&#39;Name&#39;, &#39;Salary&#39;]])&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;      Name  Salary
0    Alice   50000
1      Bob   70000
2  Charlie   65000
3    Diana   80000
4      Eve   45000&lt;/pre&gt;

&lt;h2&gt;Loading Data from Files&lt;/h2&gt;

&lt;p&gt;In real projects you will load data from external files rather than creating DataFrames manually.&lt;/p&gt;

&lt;pre&gt;# Load from CSV
df = pd.read_csv(&#39;sales_data.csv&#39;)

# Load from Excel
df = pd.read_excel(&#39;sales_data.xlsx&#39;)

# Load from JSON
df = pd.read_json(&#39;data.json&#39;)&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;read_csv()&lt;/code&gt; function is the most commonly used. One line is all it takes to load an entire file into a DataFrame.&lt;/p&gt;

&lt;h2&gt;Inspecting Your Data&lt;/h2&gt;

&lt;p&gt;After loading a dataset, the first step is always to inspect it before making any changes.&lt;/p&gt;

&lt;pre&gt;df.head()       # First 5 rows
df.tail()       # Last 5 rows
df.shape        # (rows, columns)
df.columns      # List of column names
df.dtypes       # Data type of each column
df.info()       # Full summary
df.describe()   # Statistical summary&lt;/pre&gt;

&lt;p&gt;Running &lt;code&gt;df.info()&lt;/code&gt; on the sample dataset:&lt;/p&gt;

&lt;pre&gt;df.info()&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;&amp;lt;class &#39;pandas.core.frame.DataFrame&#39;&amp;gt;
RangeIndex: 5 entries, 0 to 4
Data columns (total 4 columns):
 #   Column  Non-Null Count  Dtype
---  ------  --------------  -----
 0   Name    5 non-null      object
 1   Age     5 non-null      int64
 2   City    5 non-null      object
 3   Salary  5 non-null      int64
dtypes: int64(2), object(2)&lt;/pre&gt;

&lt;p&gt;Running &lt;code&gt;df.describe()&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;df.describe()&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;             Age        Salary
count   5.000000      5.000000
mean   28.000000  62000.000000
std     4.848       13600.000
min    22.000000  45000.000000
25%    25.000000  50000.000000
50%    28.000000  65000.000000
75%    30.000000  70000.000000
max    35.000000  80000.000000&lt;/pre&gt;

&lt;h2&gt;Indexing with loc and iloc&lt;/h2&gt;

&lt;p&gt;Pandas provides two ways to access specific rows and columns.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;iloc&lt;/code&gt; - access by position (row number, column number):&lt;/p&gt;

&lt;pre&gt;print(df.iloc[0])           # First row
print(df.iloc[2, 3])        # Row 2, Column 3
print(df.iloc[0:3, :])      # First 3 rows, all columns&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;Name      Alice
Age          25
City     Mumbai
Salary    50000
Name: 0, dtype: object

65000

      Name  Age     City  Salary
0    Alice   25   Mumbai   50000
1      Bob   30    Delhi   70000
2  Charlie   35  Chennai   65000&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;loc&lt;/code&gt; - access by label (row label and column name):&lt;/p&gt;

&lt;pre&gt;print(df.loc[0, &#39;Name&#39;])
print(df.loc[1:3, [&#39;Name&#39;, &#39;Salary&#39;]])&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;Alice

      Name  Salary
1      Bob   70000
2  Charlie   65000
3    Diana   80000&lt;/pre&gt;

&lt;h2&gt;Filtering Data&lt;/h2&gt;

&lt;p&gt;Rows can be filtered based on conditions without writing any loop.&lt;/p&gt;

&lt;pre&gt;# Salary greater than 60000
high_earners = df[df[&#39;Salary&#39;] &amp;gt; 60000]
print(high_earners)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;      Name  Age     City  Salary
1      Bob   30    Delhi   70000
2  Charlie   35  Chennai   65000
3    Diana   28     Pune   80000&lt;/pre&gt;

&lt;p&gt;Multiple conditions using &lt;code&gt;&amp;amp;&lt;/code&gt; for AND and &lt;code&gt;|&lt;/code&gt; for OR:&lt;/p&gt;

&lt;pre&gt;# Salary &amp;gt; 60000 AND Age &amp;lt; 32
filtered = df[(df[&#39;Salary&#39;] &amp;gt; 60000) &amp;amp; (df[&#39;Age&#39;] &amp;lt; 32)]
print(filtered)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;    Name  Age   City  Salary
1    Bob   30  Delhi   70000
3  Diana   28   Pune   80000&lt;/pre&gt;

&lt;p&gt;Using &lt;code&gt;isin()&lt;/code&gt; to filter by a list of values:&lt;/p&gt;

&lt;pre&gt;selected = df[df[&#39;City&#39;].isin([&#39;Mumbai&#39;, &#39;Pune&#39;])]
print(selected)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;    Name  Age    City  Salary
0  Alice   25  Mumbai   50000
3  Diana   28    Pune   80000&lt;/pre&gt;

&lt;p&gt;Using &lt;code&gt;str.contains()&lt;/code&gt; for text matching:&lt;/p&gt;

&lt;pre&gt;result = df[df[&#39;Name&#39;].str.contains(&#39;a&#39;, case=False)]
print(result)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;      Name  Age     City  Salary
0    Alice   25   Mumbai   50000
2  Charlie   35  Chennai   65000
3    Diana   28     Pune   80000&lt;/pre&gt;

&lt;h2&gt;Adding, Renaming and Dropping Columns&lt;/h2&gt;

&lt;p&gt;Adding new columns to a DataFrame:&lt;/p&gt;

&lt;pre&gt;df[&#39;Tax&#39;] = df[&#39;Salary&#39;] * 0.10
df[&#39;Net Salary&#39;] = df[&#39;Salary&#39;] - df[&#39;Tax&#39;]
print(df[[&#39;Name&#39;, &#39;Salary&#39;, &#39;Tax&#39;, &#39;Net Salary&#39;]])&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;      Name  Salary     Tax  Net Salary
0    Alice   50000  5000.0     45000.0
1      Bob   70000  7000.0     63000.0
2  Charlie   65000  6500.0     58500.0
3    Diana   80000  8000.0     72000.0
4      Eve   45000  4500.0     40500.0&lt;/pre&gt;

&lt;p&gt;Renaming columns:&lt;/p&gt;

&lt;pre&gt;df.rename(columns={&#39;Name&#39;: &#39;Employee&#39;, &#39;Salary&#39;: &#39;Gross Salary&#39;}, inplace=True)
print(df.columns)&lt;/pre&gt;

&lt;p&gt;Dropping a column:&lt;/p&gt;

&lt;pre&gt;df.drop(columns=[&#39;Tax&#39;], inplace=True)&lt;/pre&gt;

&lt;p&gt;Dropping a row by index:&lt;/p&gt;

&lt;pre&gt;df.drop(index=2, inplace=True)&lt;/pre&gt;

&lt;h2&gt;Sorting Data&lt;/h2&gt;

&lt;pre&gt;# Sort by Salary ascending
df_sorted = df.sort_values(&#39;Salary&#39;)
print(df_sorted)

# Sort by Salary descending
df_sorted_desc = df.sort_values(&#39;Salary&#39;, ascending=False)
print(df_sorted_desc)

# Sort by multiple columns
df_multi = df.sort_values([&#39;City&#39;, &#39;Salary&#39;], ascending=[True, False])
print(df_multi)

# Reset index after sorting
df_sorted = df.sort_values(&#39;Salary&#39;).reset_index(drop=True)
print(df_sorted)&lt;/pre&gt;

&lt;h2&gt;GroupBy Operations&lt;/h2&gt;

&lt;p&gt;GroupBy allows you to split data into groups, apply a function to each group, and combine the results.&lt;/p&gt;

&lt;pre&gt;data = {
    &#39;Department&#39;: [&#39;HR&#39;, &#39;Tech&#39;, &#39;HR&#39;, &#39;Tech&#39;, &#39;Finance&#39;, &#39;Finance&#39;, &#39;Tech&#39;],
    &#39;Employee&#39;:   [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;, &#39;Diana&#39;, &#39;Eve&#39;, &#39;Frank&#39;, &#39;Grace&#39;],
    &#39;Salary&#39;:     [50000, 90000, 55000, 95000, 70000, 72000, 85000],
    &#39;Experience&#39;: [3, 7, 4, 9, 5, 6, 8]
}

df3 = pd.DataFrame(data)

# Average salary by department
print(df3.groupby(&#39;Department&#39;)[&#39;Salary&#39;].mean())&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;Department
Finance    71000.0
HR         52500.0
Tech       90000.0
Name: Salary, dtype: float64&lt;/pre&gt;

&lt;p&gt;Multiple aggregations at once using &lt;code&gt;agg()&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;result = df3.groupby(&#39;Department&#39;).agg(
    Avg_Salary=(&#39;Salary&#39;, &#39;mean&#39;),
    Max_Salary=(&#39;Salary&#39;, &#39;max&#39;),
    Total_Employees=(&#39;Employee&#39;, &#39;count&#39;)
)
print(result)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;            Avg_Salary  Max_Salary  Total_Employees
Department
Finance      71000.0       72000             2
HR           52500.0       55000             2
Tech         90000.0       95000             3&lt;/pre&gt;

&lt;h2&gt;Merging and Joining DataFrames&lt;/h2&gt;

&lt;p&gt;In real projects data is often spread across multiple tables. Pandas provides &lt;code&gt;merge()&lt;/code&gt; to combine them - similar to SQL joins.&lt;/p&gt;

&lt;pre&gt;employees = pd.DataFrame({
    &#39;EmpID&#39;:  [1, 2, 3, 4],
    &#39;Name&#39;:   [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;, &#39;Diana&#39;],
    &#39;DeptID&#39;: [101, 102, 101, 103]
})

departments = pd.DataFrame({
    &#39;DeptID&#39;:   [101, 102, 103],
    &#39;DeptName&#39;: [&#39;HR&#39;, &#39;Tech&#39;, &#39;Finance&#39;]
})

# Inner join
merged = pd.merge(employees, departments, on=&#39;DeptID&#39;, how=&#39;inner&#39;)
print(merged)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;   EmpID     Name  DeptID DeptName
0      1    Alice     101       HR
1      3  Charlie     101       HR
2      2      Bob     102     Tech
3      4    Diana     103  Finance&lt;/pre&gt;

&lt;p&gt;Other join types:&lt;/p&gt;

&lt;pre&gt;pd.merge(employees, departments, on=&#39;DeptID&#39;, how=&#39;left&#39;)   # Left join
pd.merge(employees, departments, on=&#39;DeptID&#39;, how=&#39;right&#39;)  # Right join
pd.merge(employees, departments, on=&#39;DeptID&#39;, how=&#39;outer&#39;)  # Outer join&lt;/pre&gt;

&lt;p&gt;Stacking DataFrames vertically using &lt;code&gt;concat()&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;df_new = pd.DataFrame({
    &#39;EmpID&#39;: [5, 6],
    &#39;Name&#39;:  [&#39;Eve&#39;, &#39;Frank&#39;],
    &#39;DeptID&#39;: [102, 101]
})

df_combined = pd.concat([employees, df_new], ignore_index=True)
print(df_combined)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;   EmpID     Name  DeptID
0      1    Alice     101
1      2      Bob     102
2      3  Charlie     101
3      4    Diana     103
4      5      Eve     102
5      6    Frank     101&lt;/pre&gt;

&lt;h2&gt;Apply Function&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;apply()&lt;/code&gt; function lets you apply any custom logic to a column row by row.&lt;/p&gt;

&lt;pre&gt;def salary_category(sal):
    if sal &amp;lt; 55000:
        return &#39;Low&#39;
    elif sal &amp;lt; 75000:
        return &#39;Medium&#39;
    else:
        return &#39;High&#39;

df3[&#39;Salary_Category&#39;] = df3[&#39;Salary&#39;].apply(salary_category)
print(df3[[&#39;Employee&#39;, &#39;Salary&#39;, &#39;Salary_Category&#39;]])&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;  Employee  Salary Salary_Category
0    Alice   50000             Low
1      Bob   90000            High
2  Charlie   55000          Medium
3    Diana   95000            High
4      Eve   70000          Medium
5    Frank   72000          Medium
6    Grace   85000            High&lt;/pre&gt;

&lt;p&gt;Using a lambda function for quick one-line operations:&lt;/p&gt;

&lt;pre&gt;df3[&#39;Salary_in_Lakhs&#39;] = df3[&#39;Salary&#39;].apply(lambda x: round(x / 100000, 2))
print(df3[[&#39;Employee&#39;, &#39;Salary&#39;, &#39;Salary_in_Lakhs&#39;]])&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;  Employee  Salary  Salary_in_Lakhs
0    Alice   50000             0.50
1      Bob   90000             0.90
2  Charlie   55000             0.55
3    Diana   95000             0.95
4      Eve   70000             0.70
5    Frank   72000             0.72
6    Grace   85000             0.85&lt;/pre&gt;

&lt;h2&gt;Pivot Tables&lt;/h2&gt;

&lt;pre&gt;data = {
    &#39;Region&#39;:   [&#39;North&#39;, &#39;South&#39;, &#39;North&#39;, &#39;East&#39;, &#39;South&#39;, &#39;East&#39;],
    &#39;Product&#39;:  [&#39;A&#39;, &#39;B&#39;, &#39;A&#39;, &#39;B&#39;, &#39;A&#39;, &#39;A&#39;],
    &#39;Sales&#39;:    [200, 150, 300, 250, 180, 220],
    &#39;Quantity&#39;: [20, 15, 30, 25, 18, 22]
}

df4 = pd.DataFrame(data)

pivot = pd.pivot_table(df4,
                       values=&#39;Sales&#39;,
                       index=&#39;Region&#39;,
                       columns=&#39;Product&#39;,
                       aggfunc=&#39;sum&#39;,
                       fill_value=0)
print(pivot)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;Product  A    B
Region
East   220  250
North  500    0
South  180  150&lt;/pre&gt;

&lt;h2&gt;Exporting Data&lt;/h2&gt;

&lt;pre&gt;# Export to CSV
df.to_csv(&#39;output.csv&#39;, index=False)

# Export to Excel
df.to_excel(&#39;output.xlsx&#39;, index=False)

# Export to JSON
df.to_json(&#39;output.json&#39;, orient=&#39;records&#39;)&lt;/pre&gt;

&lt;p&gt;Setting &lt;code&gt;index=False&lt;/code&gt; prevents the row index from being written into the output file. This is almost always the preferred option.&lt;/p&gt;

&lt;h2&gt;Quick Command Reference&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;pd.Series()&lt;/code&gt; - Create a Series&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;pd.DataFrame()&lt;/code&gt; - Create a DataFrame&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;pd.read_csv()&lt;/code&gt; - Load CSV file&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.head()&lt;/code&gt; - First 5 rows&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.tail()&lt;/code&gt; - Last 5 rows&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.info()&lt;/code&gt; - Column info and data types&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.describe()&lt;/code&gt; - Statistical summary&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.shape&lt;/code&gt; - Dimensions of DataFrame&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.dtypes&lt;/code&gt; - Data type of each column&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.iloc[]&lt;/code&gt; - Access by position&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.loc[]&lt;/code&gt; - Access by label&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df[condition]&lt;/code&gt; - Filter rows&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.isin()&lt;/code&gt; - Filter by list of values&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.sort_values()&lt;/code&gt; - Sort rows&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.groupby()&lt;/code&gt; - Group and aggregate&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.agg()&lt;/code&gt; - Multiple aggregations&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;pd.merge()&lt;/code&gt; - Join DataFrames&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;pd.concat()&lt;/code&gt; - Stack DataFrames&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.apply()&lt;/code&gt; - Apply custom function&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;pd.pivot_table()&lt;/code&gt; - Create pivot table&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.to_csv()&lt;/code&gt; - Export to CSV&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.to_excel()&lt;/code&gt; - Export to Excel&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.rename()&lt;/code&gt; - Rename columns&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.drop()&lt;/code&gt; - Drop rows or columns&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;df.reset_index()&lt;/code&gt; - Reset row index&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Key Takeaways&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Pandas is built on NumPy - understanding NumPy first makes Pandas much easier to learn&lt;/li&gt;
  &lt;li&gt;Series is a single column, DataFrame is a full table - these are the two core data structures&lt;/li&gt;
  &lt;li&gt;Always inspect your data with &lt;code&gt;head()&lt;/code&gt;, &lt;code&gt;info()&lt;/code&gt;, and &lt;code&gt;describe()&lt;/code&gt; before making any changes&lt;/li&gt;
  &lt;li&gt;Use &lt;code&gt;loc&lt;/code&gt; for label-based access and &lt;code&gt;iloc&lt;/code&gt; for position-based access&lt;/li&gt;
  &lt;li&gt;GroupBy and merge are the most powerful tools for real-world data analysis&lt;/li&gt;
  &lt;li&gt;Use &lt;code&gt;apply()&lt;/code&gt; to run any custom logic across rows or columns without writing a loop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All the code examples in this post are also covered in detail in the YouTube video. The link is available at the top of this page. If you have any questions, drop them in the comments section below.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/8087569230120240037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2026/03/python-pandas-tutorial-basics-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/8087569230120240037'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/8087569230120240037'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2026/03/python-pandas-tutorial-basics-to.html' title='Python Pandas Tutorial: Basics to Advanced Guide'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhokC6ErI6y58b2xpdN5ip7xSoc9UaTEjARgigSWonAmr6r5jbec_amAHUdfBKzEoZWlJBgcrYFUSOmDUdwSfsb1FKi4jBeCjN-IWBX8gX9A6BCcyBzUfgIi8nV_95ZAlVHCR0HCph8w-XMrPglDVvjXmV2RTPF5zUNC-SmzyqEWr-jMHscvCJjAE9LsfNM/s72-w400-h225-c/Python%20Pandas%20Full%20Tutorial.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-1358906230048713122</id><published>2026-03-11T07:41:00.000-07:00</published><updated>2026-03-11T07:43:54.080-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Artificial Intelligence"/><category scheme="http://www.blogger.com/atom/ns#" term="Machine Learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="Python Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Python NumPy Tutorial: Basics to Advanced Guide</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEcqkrK8203sInM1PepSWvGtA-aGr1DDggMgjhtIX5WnOdsnbCGzgTEkyZI3qko7UWOdvdR3KTBLT2dDpN1mCKBOji5MymKkTKDK_eks__yPvTIiiAPBgWNGGiX-iDGt0kXo4Y8jjVX22cKSlzcrLyntKcnCwI_NWwV7C_HKELx1CgzCPX15V_V4t3VnyZ/s1280/python%20numpy%20tutorial.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Python NumPy Tutorial: Basics to Advanced Guide&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEcqkrK8203sInM1PepSWvGtA-aGr1DDggMgjhtIX5WnOdsnbCGzgTEkyZI3qko7UWOdvdR3KTBLT2dDpN1mCKBOji5MymKkTKDK_eks__yPvTIiiAPBgWNGGiX-iDGt0kXo4Y8jjVX22cKSlzcrLyntKcnCwI_NWwV7C_HKELx1CgzCPX15V_V4t3VnyZ/w400-h225/python%20numpy%20tutorial.png&quot; title=&quot;Python NumPy Tutorial: Basics to Advanced Guide&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Before reading this post, make sure you have basic knowledge of Python programming. You should be comfortable with variables, data types, loops, and functions. If you are new to Python, go through a Python basics tutorial first and then come back to this post.&lt;/p&gt;

&lt;p&gt;You should also have Python installed on your system. This tutorial works on both VS Code and Google Colab.&lt;/p&gt;&lt;p&gt;If you are working with data in Python, sooner or later you will come across NumPy. Almost every data science and machine learning library in Python - Pandas, TensorFlow, PyTorch, Scikit-learn - is built on top of NumPy. So understanding NumPy properly gives you a very strong foundation for everything else that comes after it.&lt;/p&gt;

&lt;p&gt;In this post, we are going to cover NumPy from the basics all the way to advanced concepts - with real code and real output at every step. By the end of this post you will know how to create arrays, perform operations, reshape data, and use advanced techniques like broadcasting and boolean masking.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;You can also watch this tutorial in youtube.&lt;/span&gt;&lt;/p&gt;


&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; src=&quot;https://www.youtube.com/embed/7rTpeys5oqQ?si=Z7SAoIFwf_ubqEOL&quot; title=&quot;YouTube video player&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;h2&gt;What is NumPy?&lt;/h2&gt;

&lt;p&gt;NumPy stands for Numerical Python. It is an open source library built specifically for numerical computation in Python. The core feature of NumPy is the ndarray - an N-dimensional array - which allows you to store and operate on large amounts of numerical data very efficiently.&lt;/p&gt;

&lt;p&gt;The biggest difference between a Python list and a NumPy array is speed and efficiency. A Python list can hold mixed data types - strings, numbers, objects - all in one list. Because of this, Python has to check the type of every element before performing any operation. That takes time.&lt;/p&gt;

&lt;p&gt;A NumPy array holds only one data type. So operations are performed directly without any type checking. This makes NumPy significantly faster than regular Python lists for numerical work - sometimes 50 times faster on large datasets.&lt;/p&gt;

&lt;h2&gt;Installing NumPy&lt;/h2&gt;

&lt;p&gt;If you are using VS Code, open your terminal and run the following command:&lt;/p&gt;

&lt;pre&gt;pip install numpy&lt;/pre&gt;

&lt;p&gt;If you are using Google Colab, NumPy is already installed. You can directly import it.&lt;/p&gt;

&lt;p&gt;To import NumPy in your Python file or notebook, always use this line:&lt;/p&gt;

&lt;pre&gt;import numpy as np&lt;/pre&gt;

&lt;p&gt;The alias &lt;code&gt;np&lt;/code&gt; is a universal convention. Every data scientist and machine learning engineer in the world uses &lt;code&gt;np&lt;/code&gt; for NumPy. So follow this same convention in all your projects.&lt;/p&gt;

&lt;h2&gt;Creating NumPy Arrays&lt;/h2&gt;

&lt;p&gt;The most basic thing you can do in NumPy is create an array. Let us start with a simple one-dimensional array:&lt;/p&gt;

&lt;pre&gt;import numpy as np

a = np.array([10, 20, 30, 40, 50])
print(a)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[10 20 30 40 50]&lt;/pre&gt;

&lt;p&gt;A two-dimensional array - which is like a table with rows and columns - is created like this:&lt;/p&gt;

&lt;pre&gt;b = np.array([[1, 2, 3], [4, 5, 6]])
print(b)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[[1 2 3]
 [4 5 6]]&lt;/pre&gt;

&lt;p&gt;NumPy also provides shortcut functions to create arrays without typing every value manually:&lt;/p&gt;

&lt;pre&gt;# Array of all zeros
print(np.zeros((3, 3)))

# Array of all ones
print(np.ones((2, 4)))

# Range of numbers with a step
print(np.arange(0, 10, 2))

# Evenly spaced numbers between two values
print(np.linspace(0, 1, 5))

# Random values between 0 and 1
print(np.random.rand(3, 3))&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]

[[1. 1. 1. 1.]
 [1. 1. 1. 1.]]

[0 2 4 6 8]

[0.   0.25 0.5  0.75 1.  ]

[[0.37 0.95 0.73]
 [0.60 0.15 0.86]
 [0.71 0.02 0.97]]&lt;/pre&gt;

&lt;h2&gt;Array Properties&lt;/h2&gt;

&lt;p&gt;Every NumPy array has properties that describe its structure. These are checked constantly when working with real data.&lt;/p&gt;

&lt;pre&gt;a = np.array([[1, 2, 3], [4, 5, 6]])

print(a.shape)   # Dimensions
print(a.ndim)    # Number of dimensions
print(a.size)    # Total number of elements
print(a.dtype)   # Data type of elements&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;(2, 3)
2
6
int64&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;shape&lt;/code&gt; property is especially important. Shape mismatches are the most common source of errors in machine learning code. Always check &lt;code&gt;.shape&lt;/code&gt; on your arrays before and after every operation.&lt;/p&gt;

&lt;h2&gt;Indexing and Slicing&lt;/h2&gt;

&lt;p&gt;Accessing specific elements or ranges from a NumPy array works as follows:&lt;/p&gt;

&lt;pre&gt;a = np.array([10, 20, 30, 40, 50])

print(a[0])     # First element
print(a[-1])    # Last element
print(a[1:4])   # Elements at index 1, 2, 3&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;10
50
[20 30 40]&lt;/pre&gt;

&lt;p&gt;For two-dimensional arrays:&lt;/p&gt;

&lt;pre&gt;b = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

print(b[1, 2])    # Row 1, Column 2
print(b[:, 1])    # All rows, Column 1
print(b[0:2, :])  # First 2 rows, all columns&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;6
[2 5 8]
[[1 2 3]
 [4 5 6]]&lt;/pre&gt;

&lt;h2&gt;Math Operations&lt;/h2&gt;

&lt;p&gt;All basic math operations in NumPy are element-wise by default. This means the operation is applied to each pair of elements automatically - no loop required.&lt;/p&gt;

&lt;pre&gt;a = np.array([1, 2, 3])
b = np.array([4, 5, 6])

print(a + b)       # Addition
print(a * b)       # Multiplication
print(a - b)       # Subtraction
print(a / b)       # Division
print(np.dot(a, b))  # Dot product&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[5 7 9]
[ 4 10 18]
[-3 -3 -3]
[0.25 0.4  0.5 ]
32&lt;/pre&gt;

&lt;h2&gt;Broadcasting&lt;/h2&gt;

&lt;p&gt;Broadcasting is one of the most powerful features of NumPy. It allows operations to be performed between arrays of different shapes without writing any extra code.&lt;/p&gt;

&lt;p&gt;For example, adding a single number to every element of a two-dimensional array:&lt;/p&gt;

&lt;pre&gt;a = np.array([[1, 2, 3], [4, 5, 6]])
print(a + 10)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[[11 12 13]
 [14 15 16]]&lt;/pre&gt;

&lt;p&gt;NumPy automatically stretches the value 10 across every element in the array. This is called broadcasting. It is used in normalisation, feature scaling, and image processing.&lt;/p&gt;

&lt;p&gt;Broadcasting also works between arrays of compatible shapes:&lt;/p&gt;

&lt;pre&gt;a = np.array([[1, 2, 3], [4, 5, 6]])
b = np.array([10, 20, 30])
print(a + b)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[[11 22 33]
 [14 25 36]]&lt;/pre&gt;

&lt;h2&gt;Reshaping and Transposing&lt;/h2&gt;

&lt;p&gt;The shape of an array can be changed using &lt;code&gt;reshape()&lt;/code&gt;. The total number of elements must remain the same.&lt;/p&gt;

&lt;pre&gt;a = np.arange(12)
print(a)

b = a.reshape(3, 4)
print(b)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[ 0  1  2  3  4  5  6  7  8  9 10 11]

[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]&lt;/pre&gt;

&lt;p&gt;Transposing - swapping rows and columns - is done with &lt;code&gt;.T&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;print(b.T)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[[ 0  4  8]
 [ 1  5  9]
 [ 2  6 10]
 [ 3  7 11]]&lt;/pre&gt;

&lt;h2&gt;Advanced NumPy&lt;/h2&gt;

&lt;h3&gt;Fancy Indexing&lt;/h3&gt;

&lt;p&gt;Multiple specific elements can be extracted at once by passing a list of indices:&lt;/p&gt;

&lt;pre&gt;a = np.array([10, 20, 30, 40, 50])
print(a[[0, 2, 4]])&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[10 30 50]&lt;/pre&gt;

&lt;h3&gt;Boolean Masking&lt;/h3&gt;

&lt;p&gt;Elements that satisfy a condition can be filtered in a single line:&lt;/p&gt;

&lt;pre&gt;a = np.array([3, 7, 1, 9, 4, 6])
print(a[a &amp;gt; 5])&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[7 9 6]&lt;/pre&gt;

&lt;h3&gt;Stacking Arrays&lt;/h3&gt;

&lt;pre&gt;a = np.array([1, 2, 3])
b = np.array([4, 5, 6])

print(np.vstack([a, b]))   # Vertical stack
print(np.hstack([a, b]))   # Horizontal stack&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[[1 2 3]
 [4 5 6]]

[1 2 3 4 5 6]&lt;/pre&gt;

&lt;h3&gt;Statistical Functions&lt;/h3&gt;

&lt;pre&gt;a = np.array([[1, 2, 3], [4, 5, 6]])

print(np.mean(a))           # Overall mean
print(np.sum(a, axis=0))    # Sum down columns
print(np.sum(a, axis=1))    # Sum across rows
print(np.max(a))            # Maximum value
print(np.min(a))            # Minimum value
print(np.std(a))            # Standard deviation&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;3.5
[5 7 9]
[ 6 15]
6
1
1.707&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;axis&lt;/code&gt; parameter controls the direction of the operation. &lt;code&gt;axis=0&lt;/code&gt; runs down the rows (column-wise). &lt;code&gt;axis=1&lt;/code&gt; runs across the columns (row-wise).&lt;/p&gt;

&lt;h3&gt;np.where()&lt;/h3&gt;

&lt;p&gt;A conditional replacement can be applied across an entire array at once:&lt;/p&gt;

&lt;pre&gt;a = np.array([3, 7, 1, 9, 4, 6])
result = np.where(a &amp;gt; 5, &#39;high&#39;, &#39;low&#39;)
print(result)&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[&#39;low&#39; &#39;high&#39; &#39;low&#39; &#39;high&#39; &#39;low&#39; &#39;high&#39;]&lt;/pre&gt;

&lt;h3&gt;np.unique() and np.sort()&lt;/h3&gt;

&lt;pre&gt;a = np.array([3, 1, 4, 1, 5, 9, 2, 6, 5])

print(np.unique(a))   # Unique values
print(np.sort(a))     # Sorted array&lt;/pre&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;[1 2 3 4 5 6 9]
[1 1 2 3 4 5 5 6 9]&lt;/pre&gt;

&lt;h2&gt;Quick Command Reference&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;np.array()&lt;/code&gt; - Create an array from a list&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.zeros()&lt;/code&gt; - Array of zeros&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.ones()&lt;/code&gt; - Array of ones&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.arange()&lt;/code&gt; - Range of values with step&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.linspace()&lt;/code&gt; - Evenly spaced values&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.random.rand()&lt;/code&gt; - Random values&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;.shape&lt;/code&gt; - Dimensions of the array&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;.dtype&lt;/code&gt; - Data type of elements&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;.reshape()&lt;/code&gt; - Change array shape&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;.T&lt;/code&gt; - Transpose the array&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.dot()&lt;/code&gt; - Dot product&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.vstack()&lt;/code&gt; - Vertical stack&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.hstack()&lt;/code&gt; - Horizontal stack&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.where()&lt;/code&gt; - Conditional replacement&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.unique()&lt;/code&gt; - Unique values&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.sort()&lt;/code&gt; - Sort array&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;np.mean()&lt;/code&gt;, &lt;code&gt;np.sum()&lt;/code&gt;, &lt;code&gt;np.std()&lt;/code&gt; - Statistical functions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Key Takeaways&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;NumPy arrays are faster and more efficient than Python lists for numerical operations&lt;/li&gt;
  &lt;li&gt;Always check &lt;code&gt;.shape&lt;/code&gt; when debugging - shape mismatches are the most common error&lt;/li&gt;
  &lt;li&gt;Broadcasting removes the need for loops when performing operations on arrays of different sizes&lt;/li&gt;
  &lt;li&gt;Use boolean masking to filter data without writing any loop&lt;/li&gt;
  &lt;li&gt;NumPy is the foundation of Pandas, TensorFlow, PyTorch, and Scikit-learn&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All the code examples in this post are also covered in detail in the YouTube video. The link is available at the top of this page. If you have any questions, drop them in the comments section below.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/1358906230048713122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2026/03/python-numpy-tutorial-basics-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/1358906230048713122'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/1358906230048713122'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2026/03/python-numpy-tutorial-basics-to.html' title='Python NumPy Tutorial: Basics to Advanced Guide'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEcqkrK8203sInM1PepSWvGtA-aGr1DDggMgjhtIX5WnOdsnbCGzgTEkyZI3qko7UWOdvdR3KTBLT2dDpN1mCKBOji5MymKkTKDK_eks__yPvTIiiAPBgWNGGiX-iDGt0kXo4Y8jjVX22cKSlzcrLyntKcnCwI_NWwV7C_HKELx1CgzCPX15V_V4t3VnyZ/s72-w400-h225-c/python%20numpy%20tutorial.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-103557485818808329</id><published>2026-03-11T06:10:00.000-07:00</published><updated>2026-03-12T23:36:01.904-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Machine Learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><title type='text'>Python Pandas Data Cleaning &amp; Null Values Guide</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR5vYTmm9NtiDXMK17TW3TvoB6yxZXYyuC2N3l7Y38ZPerxrEllQBdpXIzHUepXHTaxWloWWfCaS-TkA-rcQWrGegXGOT4J6BJYGtIGdkFgvUnvKhvXTVjoWDnWTBTG5vdT9gMRLAD7zHCcP2B61v21ShcrZ4SP1hIRqthMfoTCsXeYbN_9aWKjJxvp8mx/s1280/Python%20Pandas%20Data%20Cleaning%20Explained.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Python Pandas Data Cleaning &amp;amp; Null Values Guide&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR5vYTmm9NtiDXMK17TW3TvoB6yxZXYyuC2N3l7Y38ZPerxrEllQBdpXIzHUepXHTaxWloWWfCaS-TkA-rcQWrGegXGOT4J6BJYGtIGdkFgvUnvKhvXTVjoWDnWTBTG5vdT9gMRLAD7zHCcP2B61v21ShcrZ4SP1hIRqthMfoTCsXeYbN_9aWKjJxvp8mx/w400-h225/Python%20Pandas%20Data%20Cleaning%20Explained.png&quot; title=&quot;Python Pandas Data Cleaning &amp;amp; Null Values Guide&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Every data science project starts with one unavoidable step - cleaning the data.&lt;/p&gt;
&lt;p&gt;Most beginners want to jump straight into analysis, building charts, or training machine learning models. But here is the reality: if the data going in is broken, the results coming out will be wrong. And the frustrating part is - the code will not always throw an error to warn you. It will just give you a number that looks correct but is not.&lt;/p&gt;
&lt;p&gt;That is what makes dirty data dangerous.&lt;/p&gt;
&lt;p&gt;In this post, we are going to work through the full data cleaning process using Python and Pandas - step by step, with real code and real output. By the end, you will know how to find missing values, remove duplicates, fix data types, and fill nulls using the right strategy for each column type.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;You can also watch this tutorial in youtube.&lt;/span&gt;&lt;/p&gt;

&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; src=&quot;https://www.youtube.com/embed/49MwmVFiOV0&quot; title=&quot;YouTube video player&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;What Is Dirty Data?&lt;/h2&gt;

&lt;p&gt;Dirty data is any dataset that contains errors, inconsistencies, or missing information that can affect the accuracy of your analysis.&lt;/p&gt;
&lt;p&gt;The three most common problems in real-world datasets are:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Missing values&lt;/strong&gt; - cells that are empty or contain NaN&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Duplicate rows&lt;/strong&gt; - the same record appearing more than once&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Wrong data types&lt;/strong&gt; - a numeric column stored as text, for example&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;None of these are rare. In production datasets - whether they come from databases, forms, APIs, or CSV exports - all three problems tend to show up together.&lt;/p&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;Setting Up the Environment&lt;/h2&gt;

&lt;p&gt;This tutorial works in both &lt;strong&gt;VS Code&lt;/strong&gt; and &lt;strong&gt;Google Colab&lt;/strong&gt;.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;VS Code:&lt;/strong&gt; Create a new file &lt;code&gt;data_cleaning.py&lt;/code&gt; and run it from the integrated terminal.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Google Colab:&lt;/strong&gt; Open &lt;a href=&quot;https://colab.research.google.com&quot; target=&quot;_blank&quot;&gt;colab.research.google.com&lt;/a&gt;, create a new notebook, and run each cell block by block.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Start every session with these two imports:&lt;/p&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;import pandas as pd
import numpy as np&lt;/pre&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;Step 1 - Load the Data and Spot the Problems&lt;/h2&gt;

&lt;p&gt;Before fixing anything, the first job is to see what you are working with. Below is a sample student dataset with intentional problems built in:&lt;/p&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;import pandas as pd
import numpy as np

data = {
    &#39;Name&#39;:  [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;, &#39;Bob&#39;, &#39;Diana&#39;, &#39;Eve&#39;],
    &#39;Age&#39;:   [22.0, None, 21.0, None, 23.0, 25.0],
    &#39;Score&#39;: [88.0, 92.0, None, 92.0, 79.0, None],
    &#39;Grade&#39;: [&#39;A&#39;, &#39;B&#39;, None, &#39;B&#39;, &#39;C&#39;, None]
}

df = pd.DataFrame(data)
print(df)&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;      Name   Age  Score Grade
0    Alice  22.0   88.0     A
1      Bob   NaN   92.0     B
2  Charlie  21.0    NaN  None
3      Bob   NaN   92.0     B
4    Diana  23.0   79.0     C
5      Eve  25.0    NaN  None&lt;/div&gt;

&lt;p&gt;Problems visible at a glance:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Row 1 and Row 3 are exact duplicates - Bob appears twice&lt;/li&gt;
  &lt;li&gt;Age is missing in rows 1 and 3&lt;/li&gt;
  &lt;li&gt;Score is missing in rows 2 and 5&lt;/li&gt;
  &lt;li&gt;Grade is missing in rows 2 and 5&lt;/li&gt;
&lt;/ul&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;Step 2 - Find All Null Values&lt;/h2&gt;

&lt;p&gt;Before deciding how to handle missing values, you need to know exactly where they are and how many there are.&lt;/p&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;print(df.isnull())&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;    Name    Age  Score  Grade
0  False  False  False  False
1  False   True  False  False
2  False  False   True   True
3  False   True  False  False
4  False  False  False  False
5  False  False   True   True&lt;/div&gt;

&lt;p&gt;Use &lt;code&gt;.sum()&lt;/code&gt; to get a count per column:&lt;/p&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;print(df.isnull().sum())&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;Name     0
Age      2
Score    2
Grade    2
dtype: int64&lt;/div&gt;

&lt;p&gt;For large datasets, check the percentage of missing values:&lt;/p&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;print(df.isnull().sum() / len(df) * 100)&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;Name      0.00
Age      33.33
Score    33.33
Grade    33.33
dtype: float64&lt;/div&gt;

&lt;p&gt;33% of Age, Score, and Grade is missing. That is too significant to ignore.&lt;/p&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;Step 3 - Remove Duplicate Rows&lt;/h2&gt;

&lt;p&gt;Duplicates quietly inflate your numbers. If Bob appears twice, his score gets counted twice in every average or aggregation - without a single warning.&lt;/p&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;# Count duplicates
print(df.duplicated().sum())&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;1&lt;/div&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;# See which row is duplicate
print(df[df.duplicated()])&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;  Name  Age  Score Grade
3  Bob  NaN   92.0     B&lt;/div&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;# Remove duplicates
df.drop_duplicates(inplace=True)
print(df.shape)&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;(5, 4)&lt;/div&gt;

&lt;p&gt;Additional options for &lt;code&gt;drop_duplicates()&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;df.drop_duplicates(keep=&#39;last&#39;, inplace=True)          # Keep last occurrence
df.drop_duplicates(keep=False, inplace=True)           # Remove all copies
df.drop_duplicates(subset=[&#39;Name&#39;], inplace=True)      # Check by column only&lt;/pre&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;Step 4 - Drop or Fill?&lt;/h2&gt;

&lt;p&gt;Once duplicates are handled, you need to deal with null values. You have two options - &lt;strong&gt;drop&lt;/strong&gt; or &lt;strong&gt;fill&lt;/strong&gt;.&lt;/p&gt;

&lt;table&gt;
  &lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Situation&lt;/th&gt;&lt;th&gt;Recommended Action&lt;/th&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Very few rows have nulls, large dataset&lt;/td&gt;&lt;td&gt;Drop rows&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Nulls are common or rows are valuable&lt;/td&gt;&lt;td&gt;Fill with mean / median / mode&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Entire column is mostly null&lt;/td&gt;&lt;td&gt;Drop the column&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;Step 5 - Dropping Nulls&lt;/h2&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;# Drop any row with at least one null
df_dropped = df.dropna()
print(df_dropped)&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;    Name   Age  Score Grade
0  Alice  22.0   88.0     A
4  Diana  23.0   79.0     C&lt;/div&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;df.dropna(axis=1)        # Drop columns with any null
df.dropna(thresh=3)      # Keep rows with at least 3 non-null values&lt;/pre&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;Step 6 - Filling Nulls in Numeric Columns&lt;/h2&gt;

&lt;p&gt;For numeric columns, fill with &lt;strong&gt;mean&lt;/strong&gt; when there are no significant outliers, or &lt;strong&gt;median&lt;/strong&gt; when outliers exist.&lt;/p&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;# Fill Age with mean
df[&#39;Age&#39;].fillna(df[&#39;Age&#39;].mean(), inplace=True)
print(df[&#39;Age&#39;])&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;0    22.00
1    22.75
2    21.00
4    23.00
5    25.00
Name: Age, dtype: float64&lt;/div&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;# Fill Score with median
df[&#39;Score&#39;].fillna(df[&#39;Score&#39;].median(), inplace=True)
print(df[&#39;Score&#39;])&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;0    88.0
1    92.0
2    88.5
4    79.0
5    88.5
Name: Score, dtype: float64&lt;/div&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;Step 7 - Filling Nulls in Categorical Columns&lt;/h2&gt;

&lt;p&gt;For categorical columns like Grade or City - filling with mean makes no sense. Use the &lt;strong&gt;mode&lt;/strong&gt; - the most frequently occurring value.&lt;/p&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;# Fill Grade with mode
df[&#39;Grade&#39;].fillna(df[&#39;Grade&#39;].mode()[0], inplace=True)
print(df[&#39;Grade&#39;])&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;0    A
1    B
2    B
4    C
5    B
Name: Grade, dtype: object&lt;/div&gt;

&lt;div class=&quot;tip&quot;&gt;💡 &lt;strong&gt;Note:&lt;/strong&gt; &lt;code&gt;mode()[0]&lt;/code&gt; is used because &lt;code&gt;.mode()&lt;/code&gt; returns a Series. The &lt;code&gt;[0]&lt;/code&gt; extracts the first - most frequent - value from it.&lt;/div&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;Step 8 - Checking and Fixing Data Types&lt;/h2&gt;

&lt;p&gt;A very common issue with CSV files is that numeric columns get loaded as strings when the column contains mixed content.&lt;/p&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;data2 = {
    &#39;Product&#39;: [&#39;Laptop&#39;, &#39;Phone&#39;, &#39;Tablet&#39;, &#39;Watch&#39;],
    &#39;Price&#39;:   [&#39;999&#39;, &#39;499&#39;, &#39;NaN&#39;, &#39;199&#39;],
    &#39;Stock&#39;:   [50, 30, 20, 15]
}

df2 = pd.DataFrame(data2)
print(df2.dtypes)&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;Product    object
Price      object
Stock       int64
dtype: object&lt;/div&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;# Convert Price to numeric
df2[&#39;Price&#39;] = pd.to_numeric(df2[&#39;Price&#39;], errors=&#39;coerce&#39;)
print(df2.dtypes)
print(df2)&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;Product    object
Price     float64
Stock       int64

  Product   Price  Stock
0  Laptop   999.0     50
1   Phone   499.0     30
2  Tablet     NaN     20
3   Watch   199.0     15&lt;/div&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;df2[&#39;Stock&#39;]   = df2[&#39;Stock&#39;].astype(int)     # To integer
df2[&#39;Product&#39;] = df2[&#39;Product&#39;].astype(str)   # To string&lt;/pre&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;Step 9 - Complete End-to-End Cleaning Workflow&lt;/h2&gt;

&lt;p&gt;Below is the full seven-step workflow in a single block. This is the process to follow every time a new dataset lands on your desk.&lt;/p&gt;

&lt;div class=&quot;label&quot;&gt;Code&lt;/div&gt;
&lt;pre&gt;import pandas as pd
import numpy as np

# Step 1 - Load
df = pd.read_csv(&quot;students.csv&quot;)
print(&quot;Raw Data:&quot;)
print(df.head())

# Step 2 - Inspect
print(&quot;\nShape:&quot;, df.shape)
print(df.info())

# Step 3 - Check nulls
print(&quot;\nNull Counts:&quot;)
print(df.isnull().sum())
print(&quot;\nNull Percentage:&quot;)
print(df.isnull().sum() / len(df) * 100)

# Step 4 - Remove duplicates
print(&quot;\nDuplicates:&quot;, df.duplicated().sum())
df.drop_duplicates(inplace=True)

# Step 5 - Fix data types
df[&#39;Age&#39;]   = pd.to_numeric(df[&#39;Age&#39;],   errors=&#39;coerce&#39;)
df[&#39;Score&#39;] = pd.to_numeric(df[&#39;Score&#39;], errors=&#39;coerce&#39;)

# Step 6 - Fill nulls by column type
df[&#39;Age&#39;].fillna(df[&#39;Age&#39;].mean(),        inplace=True)   # Numeric → mean
df[&#39;Score&#39;].fillna(df[&#39;Score&#39;].median(),  inplace=True)   # Numeric → median
df[&#39;Grade&#39;].fillna(df[&#39;Grade&#39;].mode()[0], inplace=True)   # Categorical → mode

# Step 7 - Confirm clean
print(&quot;\nNull counts after cleaning:&quot;)
print(df.isnull().sum())
print(&quot;\nClean Dataset:&quot;)
print(df)&lt;/pre&gt;

&lt;div class=&quot;label&quot;&gt;Output&lt;/div&gt;
&lt;div class=&quot;output-block&quot;&gt;Null Counts:
Name     0
Age      2
Score    1
Grade    1

Duplicates: 1

Null counts after cleaning:
Name     0
Age      0
Score    0
Grade    0

Clean Dataset:
      Name    Age  Score Grade
0    Alice  22.00   88.0     A
1      Bob  22.00   88.5     B
2  Charlie  21.00   88.5     A
4    Diana  23.00   79.0     C&lt;/div&gt;

&lt;!--═══════════════════════════════════════════--&gt;
&lt;h2&gt;Quick Command Reference&lt;/h2&gt;

&lt;table&gt;
  &lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Task&lt;/th&gt;&lt;th&gt;Command&lt;/th&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Check nulls per cell&lt;/td&gt;&lt;td&gt;&lt;code&gt;df.isnull()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Count nulls per column&lt;/td&gt;&lt;td&gt;&lt;code&gt;df.isnull().sum()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Null percentage&lt;/td&gt;&lt;td&gt;&lt;code&gt;df.isnull().sum() / len(df) * 100&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Drop rows with nulls&lt;/td&gt;&lt;td&gt;&lt;code&gt;df.dropna()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Drop columns with nulls&lt;/td&gt;&lt;td&gt;&lt;code&gt;df.dropna(axis=1)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Fill with fixed value&lt;/td&gt;&lt;td&gt;&lt;code&gt;df.fillna(0)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Fill numeric with mean&lt;/td&gt;&lt;td&gt;&lt;code&gt;df[&#39;col&#39;].fillna(df[&#39;col&#39;].mean())&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Fill numeric with median&lt;/td&gt;&lt;td&gt;&lt;code&gt;df[&#39;col&#39;].fillna(df[&#39;col&#39;].median())&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Fill categorical with mode&lt;/td&gt;&lt;td&gt;&lt;code&gt;df[&#39;col&#39;].fillna(df[&#39;col&#39;].mode()[0])&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Count duplicates&lt;/td&gt;&lt;td&gt;&lt;code&gt;df.duplicated().sum()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Remove duplicates&lt;/td&gt;&lt;td&gt;&lt;code&gt;df.drop_duplicates()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Check data types&lt;/td&gt;&lt;td&gt;&lt;code&gt;df.dtypes&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Convert to numeric&lt;/td&gt;&lt;td&gt;&lt;code&gt;pd.to_numeric(df[&#39;col&#39;], errors=&#39;coerce&#39;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Convert type manually&lt;/td&gt;&lt;td&gt;&lt;code&gt;df[&#39;col&#39;].astype(int)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;!--═══════════════════════════════════════════--&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/103557485818808329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2026/03/python-pandas-data-cleaning-null-values.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/103557485818808329'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/103557485818808329'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2026/03/python-pandas-data-cleaning-null-values.html' title='Python Pandas Data Cleaning &amp; Null Values Guide'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR5vYTmm9NtiDXMK17TW3TvoB6yxZXYyuC2N3l7Y38ZPerxrEllQBdpXIzHUepXHTaxWloWWfCaS-TkA-rcQWrGegXGOT4J6BJYGtIGdkFgvUnvKhvXTVjoWDnWTBTG5vdT9gMRLAD7zHCcP2B61v21ShcrZ4SP1hIRqthMfoTCsXeYbN_9aWKjJxvp8mx/s72-w400-h225-c/Python%20Pandas%20Data%20Cleaning%20Explained.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-3677740061764224802</id><published>2025-07-25T22:25:00.000-07:00</published><updated>2025-07-25T22:25:52.455-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Docker"/><category scheme="http://www.blogger.com/atom/ns#" term="Docker Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Howto"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Ubuntu"/><category scheme="http://www.blogger.com/atom/ns#" term="Ubuntu 22"/><category scheme="http://www.blogger.com/atom/ns#" term="Ubuntu Howto"/><title type='text'>Docker Installation on Ubuntu 22.04 | Step-by-Step Guide</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhump9r1_11Qw7zLT1rrc4xu739r7o0A8TemkNOkTvZC5ExtlM7uAQ1qh9suXK8hBHDtSeHUl1c7KDj4Ga8fC9UpnDCjTmvwbVFUpzFAY3FD9KvkGPcDCP5_JquNt8yJDNi-oApLcitLMuuL1Zgw-L1A7xyeyvUHd9b4_jTDq_HBFeEtoXwkWEKsUd1Vi16&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Docker Installation on Ubuntu&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhump9r1_11Qw7zLT1rrc4xu739r7o0A8TemkNOkTvZC5ExtlM7uAQ1qh9suXK8hBHDtSeHUl1c7KDj4Ga8fC9UpnDCjTmvwbVFUpzFAY3FD9KvkGPcDCP5_JquNt8yJDNi-oApLcitLMuuL1Zgw-L1A7xyeyvUHd9b4_jTDq_HBFeEtoXwkWEKsUd1Vi16=w640-h360&quot; title=&quot;Docker Installation on Ubuntu&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div&gt;In this guide, we are going to learn how to install Docker on Ubuntu with step-by-step complete explanation. We will also verify every step to make sure Docker is properly installed and running on your system.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Topics Covered:&lt;/h3&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;How to update and prepare your Ubuntu system&lt;/li&gt;&lt;li&gt;How to install Docker securely using Docker’s official repository&lt;/li&gt;&lt;li&gt;How to verify Docker installation&lt;/li&gt;&lt;li&gt;How to test Docker by running a container&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;My Setup:&lt;/h3&gt;&lt;div&gt;I&#39;m using Ubuntu 22.04 as my operating system for this demo.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, sans-serif&quot; style=&quot;background-color: white; color: red; font-size: 18px;&quot;&gt;You can also watch this tutorial demo on our Youtube Channel&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, sans-serif&quot; style=&quot;background-color: white; color: red; font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;iframe allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; src=&quot;https://www.youtube.com/embed/pPCYoZrw0oY?si=vaDh-RGGAI8cGerl&quot; title=&quot;YouTube video player&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 1: Update System Packages&lt;/h2&gt;&lt;div&gt;We need to update the package list and upgrade any outdated packages.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;sudo apt update&lt;/div&gt;&lt;div&gt;sudo apt upgrade -y&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Command Output:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;Trimmed&lt;/div&gt;&lt;div&gt;&lt;div&gt;Processing triggers for dbus (1.14.10-4ubuntu4.1) ...&lt;/div&gt;&lt;div&gt;Processing triggers for install-info (7.1-3build2) ...&lt;/div&gt;&lt;div&gt;Processing triggers for libc-bin (2.39-0ubuntu8.5) ...&lt;/div&gt;&lt;div&gt;Processing triggers for man-db (2.12.0-4build2) ...&lt;/div&gt;&lt;div&gt;Processing triggers for initramfs-tools (0.142ubuntu25.5) ...&lt;/div&gt;&lt;div&gt;update-initramfs: Generating /boot/initrd.img-6.8.0-64-generic&lt;/div&gt;&lt;div&gt;Scanning processes...&lt;/div&gt;&lt;div&gt;Scanning candidates...&lt;/div&gt;&lt;div&gt;Scanning linux images...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Running kernel seems to be up-to-date.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Restarting services...&lt;/div&gt;&lt;div&gt;&amp;nbsp;systemctl restart multipathd.service polkit.service ssh.service udisks2.service&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Service restarts being deferred:&lt;/div&gt;&lt;div&gt;&amp;nbsp;systemctl restart ModemManager.service&lt;/div&gt;&lt;div&gt;&amp;nbsp;/etc/needrestart/restart.d/dbus.service&lt;/div&gt;&lt;div&gt;&amp;nbsp;systemctl restart getty@tty1.service&lt;/div&gt;&lt;div&gt;&amp;nbsp;systemctl restart systemd-logind.service&lt;/div&gt;&lt;div&gt;&amp;nbsp;systemctl restart unattended-upgrades.service&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;No containers need to be restarted.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;User sessions running outdated binaries:&lt;/div&gt;&lt;div&gt;&amp;nbsp;skuma @ session #2: apt[1490], sshd[891]&lt;/div&gt;&lt;div&gt;&amp;nbsp;skuma @ session #4: sshd[893]&lt;/div&gt;&lt;div&gt;&amp;nbsp;skuma @ user manager service: systemd[898]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;No VM guests are running outdated hypervisor (qemu) binaries on this host.&lt;/div&gt;&lt;div&gt;skuma@server1:~$&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;This makes sure we are working with the latest versions of all dependencies.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 2: Install Required Packages&lt;/h2&gt;&lt;div&gt;Install some necessary packages that help us securely install Docker.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo apt install ca-certificates curl gnupg -y&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Command Output:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;skuma@server1:~$ sudo apt install ca-certificates curl gnupg -y&lt;/div&gt;&lt;div&gt;Reading package lists... Done&lt;/div&gt;&lt;div&gt;Building dependency tree... Done&lt;/div&gt;&lt;div&gt;Reading state information... Done&lt;/div&gt;&lt;div&gt;ca-certificates is already the newest version (20240203).&lt;/div&gt;&lt;div&gt;ca-certificates set to manually installed.&lt;/div&gt;&lt;div&gt;curl is already the newest version (8.5.0-2ubuntu10.6).&lt;/div&gt;&lt;div&gt;gnupg is already the newest version (2.4.4-2ubuntu17.3).&lt;/div&gt;&lt;div&gt;gnupg set to manually installed.&lt;/div&gt;&lt;div&gt;0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.&lt;/div&gt;&lt;div&gt;skuma@server1:~$&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;These tools are very important for managing repositories and downloading packages over HTTPS.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 3: Add Docker’s GPG Key&lt;/h2&gt;&lt;div&gt;To make sure we install Docker from a trusted source, we need to add Docker’s official GPG key.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First, create the directory:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo mkdir -p /etc/apt/keyrings&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Then download and store the GPG key securely using curl:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg \&lt;/div&gt;&lt;div&gt;--dearmor -o /etc/apt/keyrings/docker.gpg&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 4: Add Docker’s Repository&lt;/h2&gt;&lt;div&gt;Now we’ll add Docker’s official repository.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;echo \&lt;/div&gt;&lt;div&gt;&amp;nbsp; &quot;deb [arch=$(dpkg --print-architecture) \&lt;/div&gt;&lt;div&gt;&amp;nbsp; signed-by=/etc/apt/keyrings/docker.gpg] \&lt;/div&gt;&lt;div&gt;&amp;nbsp; https://download.docker.com/linux/ubuntu \&lt;/div&gt;&lt;div&gt;&amp;nbsp; $(lsb_release -cs) stable&quot; | \&lt;/div&gt;&lt;div&gt;&amp;nbsp; sudo tee /etc/apt/sources.list.d/docker.list &amp;gt; /dev/null&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;This command automatically detects your system architecture and Ubuntu version, and configures the Docker repo accordingly.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 5: Update the Package List Again&lt;/h2&gt;&lt;div&gt;Now that Docker&#39;s repo is added, we need to refresh the package list again.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo apt update&lt;/blockquote&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Command Output:&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;skuma@server1:~$ sudo apt update&lt;/div&gt;&lt;div&gt;Get:1 https://download.docker.com/linux/ubuntu noble InRelease [48.8 kB]&lt;/div&gt;&lt;div&gt;Get:2 https://download.docker.com/linux/ubuntu noble/stable amd64 Packages [28.5 kB]&lt;/div&gt;&lt;div&gt;Hit:3 http://in.archive.ubuntu.com/ubuntu noble InRelease&lt;/div&gt;&lt;div&gt;Hit:4 http://security.ubuntu.com/ubuntu noble-security InRelease&lt;/div&gt;&lt;div&gt;Hit:5 http://in.archive.ubuntu.com/ubuntu noble-updates InRelease&lt;/div&gt;&lt;div&gt;Hit:6 http://in.archive.ubuntu.com/ubuntu noble-backports InRelease&lt;/div&gt;&lt;div&gt;Fetched 77.3 kB in 2s (47.0 kB/s)&lt;/div&gt;&lt;div&gt;Reading package lists... Done&lt;/div&gt;&lt;div&gt;Building dependency tree... Done&lt;/div&gt;&lt;div&gt;Reading state information... Done&lt;/div&gt;&lt;div&gt;4 packages can be upgraded. Run &#39;apt list --upgradable&#39; to see them.&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 6: Install Docker Engine&lt;/h2&gt;&lt;div&gt;Now comes the main part, installing Docker.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Command Output:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;div&gt;skuma@server1:~$ sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y&lt;/div&gt;&lt;div&gt;Reading package lists... Done&lt;/div&gt;&lt;div&gt;Building dependency tree... Done&lt;/div&gt;&lt;div&gt;Reading state information... Done&lt;/div&gt;&lt;div&gt;The following additional packages will be installed:&lt;/div&gt;&lt;div&gt;&amp;nbsp; docker-ce-rootless-extras libslirp0 pigz slirp4netns&lt;/div&gt;&lt;div&gt;Suggested packages:&lt;/div&gt;&lt;div&gt;&amp;nbsp; cgroupfs-mount | cgroup-lite docker-model-plugin&lt;/div&gt;&lt;div&gt;The following NEW packages will be installed:&lt;/div&gt;&lt;div&gt;&amp;nbsp; containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin libslirp0 pigz slirp4netns&lt;/div&gt;&lt;div&gt;0 upgraded, 9 newly installed, 0 to remove and 4 not upgraded.&lt;/div&gt;&lt;div&gt;Need to get 103 MB of archives.&lt;/div&gt;&lt;div&gt;After this operation, 429 MB of additional disk space will be used.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #fcff01;&quot;&gt;Output Trimmed&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Running kernel seems to be up-to-date.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Restarting services...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Service restarts being deferred:&lt;/div&gt;&lt;div&gt;&amp;nbsp;/etc/needrestart/restart.d/dbus.service&lt;/div&gt;&lt;div&gt;&amp;nbsp;systemctl restart getty@tty1.service&lt;/div&gt;&lt;div&gt;&amp;nbsp;systemctl restart systemd-logind.service&lt;/div&gt;&lt;div&gt;&amp;nbsp;systemctl restart unattended-upgrades.service&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;No containers need to be restarted.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;User sessions running outdated binaries:&lt;/div&gt;&lt;div&gt;&amp;nbsp;skuma @ session #2: sshd[891]&lt;/div&gt;&lt;div&gt;&amp;nbsp;skuma @ session #4: sshd[893]&lt;/div&gt;&lt;div&gt;&amp;nbsp;skuma @ user manager service: systemd[898]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;No VM guests are running outdated hypervisor (qemu) binaries on this host.&lt;/div&gt;&lt;div&gt;skuma@server1:~$&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This installs:&lt;/div&gt;&lt;div&gt;Docker Engine&lt;/div&gt;&lt;div&gt;Docker CLI tools&lt;/div&gt;&lt;div&gt;Docker Compose plugin&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 7: Verify Docker Installation&lt;/h2&gt;&lt;div&gt;Check Docker version:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;docker --version&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Command Output:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;skuma@server1:~$ docker --version&lt;/div&gt;&lt;div&gt;Docker version 28.3.2, build 578ccf6&lt;/div&gt;&lt;div&gt;skuma@server1:~$&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;If you see the version number, Docker is installed correctly.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 8: Check Docker Service Status&lt;/h2&gt;&lt;div&gt;Verify whether Docker is running or not.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo systemctl status docker&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Command Output:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;div&gt;skuma@server1:~$ sudo systemctl status docker&lt;/div&gt;&lt;div&gt;● docker.service - Docker Application Container Engine&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: enabled)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Active: active (running) since Sat 2025-07-26 05:23:22 UTC; 1min 6s ago&lt;/div&gt;&lt;div&gt;TriggeredBy: ● docker.socket&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Docs: https://docs.docker.com&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;Main PID: 16697 (dockerd)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Tasks: 8&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Memory: 21.6M (peak: 21.8M)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CPU: 483ms&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;CGroup: /system.slice/docker.service&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;└─16697 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Jul 26 05:23:21 server1 dockerd[16697]: time=&quot;2025-07-26T05:23:21.669297451Z&quot; level=info msg=&quot;detected 127.0.0.53 nameserver, assuming systemd-resolved, so using re&amp;gt;&lt;/div&gt;&lt;div&gt;Jul 26 05:23:21 server1 dockerd[16697]: time=&quot;2025-07-26T05:23:21.708933067Z&quot; level=info msg=&quot;Creating a containerd client&quot; address=/run/containerd/containerd.sock &amp;gt;&lt;/div&gt;&lt;div&gt;Jul 26 05:23:21 server1 dockerd[16697]: time=&quot;2025-07-26T05:23:21.824117058Z&quot; level=info msg=&quot;Loading containers: start.&quot;&lt;/div&gt;&lt;div&gt;Jul 26 05:23:22 server1 dockerd[16697]: time=&quot;2025-07-26T05:23:22.404568741Z&quot; level=info msg=&quot;Loading containers: done.&quot;&lt;/div&gt;&lt;div&gt;Jul 26 05:23:22 server1 dockerd[16697]: time=&quot;2025-07-26T05:23:22.436489743Z&quot; level=info msg=&quot;Docker daemon&quot; commit=e77ff99 containerd-snapshotter=false storage-dri&amp;gt;&lt;/div&gt;&lt;div&gt;Jul 26 05:23:22 server1 dockerd[16697]: time=&quot;2025-07-26T05:23:22.436901615Z&quot; level=info msg=&quot;Initializing buildkit&quot;&lt;/div&gt;&lt;div&gt;Jul 26 05:23:22 server1 dockerd[16697]: time=&quot;2025-07-26T05:23:22.501542109Z&quot; level=info msg=&quot;Completed buildkit initialization&quot;&lt;/div&gt;&lt;div&gt;Jul 26 05:23:22 server1 dockerd[16697]: time=&quot;2025-07-26T05:23:22.518178178Z&quot; level=info msg=&quot;Daemon has completed initialization&quot;&lt;/div&gt;&lt;div&gt;Jul 26 05:23:22 server1 dockerd[16697]: time=&quot;2025-07-26T05:23:22.518243119Z&quot; level=info msg=&quot;API listen on /run/docker.sock&quot;&lt;/div&gt;&lt;div&gt;Jul 26 05:23:22 server1 systemd[1]: Started docker.service - Docker Application Container Engine.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You should see something like active (running) in green. That means Docker is up and running.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 9: Run a Test Container&lt;/h2&gt;&lt;div&gt;Let’s run a simple test container using the hello-world image:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo docker run hello-world&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Command Output:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;div&gt;skuma@server1:~$ sudo docker run hello-world&lt;/div&gt;&lt;div&gt;Unable to find image &#39;hello-world:latest&#39; locally&lt;/div&gt;&lt;div&gt;latest: Pulling from library/hello-world&lt;/div&gt;&lt;div&gt;e6590344b1a5: Pull complete&lt;/div&gt;&lt;div&gt;Digest: sha256:ec153840d1e635ac434fab5e377081f17e0e15afab27beb3f726c3265039cfff&lt;/div&gt;&lt;div&gt;Status: Downloaded newer image for hello-world:latest&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hello from Docker!&lt;/div&gt;&lt;div&gt;This message shows that your installation appears to be working correctly.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To generate this message, Docker took the following steps:&lt;/div&gt;&lt;div&gt;&amp;nbsp;1. The Docker client contacted the Docker daemon.&lt;/div&gt;&lt;div&gt;&amp;nbsp;2. The Docker daemon pulled the &quot;hello-world&quot; image from the Docker Hub.&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; (amd64)&lt;/div&gt;&lt;div&gt;&amp;nbsp;3. The Docker daemon created a new container from that image which runs the&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; executable that produces the output you are currently reading.&lt;/div&gt;&lt;div&gt;&amp;nbsp;4. The Docker daemon streamed that output to the Docker client, which sent it&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; to your terminal.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To try something more ambitious, you can run an Ubuntu container with:&lt;/div&gt;&lt;div&gt;&amp;nbsp;$ docker run -it ubuntu bash&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Share images, automate workflows, and more with a free Docker ID:&lt;/div&gt;&lt;div&gt;&amp;nbsp;https://hub.docker.com/&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For more examples and ideas, visit:&lt;/div&gt;&lt;div&gt;&amp;nbsp;https://docs.docker.com/get-started/&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;skuma@server1:~$&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;This downloads a test image and runs a small container.&lt;/div&gt;&lt;div&gt;If everything is working, you&#39;ll see a friendly message from Docker confirming the setup is successful.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;That’s It!&lt;/div&gt;&lt;div&gt;We have successfully installed Docker on Ubuntu 22.04! See you in the next tutorial.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/3677740061764224802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2025/07/docker-installation-on-ubuntu-2204-step.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/3677740061764224802'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/3677740061764224802'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2025/07/docker-installation-on-ubuntu-2204-step.html' title='Docker Installation on Ubuntu 22.04 | Step-by-Step Guide'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhump9r1_11Qw7zLT1rrc4xu739r7o0A8TemkNOkTvZC5ExtlM7uAQ1qh9suXK8hBHDtSeHUl1c7KDj4Ga8fC9UpnDCjTmvwbVFUpzFAY3FD9KvkGPcDCP5_JquNt8yJDNi-oApLcitLMuuL1Zgw-L1A7xyeyvUHd9b4_jTDq_HBFeEtoXwkWEKsUd1Vi16=s72-w640-h360-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-6823734132258267473</id><published>2025-07-22T22:28:00.000-07:00</published><updated>2025-07-22T22:36:37.188-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="AWS EKS"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Kubernetes"/><category scheme="http://www.blogger.com/atom/ns#" term="Kubernetes Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Kubernetes RBAC Explained with Hands-On Demo</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwBlm32nGukCaO9lJ1a3wz8IvFcXGo00GturEriDE1mxB8Xv8OQZqknn3yvNVIq96FF9kOgaUNuY6O1eYSXh2TzVHWLRIREs8ZP8BBmg3pFX2ocLyh21TA0ffndzV5y5oTYGE5TzEWmtpYqM-EzIvMIz9A_5b0R_05AnAWprU-QGMo1a7p1G8N7ge1nXNF/s1280/Kubernetes%20RBAC%20Explained.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Kubernetes RBAC Explained with Hands-On Demo&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwBlm32nGukCaO9lJ1a3wz8IvFcXGo00GturEriDE1mxB8Xv8OQZqknn3yvNVIq96FF9kOgaUNuY6O1eYSXh2TzVHWLRIREs8ZP8BBmg3pFX2ocLyh21TA0ffndzV5y5oTYGE5TzEWmtpYqM-EzIvMIz9A_5b0R_05AnAWprU-QGMo1a7p1G8N7ge1nXNF/w640-h360/Kubernetes%20RBAC%20Explained.jpg&quot; title=&quot;Kubernetes RBAC Explained with Hands-On Demo&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;p data-end=&quot;606&quot; data-start=&quot;410&quot;&gt;In this post, I will help you to explain what is RBAC in Kubernetes? and help you understand the concept in a very simple way with hands-on examples.&lt;/p&gt;
&lt;p data-end=&quot;768&quot; data-start=&quot;608&quot;&gt;So, if you want to know how to give access to multiple users with different permissions in your Kubernetes cluster, then this tutorial will definitely help you.&lt;/p&gt;
&lt;p data-end=&quot;782&quot; data-start=&quot;770&quot;&gt;For example:&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Admin access for some users&lt;/li&gt;&lt;li&gt;Read-only access for some users in specific namespaces&lt;/li&gt;&lt;li&gt;Full access for some users in specific namespaces&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;
&lt;p data-end=&quot;988&quot; data-start=&quot;923&quot;&gt;We will start with understanding what is RBAC and why we need it.&lt;/p&gt;&lt;h2 data-end=&quot;1015&quot; data-start=&quot;995&quot;&gt;Topics Covered&lt;/h2&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;What is RBAC and why do we need it?&lt;/li&gt;&lt;li&gt;How Kubernetes users are authenticated and authorized&lt;/li&gt;&lt;li&gt;Types of RBAC components:&lt;/li&gt;&lt;ol&gt;&lt;li&gt;▸ Role&lt;/li&gt;&lt;li&gt;▸ ClusterRole&lt;/li&gt;&lt;li&gt;▸ RoleBinding&lt;/li&gt;&lt;li&gt;▸ ClusterRoleBinding&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Creating admin and read-only users&lt;/li&gt;&lt;li&gt;Mapping them using aws-auth&lt;/li&gt;&lt;li&gt;And finally, a demo with examples using different AWS profiles:&lt;/li&gt;&lt;ol&gt;&lt;li&gt;🔹 user1-ro – Read-only access to a single namespace&lt;/li&gt;&lt;li&gt;🔹 user2-full – Full access to a single namespace&lt;/li&gt;&lt;li&gt;🔹 user3-admin – Full access to the entire cluster&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p data-end=&quot;988&quot; data-start=&quot;923&quot;&gt;Since this is for Kubernetes, I use AWS EKS. It may vary if you are using other cloud providers like Google Cloud, etc. But here, I’ll be using AWS IAM for authentication.&lt;/p&gt;&lt;div style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #3d4452; font-family: &amp;quot;Open Sans&amp;quot;, sans-serif; font-size: 18px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;div style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; text-align: center; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; color: red; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;You can also watch this tutorial demo on our Youtube Channel&lt;br /&gt;&lt;iframe allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; src=&quot;https://www.youtube.com/embed/7ubwSKbJp_Y?si=q3tP1PgFIioD7YYZ&quot; title=&quot;YouTube video player&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; color: red; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 data-end=&quot;1708&quot; data-start=&quot;1689&quot;&gt;What is RBAC?&lt;/h2&gt;&lt;p data-end=&quot;1825&quot; data-start=&quot;1710&quot;&gt;RBAC stands for Role-Based Access Control. It is a method to define &lt;strong data-end=&quot;1797&quot; data-start=&quot;1778&quot;&gt;who can do what&lt;/strong&gt; on your Kubernetes cluster.&lt;/p&gt;&lt;p data-end=&quot;1870&quot; data-start=&quot;1827&quot;&gt;To do this, RBAC uses four main components:&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Role&lt;/li&gt;&lt;li&gt;ClusterRole&lt;/li&gt;&lt;li&gt;RoleBinding&lt;/li&gt;&lt;li&gt;ClusterRoleBinding&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p data-end=&quot;988&quot; data-start=&quot;923&quot;&gt;



&lt;/p&gt;&lt;p data-end=&quot;1995&quot; data-start=&quot;1928&quot;&gt;Each component plays a key role in defining and controlling access.&lt;/p&gt;&lt;h2 data-end=&quot;2038&quot; data-start=&quot;2002&quot;&gt;Authentication &amp;amp; Authorization&lt;/h2&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmKfkKxrr5nUGnaDAXxf7zbZaTZu1r6loUX3hyphenhyphengw6T34dkJZLLWUU27cSQ7AFEWxYfUw2GokMGYjjy_o905I9E-KeEVdmxHWj9UjYT-uWnSvFef6TspzC05jTqW7UZGOMwKBD7j2EUnyZDPuuEwkITiXUhgA4TCzSGLQLyqu-_0lnIcxPtK27OiaMv0alH/s1280/2.iam_rbac.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;How Kubernetes RBAC works&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmKfkKxrr5nUGnaDAXxf7zbZaTZu1r6loUX3hyphenhyphengw6T34dkJZLLWUU27cSQ7AFEWxYfUw2GokMGYjjy_o905I9E-KeEVdmxHWj9UjYT-uWnSvFef6TspzC05jTqW7UZGOMwKBD7j2EUnyZDPuuEwkITiXUhgA4TCzSGLQLyqu-_0lnIcxPtK27OiaMv0alH/w400-h225/2.iam_rbac.png&quot; title=&quot;How Kubernetes RBAC works&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p data-end=&quot;2103&quot; data-start=&quot;2040&quot;&gt;Kubernetes always checks &lt;strong data-end=&quot;2079&quot; data-start=&quot;2065&quot;&gt;two things&lt;/strong&gt; when a request is made:&lt;/p&gt;&lt;ol data-end=&quot;2301&quot; data-start=&quot;2105&quot;&gt;
&lt;li data-end=&quot;2208&quot; data-start=&quot;2105&quot;&gt;
&lt;p data-end=&quot;2208&quot; data-start=&quot;2108&quot;&gt;&lt;strong data-end=&quot;2126&quot; data-start=&quot;2108&quot;&gt;Authentication&lt;/strong&gt; – Who is making the request?&lt;br data-end=&quot;2158&quot; data-start=&quot;2155&quot; /&gt;
In EKS, the identity is verified using AWS IAM.&lt;/p&gt;
&lt;/li&gt;
&lt;li data-end=&quot;2301&quot; data-start=&quot;2210&quot;&gt;
&lt;p data-end=&quot;2301&quot; data-start=&quot;2213&quot;&gt;&lt;strong data-end=&quot;2230&quot; data-start=&quot;2213&quot;&gt;Authorization&lt;/strong&gt; – What is that user allowed to do?&lt;br data-end=&quot;2268&quot; data-start=&quot;2265&quot; /&gt;
This is controlled using RBAC.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;p data-end=&quot;1995&quot; data-start=&quot;1928&quot;&gt;


&lt;/p&gt;&lt;p data-end=&quot;2432&quot; data-start=&quot;2303&quot;&gt;For example, if a user tries to list pods, Kubernetes checks: is this user authenticated? Then, is the user allowed to list pods?&lt;/p&gt;&lt;h2 data-end=&quot;2463&quot; data-start=&quot;2439&quot;&gt;Creating IAM Users&lt;/h2&gt;&lt;p data-end=&quot;2521&quot; data-start=&quot;2465&quot;&gt;So I have already created three IAM users for this demo:&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;user1-ro&lt;/li&gt;&lt;li&gt;user2-full&lt;/li&gt;&lt;li&gt;user3-admin&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p data-end=&quot;2649&quot; data-start=&quot;2567&quot;&gt;I’ve added them with the &lt;strong data-end=&quot;2615&quot; data-start=&quot;2592&quot;&gt;AdministratorAccess&lt;/strong&gt; policy just for the sake of demo.&lt;/p&gt;&lt;p data-end=&quot;2432&quot; data-start=&quot;2303&quot;&gt;



&lt;/p&gt;&lt;p data-end=&quot;2748&quot; data-start=&quot;2651&quot;&gt;Each user has their own access key ID and secret, which is configured using AWS CLI on my system.&lt;/p&gt;&lt;h2 data-end=&quot;2789&quot; data-start=&quot;2755&quot;&gt;Updating aws-auth ConfigMap&lt;/h2&gt;&lt;p data-end=&quot;2857&quot; data-start=&quot;2791&quot;&gt;For mapping AWS IAM users to Kubernetes clusters, We have to use &lt;b&gt;aws-auth&lt;/b&gt; ConfigMap.&lt;/p&gt;&lt;p data-end=&quot;2857&quot; data-start=&quot;2791&quot;&gt;&lt;/p&gt;&lt;blockquote&gt;kubectl -n kube-system get cm aws-auth -o yaml&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p data-end=&quot;2748&quot; data-start=&quot;2651&quot;&gt;

&lt;/p&gt;&lt;p data-end=&quot;2880&quot; data-start=&quot;2859&quot;&gt;So export this aws-auth configmap to a file, which will be easy for managing access&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;blockquote&gt;kubectl -n kube-system get cm aws-auth -o yaml &amp;gt; aws-auth.yaml&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p data-end=&quot;2880&quot; data-start=&quot;2859&quot;&gt;You can verify the aws-auth.yaml file using cat command.&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;blockquote&gt;skuma@server1:~/kubernetes/auth$ cat aws-auth.yaml&lt;br /&gt;apiVersion: v1&lt;br /&gt;kind: ConfigMap&lt;br /&gt;metadata:&lt;br /&gt;&amp;nbsp; name: aws-auth&lt;br /&gt;&amp;nbsp; namespace: kube-system&lt;br /&gt;data:&lt;br /&gt;&amp;nbsp; mapRoles: |&lt;br /&gt;&amp;nbsp; &amp;nbsp; - rolearn: arn:aws:iam::591874054217:role/eksctl-demo-cluster-nodegroup-demo-NodeInstanceRole-cW2EtCUZvNc7&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; username: system:node:{{EC2PrivateDNSName}}&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; groups:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - system:bootstrappers&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - system:nodes&lt;/blockquote&gt;&lt;/div&gt;&lt;h2 data-end=&quot;3519&quot; data-start=&quot;3500&quot;&gt;API Resources&lt;/h2&gt;&lt;p data-end=&quot;2880&quot; data-start=&quot;2859&quot;&gt;
&lt;/p&gt;&lt;p data-end=&quot;3565&quot; data-start=&quot;3521&quot;&gt;Before creating actual roles and bindings, we must know the list of resources we can use in RBAC for access:&lt;/p&gt;&lt;p data-end=&quot;3565&quot; data-start=&quot;3521&quot;&gt;&lt;/p&gt;&lt;blockquote&gt;kubectl api-resources&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;Output:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgULo3BZr9z95Kr_XnkmmgohSuen4bhvcg9YNyaHYQqxx_szsNVgHOpIby7uEc1eI0fKdze07DMoFfOV2nXMPZkVhisbblKYnrXrU4qPdrHP7yxlnd7AapMYAhYkauEMq5OiVLBId5k-e-VEpXwWMTigwg-DO0wJCh1aSGEyjovXtlDOt13VD1Bok-n6E5x&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;767&quot; data-original-width=&quot;1335&quot; height=&quot;368&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgULo3BZr9z95Kr_XnkmmgohSuen4bhvcg9YNyaHYQqxx_szsNVgHOpIby7uEc1eI0fKdze07DMoFfOV2nXMPZkVhisbblKYnrXrU4qPdrHP7yxlnd7AapMYAhYkauEMq5OiVLBId5k-e-VEpXwWMTigwg-DO0wJCh1aSGEyjovXtlDOt13VD1Bok-n6E5x=w640-h368&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;You will see list of all Kubernetes resources, that supports to manage using RBAC including whether they are namespaced controlled or not.&lt;/div&gt;&lt;p data-end=&quot;2880&quot; data-start=&quot;2859&quot;&gt;
&lt;/p&gt;&lt;p data-end=&quot;3794&quot; data-start=&quot;3686&quot;&gt;Use &lt;span data-end=&quot;3704&quot; data-start=&quot;3690&quot;&gt;long names&lt;/span&gt; like services, pods, deployments, configmaps. Don’t use short names like svc, po, deploy.&lt;/p&gt;&lt;h2 data-end=&quot;3830&quot; data-start=&quot;3801&quot;&gt;Create Roles &amp;amp; ClusterRole&lt;/h2&gt;&lt;p data-end=&quot;3878&quot; data-start=&quot;3832&quot;&gt;Now let’s create the role and cluster role.&lt;/p&gt;&lt;p data-end=&quot;3794&quot; data-start=&quot;3686&quot;&gt;

&lt;/p&gt;&lt;h3 data-end=&quot;3921&quot; data-start=&quot;3880&quot;&gt;1. Read-only Role for &lt;code data-end=&quot;3911&quot; data-start=&quot;3906&quot;&gt;dev&lt;/code&gt; namespace&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;$ cat role-dev-readonly.yaml&lt;/div&gt;&lt;div&gt;apiVersion: rbac.authorization.k8s.io/v1&lt;/div&gt;&lt;div&gt;kind: Role&lt;/div&gt;&lt;div&gt;metadata:&lt;/div&gt;&lt;div&gt;&amp;nbsp; namespace: dev&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: dev-readonly&lt;/div&gt;&lt;div&gt;rules:&lt;/div&gt;&lt;div&gt;- apiGroups: [&quot;&quot;] # &quot;&quot; indicates the core API group&lt;/div&gt;&lt;div&gt;&amp;nbsp; resources: [&quot;pods&quot;,&quot;services&quot;,&quot;configmaps&quot;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; verbs: [&quot;get&quot;, &quot;watch&quot;, &quot;list&quot;]&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;2. Full-access Role for &lt;code data-end=&quot;4176&quot; data-start=&quot;4171&quot;&gt;dev&lt;/code&gt; namespace&lt;/h3&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;$ cat role-dev-fullaccess.yaml&lt;/div&gt;&lt;div&gt;apiVersion: rbac.authorization.k8s.io/v1&lt;/div&gt;&lt;div&gt;kind: Role&lt;/div&gt;&lt;div&gt;metadata:&lt;/div&gt;&lt;div&gt;&amp;nbsp; namespace: dev&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: dev-fullaccess&lt;/div&gt;&lt;div&gt;rules:&lt;/div&gt;&lt;div&gt;- apiGroups: [&quot;&quot;] # &quot;&quot; indicates the core API group&lt;/div&gt;&lt;div&gt;&amp;nbsp; resources: [&quot;*&quot;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; verbs: [&quot;*&quot;]&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;3. Cluster Admin Role&lt;/h3&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;$ cat clusterrole-cluster-admin-full.yaml&lt;/div&gt;&lt;div&gt;apiVersion: rbac.authorization.k8s.io/v1&lt;/div&gt;&lt;div&gt;kind: ClusterRole&lt;/div&gt;&lt;div&gt;metadata:&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: cluster-admin-full&lt;/div&gt;&lt;div&gt;rules:&lt;/div&gt;&lt;div&gt;- apiGroups: [&quot;&quot;] # &quot;&quot; indicates the core API group&lt;/div&gt;&lt;div&gt;&amp;nbsp; resources: [&quot;*&quot;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; verbs: [&quot;*&quot;]&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Once we have created role, cluster role with required permissions including resources, verbs. Now we need to create bindings for each role and clusterrole.&lt;/div&gt;&lt;div&gt;&lt;h2 data-end=&quot;4599&quot; data-start=&quot;4559&quot;&gt;RoleBinding and ClusterRoleBinding&lt;/h2&gt;
&lt;h3 data-end=&quot;4632&quot; data-start=&quot;4601&quot;&gt;RoleBinding read-only access for namespace &quot;dev&quot;:&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;$ cat rolebinding-dev-readonly.yaml&lt;/div&gt;&lt;div&gt;apiVersion: rbac.authorization.k8s.io/v1&lt;/div&gt;&lt;div&gt;kind: RoleBinding&lt;/div&gt;&lt;div&gt;metadata:&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: rolebinding-dev-readonly&lt;/div&gt;&lt;div&gt;&amp;nbsp; namespace: dev&lt;/div&gt;&lt;div&gt;subjects:&lt;/div&gt;&lt;div&gt;- kind: Group&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: dev-readonly&lt;/div&gt;&lt;div&gt;&amp;nbsp; apiGroup: rbac.authorization.k8s.io&lt;/div&gt;&lt;div&gt;roleRef:&lt;/div&gt;&lt;div&gt;&amp;nbsp; kind: Role&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: dev-readonly&lt;/div&gt;&lt;div&gt;&amp;nbsp; apiGroup: rbac.authorization.k8s.io&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 data-end=&quot;4632&quot; data-start=&quot;4601&quot;&gt;RoleBinding Full-access for namespace &quot;dev&quot;:&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;$ cat rolebinding-dev-fullaccess.yaml&lt;/div&gt;&lt;div&gt;apiVersion: rbac.authorization.k8s.io/v1&lt;/div&gt;&lt;div&gt;kind: RoleBinding&lt;/div&gt;&lt;div&gt;metadata:&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: rolebinding-dev-fullaccess&lt;/div&gt;&lt;div&gt;&amp;nbsp; namespace: dev&lt;/div&gt;&lt;div&gt;subjects:&lt;/div&gt;&lt;div&gt;- kind: Group&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: dev-fullaccess&lt;/div&gt;&lt;div&gt;&amp;nbsp; apiGroup: rbac.authorization.k8s.io&lt;/div&gt;&lt;div&gt;roleRef:&lt;/div&gt;&lt;div&gt;&amp;nbsp; kind: Role&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: dev-fullaccess&lt;/div&gt;&lt;div&gt;&amp;nbsp; apiGroup: rbac.authorization.k8s.io&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;ClusterRoleBinding Admin access for entire cluster:&lt;/h3&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;$ cat rolebinding-cluster-admin-full.yaml&lt;/div&gt;&lt;div&gt;apiVersion: rbac.authorization.k8s.io/v1&lt;/div&gt;&lt;div&gt;kind: ClusterRoleBinding&lt;/div&gt;&lt;div&gt;metadata:&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: rolebinding-cluster-admin-full&lt;/div&gt;&lt;div&gt;subjects:&lt;/div&gt;&lt;div&gt;- kind: Group&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: cluster-admin-full&lt;/div&gt;&lt;div&gt;&amp;nbsp; apiGroup: rbac.authorization.k8s.io&lt;/div&gt;&lt;div&gt;roleRef:&lt;/div&gt;&lt;div&gt;&amp;nbsp; kind: ClusterRole&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: cluster-admin-full&lt;/div&gt;&lt;div&gt;&amp;nbsp; apiGroup: rbac.authorization.k8s.io&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Map users in aws-auth configmap&lt;/h2&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Open aws-auth yaml file using some editor and add all your users with respective groups that we have created in the rolebdindings as below.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;blockquote&gt;&lt;div&gt;$ cat aws-auth.yaml&lt;/div&gt;&lt;div&gt;apiVersion: v1&lt;/div&gt;&lt;div&gt;kind: ConfigMap&lt;/div&gt;&lt;div&gt;metadata:&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: aws-auth&lt;/div&gt;&lt;div&gt;&amp;nbsp; namespace: kube-system&lt;/div&gt;&lt;div&gt;data:&lt;/div&gt;&lt;div&gt;&amp;nbsp; mapRoles: |&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; - rolearn: arn:aws:iam::591874054217:role/eksctl-demo-cluster-nodegroup-demo-NodeInstanceRole-cW2EtCUZvNc7&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; username: system:node:{{EC2PrivateDNSName}}&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; groups:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - system:bootstrappers&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - system:nodes&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; mapUsers: |&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; - groups:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; - dev-readonly&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; userarn: arn:aws:iam::591874054217:user/user1-ro&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; username: user1-ro&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; - groups:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; - dev-fullaccess&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; userarn: arn:aws:iam::591874054217:user/user2-full&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; username: user1-full&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; - groups:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; - cluster-admin-full&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; userarn: arn:aws:iam::591874054217:user/user3-admin&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; username: user3-admin&lt;/b&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;h2 data-end=&quot;5293&quot; data-start=&quot;5248&quot;&gt;Testing Access with AWS CLI Profiles&lt;/h2&gt;
&lt;p data-end=&quot;5334&quot; data-start=&quot;5295&quot;&gt;Ask each users to update kubeconfig into the system, then only they can manage your kubernetes cluster.&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;blockquote&gt;aws eks update-kubeconfig --region us-east-1 --name demo-cluster&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Once you have got your kubeconfig file. Test the access.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Switch to each user and run different commands to check the appropriate permission are set or not.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;kubectl get pods -n dev&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # ✅ for user1-ro&lt;/div&gt;&lt;div&gt;kubectl delete pod podname&amp;nbsp; &amp;nbsp; &amp;nbsp;# ❌ for user1-ro&lt;/div&gt;&lt;div&gt;kubectl get ns&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# ❌ for user1-ro&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finally,&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;user1-ro&lt;/b&gt; can only view resources in &lt;b&gt;dev&lt;/b&gt; namespace.&lt;/li&gt;&lt;li&gt;&lt;b&gt;user2-full&lt;/b&gt; can manage everything in &lt;b&gt;dev&lt;/b&gt; namespace but cannot touch prod or cluster-wide objects.&lt;/li&gt;&lt;li&gt;&lt;b&gt;user3-admin&lt;/b&gt; has full access across the entire cluster.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;That’s how we control access in Kubernetes using RBAC.&amp;nbsp;I hope you understood the concept.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/6823734132258267473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2025/07/kubernetes-rbac-explained-with-hands-on-demo.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/6823734132258267473'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/6823734132258267473'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2025/07/kubernetes-rbac-explained-with-hands-on-demo.html' title='Kubernetes RBAC Explained with Hands-On Demo'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwBlm32nGukCaO9lJ1a3wz8IvFcXGo00GturEriDE1mxB8Xv8OQZqknn3yvNVIq96FF9kOgaUNuY6O1eYSXh2TzVHWLRIREs8ZP8BBmg3pFX2ocLyh21TA0ffndzV5y5oTYGE5TzEWmtpYqM-EzIvMIz9A_5b0R_05AnAWprU-QGMo1a7p1G8N7ge1nXNF/s72-w640-h360-c/Kubernetes%20RBAC%20Explained.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-1152577137634490387</id><published>2025-07-18T21:20:00.000-07:00</published><updated>2025-07-18T21:20:26.660-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="AWS EC2"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Deploy AWS EKS Cluster on Private Subnets with Terraform</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGjcwwp4fMTR6H3UtNbfhoQviouaf7K5zto5lZY5MIaehmYmZ8ncekeM8Ffwv-JzsKdGJkhhgEdJ6x8-t7H8jOvlAh9vuT7aZW0XxaoI7L_qBLtksk55niU6WDhCpUEdRK7feG6yM98K26OlsKVQr6cwiBhS6J6OqTylOED7qxOB0cYqBupNeWlkkZRWNB/s1280/Deploy%20AWS%20EKS%20Cluster%20on%20Private%20Subnets%20with%20Terraform.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Deploy AWS EKS Cluster on Private Subnets with Terraform&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGjcwwp4fMTR6H3UtNbfhoQviouaf7K5zto5lZY5MIaehmYmZ8ncekeM8Ffwv-JzsKdGJkhhgEdJ6x8-t7H8jOvlAh9vuT7aZW0XxaoI7L_qBLtksk55niU6WDhCpUEdRK7feG6yM98K26OlsKVQr6cwiBhS6J6OqTylOED7qxOB0cYqBupNeWlkkZRWNB/w640-h360/Deploy%20AWS%20EKS%20Cluster%20on%20Private%20Subnets%20with%20Terraform.jpg&quot; title=&quot;Deploy AWS EKS Cluster on Private Subnets with Terraform&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div&gt;In the previous article, I showed you &lt;a href=&quot;https://www.learnitguide.net/2025/07/create-eks-cluster-on-aws-terraform.html&quot; target=&quot;_blank&quot;&gt;how to create an AWS EKS cluster with a custom VPC using Terraform modules&lt;/a&gt;. That setup was great for a non-production or testing environment.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But here, we’ll take things one step further. We will convert the same setup into a production-ready environment. The key changes? We will deploy our AWS EKS cluster into private subnets and connect it through a NAT Gateway. This is a widely recommended best practice for securing production workloads on AWS.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;🛠 Prerequisites&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Before you start, make sure these tools are installed and configured on your system.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Terraform&lt;/b&gt; – Used to provision infrastructure as code.&lt;/div&gt;&lt;div&gt;👉 Install:&amp;nbsp;&lt;a href=&quot;https://www.learnitguide.net/2024/07/introduction-to-terraform.html&quot;&gt;terraform command installation&lt;/a&gt;&lt;/div&gt;&lt;div&gt;👉 Check with terraform -v&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;AWS CLI &lt;/b&gt;– Needed to interact with AWS services and fetch kubeconfig.&lt;/div&gt;&lt;div&gt;👉 Download:&amp;nbsp;&lt;a href=&quot;https://aws.amazon.com/cli/&quot; target=&quot;_blank&quot;&gt;aws.amazon.com/cli&lt;/a&gt;&lt;/div&gt;&lt;div&gt;👉 Configure with aws configure&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;kubectl&lt;/b&gt; – To interact with your EKS Kubernetes cluster.&lt;/div&gt;&lt;div&gt;👉 Download: &lt;a href=&quot;http://kubernetes.io&quot; target=&quot;_blank&quot;&gt;kubernetes.io&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;You can also watch this tutorial demo on our Youtube Channel&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/lVF2Na8rrEI?si=a9CFz8IxaJZiP8y6&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;📁 Setting Up the Terraform Project&lt;/h2&gt;&lt;div&gt;I’m using Visual Studio Code. I copied the previous project folder &lt;b&gt;eks-terraform-demo&lt;/b&gt; and renamed it to &lt;b&gt;eks-terraform-demo-prod&lt;/b&gt;. This way we reuse all the Terraform files we created earlier and just tweak them for production.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;$ ls -lrt &lt;b&gt;eks-terraform-demo&lt;/b&gt;&lt;/div&gt;&lt;div&gt;total 7&lt;/div&gt;&lt;div&gt;-rw-r--r-- 1 skuma 197609 136 Jul&amp;nbsp; 8 20:25 outputs.tf&lt;/div&gt;&lt;div&gt;-rw-r--r-- 1 skuma 197609&amp;nbsp; 43 Jul&amp;nbsp; 9 08:05 provider.tf&lt;/div&gt;&lt;div&gt;-rw-r--r-- 1 skuma 197609 467 Jul&amp;nbsp; 9 12:09 vpc.tf&lt;/div&gt;&lt;div&gt;-rw-r--r-- 1 skuma 197609 559 Jul&amp;nbsp; 9 13:40 eks.tf&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;skuma@hp MINGW64 /d/Learning/codes/Terraform&lt;/div&gt;&lt;div&gt;$ ls -lrt &lt;b&gt;eks-terraform-demo-prod/&lt;/b&gt;&lt;/div&gt;&lt;div&gt;total 76&lt;/div&gt;&lt;div&gt;-rw-r--r-- 1 skuma 197609&amp;nbsp; 136 Jul&amp;nbsp; 8 20:25 outputs.tf&lt;/div&gt;&lt;div&gt;-rw-r--r-- 1 skuma 197609&amp;nbsp; &amp;nbsp;43 Jul&amp;nbsp; 9 08:05 provider.tf&lt;/div&gt;&lt;div&gt;-rw-r--r-- 1 skuma 197609&amp;nbsp; 650 Jul&amp;nbsp; 9 13:42 vpc.tf&lt;/div&gt;&lt;div&gt;-rw-r--r-- 1 skuma 197609&amp;nbsp; 627 Jul&amp;nbsp; 9 19:29 eks.tf&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;🏗️ VPC Changes for Production&lt;/h2&gt;&lt;div&gt;Inside &lt;b&gt;vpc.tf&lt;/b&gt;, I made several important changes:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;module&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;vpc&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;source &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;terraform-aws-modules/vpc/aws&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;version &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;~&amp;gt; 5.0&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;name &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;flipkart-vpc-prod&quot;&lt;/span&gt; &lt;span style=&quot;color: #6a9955;&quot;&gt;#changed name to match prod.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.0.0/16&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;azs &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;us-east-1a&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;us-east-1b&quot;&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;public_subnets &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.1.0/24&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.2.0/24&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;private_subnets &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.11.0/24&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.12.0/24&quot;&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;map_public_ip_on_launch &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;enable_nat_gateway &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt; &lt;span style=&quot;color: #6a9955;&quot;&gt;#changed to true&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;single_nat_gateway &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt; &lt;span style=&quot;color: #6a9955;&quot;&gt;#added for prod&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;public_subnet_tags &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;kubernetes.io/role/elb&quot;&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;#Added for prod&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;private_subnet_tags &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;kubernetes.io/role/internal-elb&quot;&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Terraform&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;VPC Name changed to &lt;b&gt;flipkart-vpc-prod&lt;/b&gt;&lt;/div&gt;&lt;div&gt;map_public_ip_on_launch = true (kept as-is)&lt;/div&gt;&lt;div&gt;&lt;b&gt;enable_nat_gateway = true&lt;/b&gt; – this allows private subnets to access the internet&lt;/div&gt;&lt;div&gt;&lt;b&gt;single_nat_gateway = true&lt;/b&gt; – avoids creating multiple NATs to save cost&lt;/div&gt;&lt;div&gt;Added tags to &lt;b&gt;private subnets&lt;/b&gt; – this is required for Kubernetes to provision internal load balancers&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;These changes ensure that our worker nodes will be launched in private subnets and still have internet access via the NAT Gateway — a common and secure setup in production environments.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;⚙️ EKS Cluster Changes&lt;/h2&gt;&lt;div&gt;In &lt;b&gt;eks.tf&lt;/b&gt;, I made the following updates:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;module&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;eks&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;source&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;terraform-aws-modules/eks/aws&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;version&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;~&amp;gt; 20.0&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cluster_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;flipkart-eks-prod&quot;&lt;/span&gt; &lt;span style=&quot;color: #6a9955;&quot;&gt;#changed name to match prod&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cluster_version&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;1.31&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;subnet_ids&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;private_subnets&lt;/span&gt; &lt;span style=&quot;color: #6a9955;&quot;&gt;#changed to private subnets&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cluster_endpoint_public_access&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;true&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;enable_cluster_creator_admin_permissions&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;true&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;eks_managed_node_groups&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;default&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_types&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; [&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;t3.medium&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_size&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_size&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;desired_size&lt;/span&gt; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Environment&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;prod&quot;&lt;/span&gt; &lt;span style=&quot;color: #6a9955;&quot;&gt;#changed to prod&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Cluster Name changed to &lt;b&gt;flipkart-eks-prod&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Subnet IDs updated to use private subnets instead of public ones&lt;/div&gt;&lt;div&gt;Tag updates to reflect environment as &quot;&lt;b&gt;prod&lt;/b&gt;&quot;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The cluster endpoint and public access settings were kept the same for now. You can make them private if needed.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;🔧 Terraform Apply Configuration&lt;/h2&gt;&lt;div&gt;It&#39;s Time to deploy the infrastructure using terraform apply command, but I have initialized the terraform, so first i will initiate it.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;terraform init&lt;/div&gt;&lt;div&gt;terraform apply -auto-approve&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Once done, you’ll see the output: your cluster endpoint and name.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;✅ Verifying EKS Cluster Setup&lt;/h2&gt;&lt;div&gt;Go to the AWS Console → EKS → You’ll see the new cluster &lt;b&gt;flipkart-eks-prod&lt;/b&gt; in &quot;&lt;b&gt;Active&lt;/b&gt;&quot; status.&lt;/div&gt;&lt;div&gt;Check the EC2 instances – a new instance should appear, deployed into your private subnet (e.g., CIDR 10.0.11.0/24).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;🔗 Connect AWS EKC Cluster using kubectl&lt;/h2&gt;&lt;div&gt;Configure your local kubeconfig to interact with the new cluster:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;aws eks update-kubeconfig --region us-east-1 --name flipkart-eks-prod&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Then test the connection:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;kubectl get nodes&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;You should see one worker node up and ready.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;🌐 Deploy Test App Deployment&lt;/h2&gt;&lt;div&gt;Now let’s deploy a basic Apache web app and expose it.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;kubectl run apache --image=httpd --port=80&lt;/div&gt;&lt;div&gt;kubectl get pods&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Expose it using a LoadBalancer:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;kubectl expose pod apache --type=LoadBalancer --port=80 --target-port=80&lt;/div&gt;&lt;div&gt;kubectl get svc&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;You’ll get a LoadBalancer hostname (likely internal, since it’s running in a private subnet).&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;🔓 Allow HTTP Temporarily (For Testing Only)&lt;/h2&gt;&lt;div&gt;If needed, open port 80:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Go to EC2 → Security Groups → Find the EKS node group SG&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Add an inbound rule: HTTP (80), source: 0.0.0.0/0&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Visit the LoadBalancer URL in your browser (use http://, not https://). You might get a &quot;Not Secure&quot; warning — just proceed for this test.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If it loads the Apache default page, then everything is working!&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;📌 Bonus Tip: Avoid One Service = One LoadBalancer&lt;/h2&gt;&lt;div&gt;&lt;div&gt;For a real production workload, exposing each pod with its own LoadBalancer is not ideal. You’ll end up with high cost and complex routing.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Instead, deploy an Ingress Controller (like &lt;a href=&quot;https://www.learnitguide.net/2020/06/kubernetes-ingress-explained-setup.html&quot; target=&quot;_blank&quot;&gt;NGINX&lt;/a&gt; or &lt;a href=&quot;https://www.learnitguide.net/2020/06/how-to-setup-haproxy-ingress-controller.html&quot; target=&quot;_blank&quot;&gt;HAProxy&lt;/a&gt;) in front of your cluster. We’ve already covered how to deploy Ingress Controllers — check out our earlier tutorials for that.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is now a production-ready Kubernetes environment on AWS using Terraform.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/1152577137634490387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2025/07/deploy-aws-eks-cluster-on-private-subnets.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/1152577137634490387'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/1152577137634490387'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2025/07/deploy-aws-eks-cluster-on-private-subnets.html' title='Deploy AWS EKS Cluster on Private Subnets with Terraform'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGjcwwp4fMTR6H3UtNbfhoQviouaf7K5zto5lZY5MIaehmYmZ8ncekeM8Ffwv-JzsKdGJkhhgEdJ6x8-t7H8jOvlAh9vuT7aZW0XxaoI7L_qBLtksk55niU6WDhCpUEdRK7feG6yM98K26OlsKVQr6cwiBhS6J6OqTylOED7qxOB0cYqBupNeWlkkZRWNB/s72-w640-h360-c/Deploy%20AWS%20EKS%20Cluster%20on%20Private%20Subnets%20with%20Terraform.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-5343486165166424614</id><published>2025-07-11T23:54:00.000-07:00</published><updated>2025-07-11T23:54:22.028-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="AWS EC2"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Create EKS Cluster on AWS Using Terraform Modules</title><content type='html'>&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCV8j8fMqfiRjh-FSAjeM0zE4f_bxeOUeNpEnirscXvTegn0Pn0jX3HEzOajnd_aNsZ0Jd9pB8kk9Ye0vvaqhB_G1bXX6Y_2DbUWVNINoMO_Y7ktjLKwO-XanR8RYi0NkCHZJhFY8rM-zdejHYvlfUL1B_Y2pJJoAERhaPHB87qV7MDWubQBxxZum7skcy/s1280/Create%20EKS%20Cluster%20on%20AWS%20Using%20Terraform%20Modules.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Create EKS Cluster on AWS Using Terraform Modules&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCV8j8fMqfiRjh-FSAjeM0zE4f_bxeOUeNpEnirscXvTegn0Pn0jX3HEzOajnd_aNsZ0Jd9pB8kk9Ye0vvaqhB_G1bXX6Y_2DbUWVNINoMO_Y7ktjLKwO-XanR8RYi0NkCHZJhFY8rM-zdejHYvlfUL1B_Y2pJJoAERhaPHB87qV7MDWubQBxxZum7skcy/w640-h360/Create%20EKS%20Cluster%20on%20AWS%20Using%20Terraform%20Modules.jpg&quot; title=&quot;Create EKS Cluster on AWS Using Terraform Modules&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In this guide, I&#39;m going to walk you through how to create a Kubernetes cluster on AWS (EKS) using Terraform modules. And it&#39;s not just about the Kubernetes cluster. we will also create the VPC required for it. This is going to be a complete Kubernetes environment, and by the end, you’ll have a strong understanding of both VPC and AWS EKS setup.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finally, we&#39;ll do a deployment of a simple test application like Apache to verify that the cluster is running and accessible.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;You can also watch this tutorial demo on our Youtube Channel&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/s0c_aXDhJgU?si=FmzbZ8GRdGUodkLa&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;AWS EKS + VPC Architecture&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi9HrHKw4IaILgLhpqsveANswpdkiSBZe4DcG2yEeVHfnJjRwMkHtDiq2uTEizwBTZCqpLr_R_e5ZBpXvl86T2OvcHU7lNf9nvKKfQdV5zfct04f_QZhNc45taNqHIQ5tRs0oi-7GBMt8b13F3bZpJ1i9Ey6uPRQ0qIwnmjRr-iplkdU66Mdn-n1tbQdHz-&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;aws-eks-vpc-architecture&quot; data-original-height=&quot;540&quot; data-original-width=&quot;960&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi9HrHKw4IaILgLhpqsveANswpdkiSBZe4DcG2yEeVHfnJjRwMkHtDiq2uTEizwBTZCqpLr_R_e5ZBpXvl86T2OvcHU7lNf9nvKKfQdV5zfct04f_QZhNc45taNqHIQ5tRs0oi-7GBMt8b13F3bZpJ1i9Ey6uPRQ0qIwnmjRr-iplkdU66Mdn-n1tbQdHz-=w640-h360&quot; title=&quot;aws-eks-vpc-architecture&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is the architecture we are going to create:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First, we need to create a VPC with two public subnets and two private subnets.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Since this is a non-production environment, we’ll deploy the Kubernetes cluster on public subnets.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you&#39;re just getting started with Kubernetes on AWS, this is the best way to begin. In a follow-up, I’ll show you how to deploy on private subnets for a full production setup.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I assume, you have already installed the required tools.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;kubectl – &lt;a href=&quot;https://kubernetes.io/docs/tasks/tools&quot; target=&quot;_blank&quot;&gt;https://kubernetes.io/docs/tasks/tools&lt;/a&gt;&lt;/div&gt;&lt;div&gt;AWS CLI – &lt;a href=&quot;https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html&quot; target=&quot;_blank&quot;&gt;https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html&lt;/a&gt;&lt;/div&gt;&lt;div&gt;- Run aws configure to set your AWS access and secret keys.&lt;/div&gt;&lt;div&gt;Terraform – &lt;a href=&quot;https://developer.hashicorp.com/terraform/downloads&quot; target=&quot;_blank&quot;&gt;https://developer.hashicorp.com/terraform/downloads&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I’ve created a directory called &lt;b&gt;eks-terraform-demo&lt;/b&gt;. Inside it, I’ve already defined the necessary Terraform files and blocks.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let’s go through them one by one.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;provider.tf&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the provider.tf file, I’ve defined the AWS provider, and the region is set to us-east-1.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;provider&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;region&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;us-east-1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Creating VPC with Terraform Module:&lt;/h2&gt;&lt;div&gt;&lt;b&gt;vpc.tf&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;module&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;vpc&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;source&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;terraform-aws-modules/vpc/aws&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;version&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;~&amp;gt; 5.0&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;flipkart-vpc-nonprod&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.0.0/16&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;azs&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;us-east-1a&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;us-east-1b&quot;&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;public_subnets&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.1.0/24&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.2.0/24&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;private_subnets&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.11.0/24&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.12.0/24&quot;&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;map_public_ip_on_launch&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;true&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;enable_nat_gateway&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;false&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;public_subnet_tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;kubernetes.io/role/elb&quot;&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Terraform&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In vpc.tf, I’ve used the official Terraform VPC module. You can find it by searching “&lt;a href=&quot;https://registry.terraform.io/browse/modules&quot; target=&quot;_blank&quot;&gt;Terraform modules&lt;/a&gt;” in your browser and heading to terraform-aws-modules. There, you’ll find a module for VPC and another for EKS.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I’ve copied the VPC example and made some modifications based on the requirement for integrating the AWS VPC with AWS EKS Module.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Mentioned Two public subnets and two private subnets across us-east-1a and us-east-1b for better high availability.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I also disabled the NAT gateway to save cost, since we’re not deploying anything on the private subnets for now.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I faced issues using the latest VPC module version (v6.x) with the EKS module, so I used version 5.x instead—it worked perfectly.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The VPC is named flipkart-vpc-nonpro, just as an example.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Creating AWS EKS with Terraform Module&lt;/h2&gt;&lt;div&gt;&lt;b&gt;eks.tf&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;module&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;eks&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;source&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;terraform-aws-modules/eks/aws&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;version&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;~&amp;gt; 20.0&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cluster_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;flipkart-eks-nonprod&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cluster_version&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;1.31&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;subnet_ids&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;public_subnets&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cluster_endpoint_public_access&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;true&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;enable_cluster_creator_admin_permissions&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;true&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;eks_managed_node_groups&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;default&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_types&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; [&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;t3.medium&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_size&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_size&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;desired_size&lt;/span&gt; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Environment&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;nonprod&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In eks.tf, I used the EKS managed node group example from the Terraform registry. I prefer managed node groups as they are fully controlled by AWS.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here are some key details:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Cluster name: flipkart-eks-nonpro&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;VPC ID is passed from the VPC module&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Subnets used are public subnets only&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;cluster_endpoint_public_access = true to allow access from outside (like your laptop)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Managed node group with:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Instance type: t3.medium&lt;/li&gt;&lt;li&gt;Desired capacity: 1&lt;/li&gt;&lt;li&gt;Min size: 1&lt;/li&gt;&lt;li&gt;Max size: 2&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Initialize and Apply Terraform Configuration:&lt;/h2&gt;&lt;p&gt;Once all the files are ready:&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;blockquote&gt;terraform init&lt;br /&gt;terraform apply -auto-approve&lt;/blockquote&gt;&lt;/div&gt;&lt;p&gt;After a successful apply, I check the output values for cluster_name and cluster_endpoint. Because i have added the below output blocks to get printed the values on the terminal.&lt;/p&gt;&lt;p&gt;&lt;b&gt;outputs.tf&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;output&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;cluster_name&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;eks&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cluster_name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;output&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;cluster_endpoint&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;eks&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cluster_endpoint&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Update KubeConfig&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;First, we need the kubeconfig locally:&lt;br /&gt;&lt;blockquote&gt;aws eks update-kubeconfig --region us-east-1 --name flipkart-eks-nonprod&lt;/blockquote&gt;Then run:&lt;br /&gt;&lt;blockquote&gt;kubectl get nodes&lt;/blockquote&gt;If you see the node listed, your setup is working.&lt;/div&gt;&lt;div&gt;&lt;h2&gt;Deploying Test Application&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;We now test by deploying a simple Apache pod.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Now deploy Apache directly:&lt;br /&gt;&lt;blockquote&gt;kubectl run apache --image=httpd --port=80&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Now Check pod:&lt;br /&gt;&lt;blockquote&gt;kubectl get pods&lt;/blockquote&gt;Expose it via a LoadBalancer:&lt;br /&gt;&lt;blockquote&gt;kubectl expose pod apache --type=LoadBalancer --port=80&lt;/blockquote&gt;Now check:&lt;br /&gt;&lt;blockquote&gt;kubectl get svc&lt;/blockquote&gt;You’ll see a LoadBalancer service created with an external IP (provided by AWS ELB).&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Allowing Access (Temporary for Testing)&lt;/h2&gt;By default, port 80 won’t be open in the security group. So:&lt;br /&gt;Go to EKS → Networking → Security Groups&lt;br /&gt;Open the additional node group security group&lt;br /&gt;Add an inbound rule for HTTP (port 80) from anywhere (0.0.0.0/0)&lt;br /&gt;Save the rule&lt;br /&gt;Now access the Load Balancer URL from your browser using HTTP (not HTTPS). If it redirects to HTTPS, remove the &quot;s&quot; and try again.&lt;br /&gt;You should see the Apache default page.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;This setup is perfect for learning and testing purposes. It will give you better understanding of how Terraform integrates with AWS services like EKS and VPC.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the next guide, I’ll show you how to set up a production-ready cluster using private subnets, proper NAT gateways, and restricted access.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/5343486165166424614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2025/07/create-eks-cluster-on-aws-terraform.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/5343486165166424614'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/5343486165166424614'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2025/07/create-eks-cluster-on-aws-terraform.html' title='Create EKS Cluster on AWS Using Terraform Modules'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCV8j8fMqfiRjh-FSAjeM0zE4f_bxeOUeNpEnirscXvTegn0Pn0jX3HEzOajnd_aNsZ0Jd9pB8kk9Ye0vvaqhB_G1bXX6Y_2DbUWVNINoMO_Y7ktjLKwO-XanR8RYi0NkCHZJhFY8rM-zdejHYvlfUL1B_Y2pJJoAERhaPHB87qV7MDWubQBxxZum7skcy/s72-w640-h360-c/Create%20EKS%20Cluster%20on%20AWS%20Using%20Terraform%20Modules.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-7122095027346835160</id><published>2025-07-01T20:59:00.000-07:00</published><updated>2025-07-02T04:01:00.468-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="AWS EC2"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Understanding Terraform Provisioners with Real-Time EC2 Demo</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCAgIT_UiCsaPmxmZy0f17w4lWL1MNJJjM5Yu92agvx2TQCIWhNEnZdPUJTHYCCWou7sHCKK5K-lI7gGMeQNrtlAlhwVkmlDHAOiXDvc9j-fEpoyUHGt2rsaBUhLxtTcNWHOtqo6Se5p6sL1GtqMTIhLvuXQo3LU7EpmG6HJqfkHTKv1FO8ZmnSBnOzkk3/s1280/terrafform%20provisioners%20file%20-%20remote%20exec%20tutorial.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;terrafform provisioners file - remote exec tutorial&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCAgIT_UiCsaPmxmZy0f17w4lWL1MNJJjM5Yu92agvx2TQCIWhNEnZdPUJTHYCCWou7sHCKK5K-lI7gGMeQNrtlAlhwVkmlDHAOiXDvc9j-fEpoyUHGt2rsaBUhLxtTcNWHOtqo6Se5p6sL1GtqMTIhLvuXQo3LU7EpmG6HJqfkHTKv1FO8ZmnSBnOzkk3/w640-h360/terrafform%20provisioners%20file%20-%20remote%20exec%20tutorial.jpg&quot; title=&quot;terrafform provisioners file - remote exec tutorial&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Hello friends, this is our 9th post in our Terraform tutorial series.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;We’ve already covered all the important topics from the basics, step by step, in the previous topics. In this post, I’ll explain about Terraform provisioners, including:&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;1. What are Terraform provisioners?&lt;br /&gt;2. Types of provisioners&lt;br /&gt;3. What is&amp;nbsp;file provisioner?&lt;br /&gt;4. What is remote-exec provisioner?&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;background-color: white; color: red; font-size: 18px; text-align: center;&quot;&gt;You can also Watch this tutorial demo on our YouTube Channel&lt;/span&gt;&lt;br /&gt;&lt;iframe allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; src=&quot;https://www.youtube.com/embed/X4P9RE_cx3M?si=5nYh6SDaY6Oh1sah&quot; title=&quot;YouTube video player&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;
  &lt;h2 style=&quot;text-align: left;&quot;&gt;What are Terraform Provisioners?&lt;/h2&gt;Provisioners are like post-setup scripts. They help you perform additional tasks after Terraform has applied the configuration.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;For example:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Copying files&lt;/li&gt;&lt;li&gt;Running installation scripts&lt;/li&gt;&lt;li&gt;Configuring services&lt;/li&gt;&lt;li&gt;Executing any custom commands&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;We have a few types of provisioners:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;file&lt;/li&gt;&lt;li&gt;local-exec&lt;/li&gt;&lt;li&gt;remote-exec&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;In this post, we’ll primarily focus on file and remote-exec type provisioners, because when using Terraform for infrastructure provisioning, we typically need to set up everything on the remote server after the resource is created.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;What is File Provisioner?&lt;/h2&gt;&lt;p&gt;As the name suggests, the file provisioner copies files from your local machine to a remote server.&lt;br /&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;The file must exist locally.&lt;/li&gt;&lt;li&gt;Terraform will copy it to the remote machine using a connection.&lt;/li&gt;&lt;li&gt;The connection type must be defined — either SSH for Linux or WinRM for Windows.&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;provisioner&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;file&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;source&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;index.html&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;destination&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/home/ubuntu/index.html&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;This provisioner is used only to copy files or directories, nothing more. So it will have source and destination parameters to define the file to be copied from source and destination location.&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;What is Remote-Exec Provisioner?&lt;/h2&gt;This provisioner helps you run commands on the remote server. It’s useful for post-setup tasks like:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Installing packages&lt;/li&gt;&lt;li&gt;Configuring services&lt;/li&gt;&lt;li&gt;Running shell scripts&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;provisioner&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;remote-exec&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;inline&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[ &lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sudo apt-get update&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sudo apt-get -y install apache2&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sudo cp -rf /home/ubuntu/index.html /var/www/html/index.html&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sudo systemctl start apache2&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;]&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;For both types, we need connection block to establish a connection to the target resources.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;connection&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;type &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ssh&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;user &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ubuntu&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;private_key &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;file&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;demov2.pem&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;host &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;aws_instance&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;server1&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;public_ip&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Provisioners and connection blocks must be inside your resource block, not outside it.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Steps:&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Define the connection block&lt;/li&gt;&lt;li&gt;Add the file provisioner to copy the index.html&lt;/li&gt;&lt;li&gt;Add the remote-exec provisioner to install Apache and move the file&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;main.tf&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;provider&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;region&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;us-east-1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_instance&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;server1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ami&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ami-0e86e20dae9224db8&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_type&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;t2.micro&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;subnet_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;subnet-0105b1aef1e7755cd&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;demov2&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ebs_block_device&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;device_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/dev/sda1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;volume_size&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;associate_public_ip_address&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_security_group_ids&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sg-04dd813e22c5a0b2f&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;server1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;connection&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ssh&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;user&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ubuntu&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;private_key&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;file&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;demov2.pem&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;host&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_instance&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;server1&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;public_ip&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;provisioner&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;file&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;source&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;index.html&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;destination&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/home/ubuntu/index.html&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;provisioner&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;remote-exec&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;inline&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[ &lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sudo apt-get update&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sudo apt-get -y install apache2&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sudo cp -rf /home/ubuntu/index.html /var/www/html/index.html&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sudo systemctl start apache2&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;]&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Above file will deploy an ec2 instance on aws and copy index.html to target location.&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Then it will setup a apache2 webserver for us as post setup scripts.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Create index.html in your current directory and keep your SSH key for making connection.&lt;br /&gt;&lt;br /&gt;Once things are ready, you can apply the terraform configuration.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;text-align: left;&quot;&gt;terraform init&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;terraform apply --auto-approve&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;They’re useful for &lt;strong data-end=&quot;5591&quot; data-start=&quot;5561&quot;&gt;lightweight configurations&lt;/strong&gt;, especially during resource creation. For long-term, robust service management, consider integrating with config management tools.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/7122095027346835160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2025/07/understanding-terraform-provisioners.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/7122095027346835160'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/7122095027346835160'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2025/07/understanding-terraform-provisioners.html' title='Understanding Terraform Provisioners with Real-Time EC2 Demo'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCAgIT_UiCsaPmxmZy0f17w4lWL1MNJJjM5Yu92agvx2TQCIWhNEnZdPUJTHYCCWou7sHCKK5K-lI7gGMeQNrtlAlhwVkmlDHAOiXDvc9j-fEpoyUHGt2rsaBUhLxtTcNWHOtqo6Se5p6sL1GtqMTIhLvuXQo3LU7EpmG6HJqfkHTKv1FO8ZmnSBnOzkk3/s72-w640-h360-c/terrafform%20provisioners%20file%20-%20remote%20exec%20tutorial.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-2410939678734139380</id><published>2025-06-26T19:38:00.000-07:00</published><updated>2025-06-26T20:28:26.771-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="AWS EC2"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Terraform Workspaces: Managing Multiple Environments Efficiently</title><content type='html'>&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6jPAmNEL-YfsMHFadwIO81HlYpEYkWJRxq1-YRMZqSaL2_dQEKJCKjWiwyuDI0F5lRj6iKiB1f55RNCQhU0mFPfpQ5Gd8UGfEc0yKsmK4vMUn_Q-r3KN5Zrli12u-WyijmlNoDHy7d10gU8LbGHKKaFQkTbLa_c6lmvOW_rUAPq6LrLUNAF6tMSmVrq5B/s1280/terraform%20workspaces%20tutorial.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;what is Terraform Workspaces&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6jPAmNEL-YfsMHFadwIO81HlYpEYkWJRxq1-YRMZqSaL2_dQEKJCKjWiwyuDI0F5lRj6iKiB1f55RNCQhU0mFPfpQ5Gd8UGfEc0yKsmK4vMUn_Q-r3KN5Zrli12u-WyijmlNoDHy7d10gU8LbGHKKaFQkTbLa_c6lmvOW_rUAPq6LrLUNAF6tMSmVrq5B/w640-h360/terraform%20workspaces%20tutorial.jpg&quot; title=&quot;what is Terraform Workspaces&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;


&lt;div&gt;&lt;div&gt;We are going to learn about Terraform Workspaces and, most importantly, how to use them to manage multiple environments like Dev, QA, Staging, and Prod efficiently. Previously we have covered the topic - &lt;a href=&quot;https://www.learnitguide.net/2025/06/terraform-state-file-management-tutorial.html&quot; target=&quot;_blank&quot;&gt;Terraform State File Management Tutorial&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: red; font-size: 18px; text-align: center;&quot;&gt;You can also Watch this tutorial demo on our YouTube Channel&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/W_wW_NNgxf4?si=x3Mu2Q9_k5-yUPUV&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;The Problem: Traditional Environment Management&lt;/h2&gt;&lt;div&gt;Usually, when we manage different environments, we will either create separate Git branches in a repository (like a Dev branch, QA, Prod, and so on) or we&#39;ll create separate directories like this.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, the Dev environment will have all the Terraform resource files. The Prod environment will have similar Terraform resource files. Similarly, for other environments, I will copy the same resource file and keep it in a different directory. This is how we generally manage multiple environments, with each directory for each environment having these resource files.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For example, in this Dev directory, which is managing my Dev environment, if you see this main.tf, I have a resource section which is nothing but the creation of an EC2 server in the Dev environment. The same code, the same directory, I will copy to create another environment.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let&#39;s say I want to have a different environment for Prod, then I&#39;ll copy this directory and rename the directory to prod, and I will make the changes accordingly. So here, in this Prod directory as well, I have a main.tf which also has the same code. Similarly, if you want to manage multiple environments, this is what we do.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is the actual problem: If I want to make a small change, like in the Dev environment I want my instance to be T2.micro, and I want all my environments&#39; resource types to be the same. In this case, if I want to use T2.micro or T3.medium, I need to go and update each main.tf file in every directory, update the value, and then I need to apply it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But, if you want to manage these environments smartly, where you can use the same resource file and apply it for different environments, this is exactly where Terraform Workspaces come in and make our life easier.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Introducing Terraform Workspaces&lt;/h2&gt;&lt;div&gt;A Workspace in Terraform is like an isolated environment that will have its own state file, but it will share the same codebase. If you see this diagram, the Terraform codebase will be the same, but for each environment, we will create a workspace. Each workspace will have a dedicated state file for that particular workspace. Here, we can consider each workspace as an environment. This is the beauty of using Terraform Workspaces.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzGe1CKWV25rQ2dyn8KlWwzozFJXOlLU9jTIF3qwtCL5DEfbUufJcUWL0aGldQZBA14ySQNTZn0azFyELOP-pqO372CB6K0os_cB14nXAdDsFlKo_H4RLTN0I6Hyi79Q0jf-GkQGCGC-V3BcH8F0uoyT0PQDBnEleWL9vnRG3g7_FqVKp9Fxx_krEd2lnF/s2048/terraform%20workspaces.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;terraform workspaces&quot; border=&quot;0&quot; data-original-height=&quot;2048&quot; data-original-width=&quot;2048&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzGe1CKWV25rQ2dyn8KlWwzozFJXOlLU9jTIF3qwtCL5DEfbUufJcUWL0aGldQZBA14ySQNTZn0azFyELOP-pqO372CB6K0os_cB14nXAdDsFlKo_H4RLTN0I6Hyi79Q0jf-GkQGCGC-V3BcH8F0uoyT0PQDBnEleWL9vnRG3g7_FqVKp9Fxx_krEd2lnF/w640-h640/terraform%20workspaces.png&quot; title=&quot;terraform workspaces&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, think of it like this: we want to create and manage multiple environments like Dev, Prod, QA. Instead of creating these kinds of different directories and copy-pasting the same code, I have created a single directory called &lt;b&gt;workspace-demo&lt;/b&gt;, and I have copied the same code here only once.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Creating and Switching Workspaces&lt;/h2&gt;&lt;div&gt;Now, we&#39;ll see how to create workspaces, how to switch between different workspaces, and how to apply configurations to them.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is the directory I&#39;m going to use. Let me first initialize Terraform. Even if you have not created any workspace, by default Terraform has created a workspace called default.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform workspace show&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Here, by default, Terraform has created a default workspace for you. This is the one you have been using even if you don&#39;t know it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let&#39;s create a new workspace for our environments. How can we create it?&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform workspace new dev&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;For example, dev. This is nothing but we are creating a workspace for the dev environment. Once this is created, this will be switched into the newly created workspace. How would you confirm it?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform workspace show&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now you are in dev.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Similarly, we&#39;ll create another workspace, prod.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform workspace new prod&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now you are switched into prod. Again, I will create one more, qa.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform workspace new qa&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If I run terraform workspace show, this will show me the workspace I&#39;m currently in.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you want to get a list of workspaces available in your current directory, I can give:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform workspace list&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So we have this many, and I&#39;m in qa now.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now, if I want to switch over between any workspaces, I can use terraform workspace select. I can switch to any workspace I want. For example, if I want to get into dev, I can use the workspace name:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform workspace select dev&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now I have switched into the dev workspace. You can use list or show to confirm this information.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, this is how we switch between workspaces. Let&#39;s see how we apply the configuration for each workspace.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Applying Configuration Across Workspaces&lt;/h2&gt;&lt;div&gt;Now, I have a similar Terraform configuration. I have a provider where I have mentioned my provider is AWS and the region is US East-1. Also, I have a Terraform resource configuration file main.tf. Here, I have defined my resource to create an EC2 instance. You can create multiple resources as you want. For this demo, I&#39;ll be using this one resource.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let&#39;s say if you apply this configuration from dev, the server will be created with a name like &quot;server one&quot;. This is what we generally do from the default workspace. But smartly, what we can do is dynamically update the value, just like how we use variables. Similarly, we can use the Terraform workspace dynamically. For example, here, in the prefix or suffix, you can define it like:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;resource &quot;aws_instance&quot; &quot;server1&quot; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; ami&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;ami-0e86e20dae9224db8&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; instance_type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;t2.micro&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; subnet_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;subnet-0105b1aef1e7755cd&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; key_name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &quot;demov2&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; ebs_block_device {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; device_name = &quot;/dev/sda1&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; volume_size = 10&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; associate_public_ip_address = &quot;true&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; vpc_security_group_ids&amp;nbsp; &amp;nbsp; &amp;nbsp; = [&quot;sg-04dd813e22c5a0b2f&quot;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; tags = {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; Name = &lt;b&gt;&quot;server1-${terraform.workspace}&quot;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is my code. So, my server name will be created like server-one-dev. If you want, you can put it in the prefix; it&#39;s up to you.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let&#39;s apply this configuration. So right now, I am in dev.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform apply -auto-approve&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The configuration is applied now, and we are in the dev workspace. So, this configuration is applied for the dev environment. Let me go to my EC2 console and refresh my page.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, server-one-dev is created. We can think like these resources are dedicatedly created for the dev environment. Similarly, you can create multiple resources. As we have only one single resource, this is fine.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now, if I want to apply the same code to multiple workspaces, I need to switch over into that particular workspace and then apply it. The point is, I&#39;m using the same Terraform code for multiple environments.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let&#39;s select qa now.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;terraform workspace select qa&lt;/div&gt;&lt;div&gt;terraform apply -auto-approve&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So the configuration is applied.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Again, I will switch over to the prod environment.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;terraform workspace select prod&lt;/div&gt;&lt;div&gt;terraform apply -auto-auto-approve&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Okay. Now, if you take this example, we used the same Terraform resource files. I have created multiple workspaces to manage my different environments. I switched over to each workspace and applied the same configuration. If you go to EC2 and refresh the page, now you see server-one-dev, server-one-qa, server-one-prod. So you have servers for each environment.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Understanding State File Management&lt;/h2&gt;&lt;div&gt;The same code is used, but the resource gets created independently in each environment. How is it maintaining its state file for each workspace? Because we need a state file, but if you see here, we don&#39;t see a TF state file directly. Instead, Terraform has created a directory called .terraform/terraform.tfstate.d. If you expand this, you can see it created a directory for each workspace, and it has saved the state file within that directory. So, it is maintaining the TF state file dedicatedly for each workspace.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Dynamic Configuration with Workspaces&lt;/h2&gt;&lt;div&gt;Okay, one more thing: we can dynamically update the values based on the environment&#39;s needs. For example, for a lower environment, I can use a small instance type. For a production environment, I can go with a little higher instance type. So, how can we achieve this, especially since we use a single resource configuration? We can use conditions. This topic is already covered in a separate video about conditions, so go through it if you need a refresher.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, what I can do for the instance type:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;resource &quot;aws_instance&quot; &quot;server1&quot; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; ami&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;ami-0e86e20dae9224db8&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; instance_type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &lt;b&gt;terraform.workspace == &quot;prod&quot; ? &quot;t3.medium&quot; : &quot;t2.micro&quot;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; subnet_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;subnet-0105b1aef1e7755cd&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; key_name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &quot;demov2&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; ebs_block_device {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; device_name = &quot;/dev/sda1&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; volume_size = 10&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; associate_public_ip_address = &quot;true&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; vpc_security_group_ids&amp;nbsp; &amp;nbsp; &amp;nbsp; = [&quot;sg-04dd813e22c5a0b2f&quot;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; tags = {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; Name = &quot;server1-${terraform.workspace}&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;This is how we generally define conditions. So, terraform.workspace == &quot;prod&quot; is the condition. If this condition is true (meaning the workspace is prod), then it will pick the first value (t3.medium). If it is false (meaning any other workspace like dev or qa), then it will pick up the second value (t2.micro) as the instance type.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let me start from dev workspace.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;terraform workspace select dev&lt;/div&gt;&lt;div&gt;terraform apply -auto-approve&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here, the condition is false because the workspace is dev. That is why T2.micro will be set. It is already set, so that is why it is refreshing.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now I will switch over to qa and I will apply the configuration.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;terraform workspace select qa&lt;/div&gt;&lt;div&gt;terraform apply -auto-approve&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Okay. Now I will switch over to prod then apply the configuration.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;terraform workspace select prod&lt;/div&gt;&lt;div&gt;terraform apply -auto-approve&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This time, the condition will become true. terraform.workspace will be prod, so it will pick T3.medium as the type. Initially, the instance type was T2.micro (from a previous run), so now a change is detected, and it will apply the new change. That is why we see this &quot;modifying&quot; message.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The configuration is applied in all workspaces. So, let&#39;s go and refresh the EC2 page.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So here, if you see, for dev and qa, the instance type is T2.micro, but for production, it is T3.medium.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Deleting Workspaces&lt;/h2&gt;&lt;div&gt;Terraform Workspaces help us manage multiple environments using the same set of code. Each workspace has its own isolated state file. We can dynamically use the workspace name to change tags, names, instance types, and other parameters.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Okay, let&#39;s say we want to delete a workspace. You can simply run:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform workspace delete [workspace_name]&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But the condition here is: if you are already in the workspace, you cannot delete it because it is an active workspace.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, let me switch over to qa.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform workspace select qa&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;From here, I will try to delete the prod workspace. This is what I want to show you: if you are planning to delete a workspace, the first thing you need to do is destroy all the resources within that workspace using terraform destroy. Only if you do a destroy and make it clean, then only you will be able to delete a workspace.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So first, I will destroy all the resources, then I will delete the workspace. As we have only one resource, it is deleting that one resource. If you have multiple resources, it will destroy them accordingly.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now I will switch over to default.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform workspace select default&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;From here, I can delete all the workspaces. First, I need to switch over to another workspace. From here, I will destroy the resources. Then we&#39;ll use prod again. We&#39;ll destroy it. Now we&#39;ll switch over to dev. Destroy the resources.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform workspace list&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;From here, I will switch over to select dev. Sorry, I have to get into default. From here, I will delete the workspaces one by one. So this is how I need to delete it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;terraform workspace delete dev&lt;/div&gt;&lt;div&gt;terraform workspace delete qa&lt;/div&gt;&lt;div&gt;terraform workspace delete prod&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we don&#39;t have any workspaces other than default. This is how we use terraform workspace delete command.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hope this article was helpful for you to understand Terraform Workspaces in a simple and practical way. See you in the next topic. Till then, keep practicing and have fun!&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/2410939678734139380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2025/06/terraform-workspaces-managing-multiple.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/2410939678734139380'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/2410939678734139380'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2025/06/terraform-workspaces-managing-multiple.html' title='Terraform Workspaces: Managing Multiple Environments Efficiently'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6jPAmNEL-YfsMHFadwIO81HlYpEYkWJRxq1-YRMZqSaL2_dQEKJCKjWiwyuDI0F5lRj6iKiB1f55RNCQhU0mFPfpQ5Gd8UGfEc0yKsmK4vMUn_Q-r3KN5Zrli12u-WyijmlNoDHy7d10gU8LbGHKKaFQkTbLa_c6lmvOW_rUAPq6LrLUNAF6tMSmVrq5B/s72-w640-h360-c/terraform%20workspaces%20tutorial.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-8316555143290810186</id><published>2025-06-19T22:00:00.000-07:00</published><updated>2025-06-26T20:24:32.413-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="AWS EC2"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Terraform State File Management Tutorial</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmEvulYr6Y3NYQIFyU_-nW2E7FnsMxT5jRXChKdUPWbBGjCBaH0Viw-rVmk5DN_q6m_UUhmCQjnAKevgVlzeuvd1PMl2PUVOAHolSWjgkEVYHZSu9YCLH4fSAGHockLzvYHpYxm1Sih6kmfSgWSZisQDTweWbe658Qz33ToagXersQCBTxeqBLYrxg7sbX/s1280/terraform%20state%20file%20management%20tutorial.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Terraform State File Management Tutorial&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmEvulYr6Y3NYQIFyU_-nW2E7FnsMxT5jRXChKdUPWbBGjCBaH0Viw-rVmk5DN_q6m_UUhmCQjnAKevgVlzeuvd1PMl2PUVOAHolSWjgkEVYHZSu9YCLH4fSAGHockLzvYHpYxm1Sih6kmfSgWSZisQDTweWbe658Qz33ToagXersQCBTxeqBLYrxg7sbX/w640-h360/terraform%20state%20file%20management%20tutorial.jpg&quot; title=&quot;Terraform State File Management Tutorial&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;p data-end=&quot;562&quot; data-start=&quot;467&quot;&gt;If you’re working with Terraform, you’ve probably seen this file pop up: &lt;code data-end=&quot;559&quot; data-start=&quot;540&quot;&gt;terraform.tfstate&lt;/code&gt;.&lt;/p&gt;
&lt;p data-end=&quot;641&quot; data-start=&quot;569&quot;&gt;What is it? Why does Terraform need it? Should you be scared of it? 😅&lt;/p&gt;&lt;p data-end=&quot;641&quot; data-start=&quot;569&quot;&gt;I’m going to explain everything about the Terraform state file — in simple, everyday language — and show you how to manage it safely. We’ll walk through examples, look at common commands, and even talk about remote state.&lt;/p&gt;&lt;p data-end=&quot;641&quot; data-start=&quot;569&quot;&gt;In the previous posts, we have covered the topic - &quot;&lt;a href=&quot;https://www.learnitguide.net/2025/06/terraform-conditionals-loops-built-in.html&quot; target=&quot;_blank&quot;&gt;Terraform Conditionals, Loops &amp;amp; Built-in Functions Explained&lt;/a&gt;&quot;&lt;/p&gt;&lt;p data-end=&quot;641&quot; data-start=&quot;569&quot;&gt;Let’s get into it!&quot;&lt;/p&gt;&lt;p data-end=&quot;641&quot; data-start=&quot;569&quot;&gt;&lt;span style=&quot;background-color: white; color: red; font-size: 18px; text-align: center;&quot;&gt;You can also Watch this tutorial demo on our YouTube Channel&lt;/span&gt;&lt;/p&gt;&lt;p data-end=&quot;641&quot; data-start=&quot;569&quot;&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/9s8dHq9jqJU?si=Gs_BGANTeytMoVEu&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;What is Terraform State File?&lt;/b&gt;&lt;/h2&gt;&lt;p data-end=&quot;1020&quot; data-start=&quot;971&quot;&gt;&quot;So first off — what even &lt;em data-end=&quot;1001&quot; data-start=&quot;997&quot;&gt;is&lt;/em&gt; this state file?&lt;/p&gt;&lt;p data-end=&quot;1144&quot; data-start=&quot;1027&quot;&gt;When you run &lt;code data-end=&quot;1057&quot; data-start=&quot;1040&quot;&gt;terraform apply&lt;/code&gt;, Terraform actually builds your infrastructure and then writes down what it created.&lt;/p&gt;&lt;p data-end=&quot;1183&quot; data-start=&quot;1151&quot;&gt;It keeps track of things like:&lt;/p&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;what resources it made&lt;/li&gt;&lt;li&gt;their IDs&lt;/li&gt;&lt;li&gt;any settings it used&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;ul data-end=&quot;1259&quot; data-start=&quot;1186&quot; style=&quot;text-align: left;&quot;&gt;


&lt;/ul&gt;&lt;p data-end=&quot;1324&quot; data-start=&quot;1262&quot;&gt;All of that gets saved in a file called &lt;code data-end=&quot;1321&quot; data-start=&quot;1302&quot;&gt;terraform.tfstate&lt;/code&gt;.&lt;/p&gt;&lt;p data-end=&quot;641&quot; data-start=&quot;569&quot;&gt;




&lt;/p&gt;&lt;p data-end=&quot;1407&quot; data-start=&quot;1331&quot;&gt;Think of it like Terraform’s memory. Without it, it forgets what it’s done.&quot;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Why Terraform state file is important?&lt;/h2&gt;&lt;p data-end=&quot;1407&quot; data-start=&quot;1331&quot;&gt;&quot;Now you might be wondering — why does Terraform need to remember anything?&lt;/p&gt;&lt;p data-end=&quot;1407&quot; data-start=&quot;1331&quot;&gt;Let’s say you created an EC2 instance on AWS.&lt;/p&gt;&lt;p data-end=&quot;1407&quot; data-start=&quot;1331&quot;&gt;Next week, you change the instance type in your code.&lt;/p&gt;&lt;p data-end=&quot;1407&quot; data-start=&quot;1331&quot;&gt;Without the state file, Terraform has no idea that the instance even exists — so it might try to create a new one, or worse, delete something by mistake.&lt;/p&gt;&lt;p data-end=&quot;1407&quot; data-start=&quot;1331&quot;&gt;The state helps Terraform figure out what to change, and what to leave alone.&quot;&lt;/p&gt;&lt;p data-end=&quot;2079&quot; data-start=&quot;1951&quot;&gt;&quot;By default, Terraform saves the state file right in your project folder — it&#39;s just a normal file called &lt;code data-end=&quot;2076&quot; data-start=&quot;2057&quot;&gt;terraform.tfstate&lt;/code&gt;.&lt;/p&gt;&lt;p data-end=&quot;1407&quot; data-start=&quot;1331&quot;&gt;
&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;Let me show you real quick:&quot;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;terraform init&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;terraform apply&lt;/p&gt;&lt;/blockquote&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&quot;Once that runs, boom — there’s your terraform.tfstate file.&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;You can open it, but… fair warning — it’s just a big chunk of JSON. Not fun to read. 😅&quot;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;How to Inspect Terraform State?&lt;/h2&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&quot;Thankfully, you don’t have to read that JSON yourself. Terraform gives us easy commands to peek inside the state. Like these:&quot;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;terraform show&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;terraform state list&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;terraform state show &amp;lt;resource&amp;gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&quot;terraform show gives you a summary of everything.&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;terraform state list will just list all the resources Terraform is tracking.&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;And terraform state show lets you look at one resource in detail.&quot;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Understanding Terraform State Commands &#39;mv&#39; and &#39;rm&#39;:&lt;/h2&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&quot;Okay, now let’s talk about two state commands that people get confused about — and they’re super useful once you get the hang of them.&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;That’s terraform state mv and terraform state rm.&quot;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&lt;b&gt;🔄 terraform state mv – Rename a Resource&lt;/b&gt;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&quot;This command is like telling Terraform,&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;‘Hey, I renamed this thing in my code, but don’t worry — it’s still the same resource.’&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;Here&#39;s an example:&quot;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;# Old name&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_instance&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;web1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ami&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ami-0e86e20dae9224db8&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_type&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;t2.micro&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;subnet_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;subnet-0105b1aef1e7755cd&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;demov2&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ebs_block_device&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;device_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/dev/sda1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;volume_size&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;associate_public_ip_address&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_security_group_ids&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sg-04dd813e22c5a0b2f&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Web2&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;# You change it to:&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_instance&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;web2&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ami&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ami-0e86e20dae9224db8&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_type&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;t2.micro&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;subnet_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;subnet-0105b1aef1e7755cd&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;demov2&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ebs_block_device&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;device_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/dev/sda1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;volume_size&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;associate_public_ip_address&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_security_group_ids&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sg-04dd813e22c5a0b2f&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Web2&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&quot;Now, if you don’t do anything, Terraform thinks the old one is gone and the new one is something totally different — so it tries to destroy and recreate it.&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;We don’t want that.&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;Instead, run this:&quot;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&lt;/p&gt;&lt;blockquote&gt;terraform state mv aws_instance.web1 aws_instance.web2&lt;/blockquote&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&quot;Now Terraform knows:&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&#39;Ah, okay — you just renamed it. Got it.&#39;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;No resources get recreated. Everything stays the same in the cloud. You just updated the state.&quot;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&lt;b&gt;🗑️ terraform state rm – Remove from State&lt;/b&gt;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&quot;Alright, now let’s talk about terraform state rm. This one removes a resource from the state file.&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;That means Terraform forgets that the resource exists — but it doesn’t delete it from your cloud provider.&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;For example:&quot;&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&lt;/p&gt;&lt;blockquote&gt;terraform state rm aws_instance.web2&lt;/blockquote&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&quot;After this, Terraform no longer tracks that ec2 web2 instance.&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;It still exists in AWS — you can see it in the console — but Terraform won’t manage it anymore.&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&lt;b&gt;Why would you do this?&lt;/b&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Maybe you’re importing that resource into a different project&lt;/li&gt;&lt;li&gt;Or maybe you want to recreate it cleanly&lt;/li&gt;&lt;li&gt;Or maybe you just don’t want Terraform managing it anymore&lt;/li&gt;&lt;/ol&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;Just keep in mind — if the resource is still in your .tf code, and you run terraform apply again, Terraform might try to create it again. So use this carefully.&quot;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;How to create Terraform Remote Backend?&lt;/h2&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&quot;Now, what if you don’t want the state file sitting in your folder? Maybe you’re on a different machine, or want to back it up.&lt;/p&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;You can use something called a remote backend — and the easiest one is S3.&quot;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;blockquote&gt;terraform {&lt;br /&gt;&amp;nbsp; backend &quot;s3&quot; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; bucket = &quot;skumarsumar0710&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; key&amp;nbsp; &amp;nbsp; = &quot;terraform_demo/terraform.tfstate&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; region = &quot;us-east-1&quot;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/blockquote&gt;&lt;/div&gt;&lt;p data-end=&quot;2114&quot; data-start=&quot;2086&quot;&gt;&quot;This will store the state file in an S3 bucket. When you run terraform init, it’ll ask you if you want to migrate your local state to remote — say yes.&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/8316555143290810186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2025/06/terraform-state-file-management-tutorial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/8316555143290810186'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/8316555143290810186'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2025/06/terraform-state-file-management-tutorial.html' title='Terraform State File Management Tutorial'/><author><name>Admin</name><uri>http://www.blogger.com/profile/03660103809536814792</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmEvulYr6Y3NYQIFyU_-nW2E7FnsMxT5jRXChKdUPWbBGjCBaH0Viw-rVmk5DN_q6m_UUhmCQjnAKevgVlzeuvd1PMl2PUVOAHolSWjgkEVYHZSu9YCLH4fSAGHockLzvYHpYxm1Sih6kmfSgWSZisQDTweWbe658Qz33ToagXersQCBTxeqBLYrxg7sbX/s72-w640-h360-c/terraform%20state%20file%20management%20tutorial.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-1830993285278298407</id><published>2025-06-16T21:21:00.000-07:00</published><updated>2025-06-26T20:23:39.036-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="AWS EC2"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Terraform Conditionals, Loops &amp; Built-in Functions Explained</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVxrTtrpZg6hhVTElwLMNbBa_GQu9r02CqZixvGO4LTpezQ0v2-Jmmgm2PHpoUET2IVyXD88ytRcf2Qlqck6AmGfP3jLS_wJRixWq1a6s3ofbkRW1owc3VB9hcSethlnSDB12AP5CQiwdIYg3kj1BXWd9vjIUPOAaB3IEhjeTYSt4QQQ56dZh3EysDroe0/s1280/Terraform%20Conditionals,%20Built-in%20Functions,%20Loops%20tutorial.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Terraform Conditionals, Loops &amp;amp; Built-in Functions Explained&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVxrTtrpZg6hhVTElwLMNbBa_GQu9r02CqZixvGO4LTpezQ0v2-Jmmgm2PHpoUET2IVyXD88ytRcf2Qlqck6AmGfP3jLS_wJRixWq1a6s3ofbkRW1owc3VB9hcSethlnSDB12AP5CQiwdIYg3kj1BXWd9vjIUPOAaB3IEhjeTYSt4QQQ56dZh3EysDroe0/w640-h360/Terraform%20Conditionals,%20Built-in%20Functions,%20Loops%20tutorial.jpg&quot; width=&quot;Terraform Conditionals, Loops &amp;amp; Built-in Functions Explained&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;There are some scenario will come to apply the terraform infrastructure based on conditions, functions and loops. On such cases, we can use these feature in terraform codes efficiently. In this post, I will show you how to use terraform conditionals, terraform built-in functions and terraform loops with examples.&lt;/p&gt;&lt;p&gt;In the previous posts, we have covered the topic - &quot;&lt;a href=&quot;https://www.learnitguide.net/2024/09/what-is-terraform-modules-explained.html&quot; target=&quot;_blank&quot;&gt;What is Terraform Modules? Explained with Examples&lt;/a&gt;&quot;.&lt;/p&gt;&lt;p&gt;Let&#39;s get started.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: white; color: red; font-size: 18px; text-align: center;&quot;&gt;You can also Watch this tutorial demo on our YouTube Channel&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/nfmpzpfDBRM?si=TuWrPJVKqDkKJZ_K&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Terraform Conditionals:&lt;/h2&gt;&lt;p&gt;Terraform conditionals can be used to perform some actions based on some conditions, It is very similar to if else condition that we use in any programming languages.&lt;/p&gt;&lt;p&gt;Terraform conditional expression is as follows:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;condition ? true_value : false_value&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Where,&lt;/p&gt;&lt;p&gt;condition - It is the expression or condition we need to define, Based on the condition result, further value will be set. it generally return Boolean value ie, true or false.&lt;/p&gt;&lt;p&gt;true_value - This value will be set if the condition is true.&lt;/p&gt;&lt;p&gt;false_value - This value will be set if the condition is false.&lt;/p&gt;&lt;p&gt;Lets take an example that if I want to create one aws ec2 resource with instance type &quot;t2.micro&quot; using terraform for my dev environment as below.&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;text-align: left;&quot;&gt;variable &quot;environment&quot; {&lt;br /&gt;&amp;nbsp; default&amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;dev&quot;&lt;br /&gt;}&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;resource &quot;aws_instance&quot; &quot;web1&quot; {&lt;br /&gt;&amp;nbsp; ami&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;ami-0e86e20dae9224db8&quot;&lt;br /&gt;&amp;nbsp; instance_type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;t2.micro&quot;&lt;br /&gt;&amp;nbsp; subnet_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;subnet-0105b1aef1e7755cd&quot;&lt;br /&gt;&amp;nbsp; key_name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &quot;demov2&quot;&lt;br /&gt;&amp;nbsp; ebs_block_device {&lt;br /&gt;&amp;nbsp; &amp;nbsp; device_name = &quot;/dev/sda1&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; volume_size = 10&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; associate_public_ip_address = &quot;true&quot;&lt;br /&gt;&amp;nbsp; vpc_security_group_ids&amp;nbsp; &amp;nbsp; &amp;nbsp; = [&quot;sg-04dd813e22c5a0b2f&quot;]&lt;br /&gt;&amp;nbsp; tags = {&lt;br /&gt;&amp;nbsp; &amp;nbsp; Name = &quot;Web Server1&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; Environment = var.environment&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;/div&gt;&lt;p&gt;What if I want to create one more ec2 resources for production environment where I want my AWS EC2 with instance type &quot;t3.medium&quot; or &quot;t3.large&quot;. In general, we will copy the resource section and modify the values accordingly for production environment. But with terraform conditionals, we can simplify the code as below.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;variable &quot;environment&quot; {&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&amp;nbsp; default&amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;dev&quot;&lt;br /&gt;}&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;resource &quot;aws_instance&quot; &quot;web1&quot; {&lt;br /&gt;&amp;nbsp; ami&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;ami-0e86e20dae9224db8&quot;&lt;br /&gt;&amp;nbsp; &lt;b&gt;instance_type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= var.environment == &quot;prod&quot; ? &quot;t3.large&quot; : &quot;t2.micro&quot;&lt;/b&gt;&lt;br /&gt;&amp;nbsp; subnet_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;subnet-0105b1aef1e7755cd&quot;&lt;br /&gt;&amp;nbsp; key_name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &quot;demov2&quot;&lt;br /&gt;&amp;nbsp; ebs_block_device {&lt;br /&gt;&amp;nbsp; &amp;nbsp; device_name = &quot;/dev/sda1&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; volume_size = 10&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; associate_public_ip_address = &quot;true&quot;&lt;br /&gt;&amp;nbsp; vpc_security_group_ids&amp;nbsp; &amp;nbsp; &amp;nbsp; = [&quot;sg-04dd813e22c5a0b2f&quot;]&lt;br /&gt;&amp;nbsp; tags = {&lt;br /&gt;&amp;nbsp; &amp;nbsp; Name = &quot;Web Server1&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; Environment = var.environment&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Above condition is defined like, if the environment is &quot;prod&quot;, &quot;t3.large&quot; value will be set for instance_type. If any other environment except &quot;prod&quot;, then &quot;t2.micro&quot; instance_type will be set.&lt;/p&gt;&lt;p&gt;Either, we can modify the variable environment from &quot;dev&quot; to &quot;prod&quot; and apply the terraform or we can use &quot;-var&quot; options along with terraform command to override the environment variable.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;terraform apply -var &#39;environment=prod&#39;&amp;nbsp;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;its not only, you have to use terraform conditionals on instance_type. Wherever you think, the conditional logic can be applied, You can give a try.&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Terraform Loops:&lt;/h2&gt;&lt;p&gt;In terraform, We can achieve the terraform loops concept using for_each and count method.&lt;/p&gt;&lt;p&gt;Terraform loops are generally used when you have multiple values, but you need to use single resources.&lt;/p&gt;&lt;p&gt;For example, Lets say I need to create 10 AWS ec2 instance. On that case, we need to create 10 aws ec2 resource section. Instead, We can create these values in list and run through terraform loops.&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Using for_each:&lt;/h3&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;blockquote&gt;variable &quot;environment&quot; {&lt;br /&gt;&amp;nbsp; default&amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;dev&quot;&lt;br /&gt;}&lt;br /&gt;&lt;b&gt;variable &quot;ec2_names&quot; {&lt;br /&gt;&amp;nbsp; default = [&quot;web1&quot;, &quot;app1&quot;, &quot;db1&quot;]&lt;br /&gt;}&lt;/b&gt;&lt;br /&gt;resource &quot;aws_instance&quot; &quot;server&quot; {&lt;br /&gt;&amp;nbsp; &lt;b&gt;for_each&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;= toset(var.ec2_names)&lt;/b&gt;&lt;br /&gt;&amp;nbsp; ami&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;ami-0e86e20dae9224db8&quot;&lt;br /&gt;&amp;nbsp; instance_type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= var.environment == &quot;prod&quot; ? &quot;t3.large&quot; : &quot;t2.micro&quot;&lt;br /&gt;&amp;nbsp; subnet_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;subnet-0105b1aef1e7755cd&quot;&lt;br /&gt;&amp;nbsp; key_name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &quot;demov2&quot;&lt;br /&gt;&amp;nbsp; ebs_block_device {&lt;br /&gt;&amp;nbsp; &amp;nbsp; device_name = &quot;/dev/sda1&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; volume_size = 10&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; associate_public_ip_address = &quot;true&quot;&lt;br /&gt;&amp;nbsp; vpc_security_group_ids&amp;nbsp; &amp;nbsp; &amp;nbsp; = [&quot;sg-04dd813e22c5a0b2f&quot;]&lt;br /&gt;&amp;nbsp; tags = {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;b&gt;Name = each.value&lt;/b&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; Environment = var.environment&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/blockquote&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This will create each instances through loops based on each values.&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Using Count:&lt;/h3&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;blockquote&gt;variable &quot;environment&quot; {&lt;br /&gt;&amp;nbsp; default&amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;dev&quot;&lt;br /&gt;}&lt;br /&gt;resource &quot;aws_instance&quot; &quot;server&quot; {&lt;br /&gt;&amp;nbsp; &lt;b&gt;count&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; = 3&lt;/b&gt;&lt;br /&gt;&amp;nbsp; ami&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;ami-0e86e20dae9224db8&quot;&lt;br /&gt;&amp;nbsp; instance_type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= var.environment == &quot;prod&quot; ? &quot;t3.large&quot; : &quot;t2.micro&quot;&lt;br /&gt;&amp;nbsp; subnet_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;subnet-0105b1aef1e7755cd&quot;&lt;br /&gt;&amp;nbsp; key_name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &quot;demov2&quot;&lt;br /&gt;&amp;nbsp; ebs_block_device {&lt;br /&gt;&amp;nbsp; &amp;nbsp; device_name = &quot;/dev/sda1&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; volume_size = 10&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; associate_public_ip_address = &quot;true&quot;&lt;br /&gt;&amp;nbsp; vpc_security_group_ids&amp;nbsp; &amp;nbsp; &amp;nbsp; = [&quot;sg-04dd813e22c5a0b2f&quot;]&lt;br /&gt;&amp;nbsp; tags = {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;b&gt;Name = &quot;ec2-${count.index + 1}&quot;&lt;/b&gt;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/blockquote&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;if we define the value in count parameter, accordingly the resources will be looped and created.&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Built-in functions:&lt;/h3&gt;&lt;p&gt;Terraform built-in functions are pre defined functions that will help us to achieve or perform some actions. Terraform has lot of built-in functions to simply the code. You can find lot of functions from official terraform website&amp;nbsp; - https://developer.hashicorp.com/terraform/language/functions&lt;/p&gt;&lt;p&gt;&lt;b&gt;List of some Built-in functions:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;upper()&lt;/p&gt;&lt;p&gt;lower()&lt;/p&gt;&lt;p&gt;max()&lt;/p&gt;&lt;p&gt;replace()&lt;/p&gt;&lt;p&gt;join()&lt;/p&gt;&lt;p&gt;For example, if I want to change my Aws ec2 names into uppercase. We can use this upper() function to achieve the same as below.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;blockquote&gt;variable &quot;environment&quot; {&lt;br /&gt;&amp;nbsp; default&amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;dev&quot;&lt;br /&gt;}&lt;br /&gt;resource &quot;aws_instance&quot; &quot;server&quot; {&lt;br /&gt;&amp;nbsp; count&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; = 3&lt;br /&gt;&amp;nbsp; ami&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;ami-0e86e20dae9224db8&quot;&lt;br /&gt;&amp;nbsp; instance_type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= var.environment == &quot;prod&quot; ? &quot;t3.large&quot; : &quot;t2.micro&quot;&lt;br /&gt;&amp;nbsp; subnet_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;subnet-0105b1aef1e7755cd&quot;&lt;br /&gt;&amp;nbsp; key_name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &quot;demov2&quot;&lt;br /&gt;&amp;nbsp; ebs_block_device {&lt;br /&gt;&amp;nbsp; &amp;nbsp; device_name = &quot;/dev/sda1&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; volume_size = 10&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; associate_public_ip_address = &quot;true&quot;&lt;br /&gt;&amp;nbsp; vpc_security_group_ids&amp;nbsp; &amp;nbsp; &amp;nbsp; = [&quot;sg-04dd813e22c5a0b2f&quot;]&lt;br /&gt;&amp;nbsp; tags = {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;b&gt;Name = upper(&quot;ec2-${count.index + 1}&quot;)&lt;/b&gt;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/blockquote&gt;&lt;/div&gt;&lt;p&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/1830993285278298407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2025/06/terraform-conditionals-loops-built-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/1830993285278298407'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/1830993285278298407'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2025/06/terraform-conditionals-loops-built-in.html' title='Terraform Conditionals, Loops &amp; Built-in Functions Explained'/><author><name>Admin</name><uri>http://www.blogger.com/profile/03660103809536814792</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVxrTtrpZg6hhVTElwLMNbBa_GQu9r02CqZixvGO4LTpezQ0v2-Jmmgm2PHpoUET2IVyXD88ytRcf2Qlqck6AmGfP3jLS_wJRixWq1a6s3ofbkRW1owc3VB9hcSethlnSDB12AP5CQiwdIYg3kj1BXWd9vjIUPOAaB3IEhjeTYSt4QQQ56dZh3EysDroe0/s72-w640-h360-c/Terraform%20Conditionals,%20Built-in%20Functions,%20Loops%20tutorial.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-3088254595037271340</id><published>2024-09-29T05:37:00.000-07:00</published><updated>2025-06-15T21:04:26.627-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="AWS Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Cloud Computing"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>What is Terraform Modules? Explained with Examples</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS6huvTEAPngocp7-GMjvcSRSAjAa7eR-Gdl6UvK-LXFzVc9x9zBtRPB_8TDpNymcUa1W4wITFyYHcMw594JloQKwH-DcEnVjmASa_iAD2r32JN9pjnPcC2RPwgNbfZ2_rmGYLz1yQEFdH-PCYoQ655uJZXFGYId300EFoIGck6jxQcq0EXyXpepWR1aws/s1920/what%20is%20terraform%20modules.webp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;What is Terraform Modules? Explained with Examples&quot; border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1920&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS6huvTEAPngocp7-GMjvcSRSAjAa7eR-Gdl6UvK-LXFzVc9x9zBtRPB_8TDpNymcUa1W4wITFyYHcMw594JloQKwH-DcEnVjmASa_iAD2r32JN9pjnPcC2RPwgNbfZ2_rmGYLz1yQEFdH-PCYoQ655uJZXFGYId300EFoIGck6jxQcq0EXyXpepWR1aws/w640-h360/what%20is%20terraform%20modules.webp&quot; title=&quot;What is Terraform Modules? Explained with Examples&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This post will help you to understand what is terraform modules and explained terraform modules with examples. In the previous posts, we have covered the below topics to &lt;a href=&quot;/2024/09/create-aws-vpc-using-terraform.html&quot; target=&quot;_blank&quot;&gt;create AWS VPC using Terraform Resources&lt;/a&gt;. So we can create such infrastructure using terraform resources or terraform modules based on our tasks.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;div&gt;Let&#39;s Get Started.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, sans-serif&quot; style=&quot;background-color: white; color: red; font-size: 18px; text-align: center;&quot;&gt;You can also Watch this tutorial demo on our YouTube Channel&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, sans-serif&quot; style=&quot;background-color: white; color: red; font-size: 18px; text-align: center;&quot;&gt;&lt;br /&gt;&lt;iframe allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; src=&quot;https://www.youtube.com/embed/cZmh4C0ir28?si=SVKIgNXsBf62VJNo&quot; title=&quot;YouTube video player&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;What is Terraform Modules?&lt;/h2&gt;&lt;div&gt;Terraform modules are reusable units that are very well organized collections of Terraform configurations with infrastructure resources. They really help us to manage any complex infrastructure by grouping related resources, allowing for scalability and maintainence easily. By using modules, we can simplify our code, promote best practices and share the configurations across any different projects. Think of them like building blocks for your cloud infrastructure.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets take an example of creating AWS VPC using Terraform Modules.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the last post, we have created AWS VPC using individual terraform resources. For creating such AWS VPC, We identified around 9 components form VPC architecture. Also we created 1 security group and deployed 2 AWS EC2 on Public Subnet and Private Subnet to test it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;1. AWS VPC (Virtual Private Cloud)&lt;/div&gt;&lt;div&gt;2. AWS Internet Gateway (IGW)&lt;/div&gt;&lt;div&gt;3. AWS Public Subnet 1&lt;/div&gt;&lt;div&gt;4. AWS Private Subnet 1&lt;/div&gt;&lt;div&gt;5. AWS Public Route table 1&lt;/div&gt;&lt;div&gt;6. AWS Private Route table 1&lt;/div&gt;&lt;div&gt;7. AWS Public Route table 1 association with Public Subnet 1&lt;/div&gt;&lt;div&gt;8. AWS Private Route table 1 association with Private Subnet 1&lt;/div&gt;&lt;div&gt;9. AWS Security Group 1&lt;/div&gt;&lt;div&gt;10. AWS EC2 - Web1 (Public Subnet 1)&lt;/div&gt;&lt;div&gt;11. AWS EC2 - DB1 (Private Subnet 1)&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For all these list of components, We have found respective terraform resources from terraform registry and created resource section on vpc.tf. You can refer the code &lt;a href=&quot;/2024/09/create-aws-vpc-using-terraform.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If we use terraform modules for the same AWS VPC architecture. we can create the same setup with less than 10 lines.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can find all terraform modules from here -&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://registry.terraform.io/browse/modules&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://registry.terraform.io/browse/modules&lt;/a&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We need to identify the correct terraform modules that will suit for our tasks. So I will be using this terraform provided aws modules called vpc -&amp;nbsp;&lt;a href=&quot;https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/latest&quot; target=&quot;_blank&quot;&gt;https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/latest&lt;/a&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is my vpc.tf where i have copied examples from terraform modules and updated as per my requirement.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. VPC&lt;/div&gt;&lt;div&gt;2. 2 Public Subnets&lt;/div&gt;&lt;div&gt;3. 2 Private Subnets&lt;/div&gt;&lt;div&gt;4. Security group&lt;/div&gt;&lt;div&gt;5. AWS EC2&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With less number of lines in code, it creates a entire AWS VPC. Here you go.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;vpc.tf&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;provider&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;region&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;us-east-1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;module&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;vpc1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;source&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;terraform-aws-modules/vpc/aws&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;flipkart-vpc-dev&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.0.0/16&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;azs&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;us-east-1a&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;us-east-1b&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;private_subnets&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.1.0/24&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.2.0/24&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;public_subnets&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.101.0/24&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.102.0/24&quot;&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Terraform&lt;/span&gt; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Environment&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;dev&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_security_group&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;sg1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;flipkart-vpc-sg1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# &amp;nbsp; description = &quot;Allow TLS inbound traffic and all outbound traffic&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc1&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ingress&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;from_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;to_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;-1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr_blocks&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;115.99.14.198/32&quot;&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ingress&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;from_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;80&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;to_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;80&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;tcp&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr_blocks&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;0.0.0.0/0&quot;&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;egress&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;from_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;to_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;-1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr_blocks&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;0.0.0.0/0&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ipv6_cidr_blocks&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;::/0&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;flipkart-sg1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Managed_by&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;terraform&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_instance&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;web1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ami&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ami-0e86e20dae9224db8&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_type&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;t2.micro&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;subnet_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc1&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;public_subnets&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;demov1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;associate_public_ip_address&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_security_group_ids&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_security_group&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sg1&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Web1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;output&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;my_web1_public_ip&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_instance&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;web1&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;public_ip&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;output&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;my_web1_private_ip&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_instance&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;web1&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;private_ip&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After making all required changes to vpc.tf manifest files. we have to initialize the directory and apply it.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;terraform init&lt;/div&gt;&lt;div&gt;terraform apply --auto-approve&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Simply by copying the same modules multiple times, we can create multiple AWS VPC easily for different purposes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/3088254595037271340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2024/09/what-is-terraform-modules-explained.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/3088254595037271340'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/3088254595037271340'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2024/09/what-is-terraform-modules-explained.html' title='What is Terraform Modules? Explained with Examples'/><author><name>Admin</name><uri>http://www.blogger.com/profile/03660103809536814792</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS6huvTEAPngocp7-GMjvcSRSAjAa7eR-Gdl6UvK-LXFzVc9x9zBtRPB_8TDpNymcUa1W4wITFyYHcMw594JloQKwH-DcEnVjmASa_iAD2r32JN9pjnPcC2RPwgNbfZ2_rmGYLz1yQEFdH-PCYoQ655uJZXFGYId300EFoIGck6jxQcq0EXyXpepWR1aws/s72-w640-h360-c/what%20is%20terraform%20modules.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-6928012253971953309</id><published>2024-09-09T06:46:00.000-07:00</published><updated>2025-06-15T21:05:26.191-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="Cloud Computing"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><title type='text'>Create AWS VPC using Terraform - AWS Cloud Provisioning</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ0a_pUNiAx3NkYZ22McMq3EzK_KBTQK8GLyL3eWcRRlM0zWWpAyMBMb3jxggX19ha0-I8Ufqh2oZ2jdgjItlM9Mv4Q5hgfbEeSBHqKdKSOMU-8RSlnGIgmm8pgO45QffZSNad-WWVgKu0NZgz6zxOxIqcpOpvdWMfSqdlWQ8ejdsmuGYiNnNe1VUJ2aRX/s1920/how%20to%20create%20aws%20vpc%20using%20terraform.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Create AWS VPC using Terraform - AWS Cloud Provisioning&quot; border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1920&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ0a_pUNiAx3NkYZ22McMq3EzK_KBTQK8GLyL3eWcRRlM0zWWpAyMBMb3jxggX19ha0-I8Ufqh2oZ2jdgjItlM9Mv4Q5hgfbEeSBHqKdKSOMU-8RSlnGIgmm8pgO45QffZSNad-WWVgKu0NZgz6zxOxIqcpOpvdWMfSqdlWQ8ejdsmuGYiNnNe1VUJ2aRX/w640-h360/how%20to%20create%20aws%20vpc%20using%20terraform.jpg&quot; title=&quot;Create AWS VPC using Terraform - AWS Cloud Provisioning&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;This post will help you with How to Create AWS VPC using Terraform from basics. In the previous posts, we have covered below topics which are very important for this topic in order to create such AWS cloud provisioning.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;a href=&quot;/2024/07/introduction-to-terraform.html&quot; target=&quot;_blank&quot;&gt;Introduction to Terraform&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;/2024/08/terraform-basics-initial-configuration.html&quot; target=&quot;_blank&quot;&gt;Terraform Basics and Initial Configuration&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;/2024/08/what-is-terraform-resources-variables.html&quot; target=&quot;_blank&quot;&gt;What is Terraform Resources, Variables &amp;amp; Outputs&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;div&gt;Let&#39;s Get Started.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: red; font-family: &amp;quot;Open Sans&amp;quot;, sans-serif; font-size: 18px; text-align: center;&quot;&gt;You can also Watch this tutorial demo on our YouTube Channel&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: red; font-family: &amp;quot;Open Sans&amp;quot;, sans-serif; font-size: 18px; text-align: center;&quot;&gt;&lt;br /&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/r6YQMmnRycY?si=UehEsmrue6UzjZ4d&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;How to Create AWS VPC using Terraform?&lt;/h2&gt;&lt;div&gt;If you want to create AWS VPC using terraform, We must have proper cloud infrastrcuture architecture diagram or documents that should show the resources that are required for our AWS Cloud infrastructure. Based on it, we can start creating the Terraform manifests files one by one to provision AWS Cloud.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPg9ivrQhHO2VItyLo93zTUhhlNYpYvMUcRncfHCyIk5rAjoVGijsrPtqsfc6vTWS824be7D6mb8k18DNQYlhlCgzF-LjhNS6dsYYsBS1f4XLmdqPGmtK3U1fkbG_RCsYLNx9tWSnrrkcrsv-T-Rbvek-4m2gDPTRPBBIGUcuA1SaEVq1wEgNK4zqhpIr-/s641/aws%20vpc%20architecture.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;393&quot; data-original-width=&quot;641&quot; height=&quot;392&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPg9ivrQhHO2VItyLo93zTUhhlNYpYvMUcRncfHCyIk5rAjoVGijsrPtqsfc6vTWS824be7D6mb8k18DNQYlhlCgzF-LjhNS6dsYYsBS1f4XLmdqPGmtK3U1fkbG_RCsYLNx9tWSnrrkcrsv-T-Rbvek-4m2gDPTRPBBIGUcuA1SaEVq1wEgNK4zqhpIr-/w640-h392/aws%20vpc%20architecture.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets take an example of above architecture diagram for creating AWS VPC architecture with Terraform..&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First, List all the resources that are required to achieve the tasks easily.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div&gt;1. AWS VPC (Virtual Private Cloud)&lt;/div&gt;&lt;div&gt;2. AWS Internet Gateway (IGW)&lt;/div&gt;&lt;div&gt;3. AWS Public Subnet 1&lt;/div&gt;&lt;div&gt;4. AWS Private Subnet 1&lt;/div&gt;&lt;div&gt;5. AWS Public Route table 1&lt;/div&gt;&lt;div&gt;6. AWS Private Route table 1&lt;/div&gt;&lt;div&gt;7. AWS Public Route table 1 association with Public Subnet 1&lt;/div&gt;&lt;div&gt;8. AWS Private Route table 1 association with Private Subnet 1&lt;/div&gt;&lt;div&gt;9. AWS Security Group 1&lt;/div&gt;&lt;div&gt;10. AWS EC2 - Web1 (Public Subnet 1)&lt;/div&gt;&lt;div&gt;11. AWS EC2 - DB1 (Private Subnet 1)&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Second, Identify the correct terraform resources from &lt;a href=&quot;https://registry.terraform.io/providers/hashicorp/aws/latest/docs&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;terraform registry&lt;/a&gt; and go through each resources and its example. Copy the example block from each resources.&lt;/p&gt;&lt;p&gt;Adjust the values and fields as per our requirement.&lt;/p&gt;&lt;p&gt;Here is the complete terraform manifest files that will create AWS VPC architecture as per the diagram.&lt;/p&gt;&lt;p&gt;Note: AWS Secret Key and Access Key are configured through AWS CLI, so it will not be available in manifests files, Please use similar approach for AWS authentication.&lt;/p&gt;&lt;p&gt;&lt;b&gt;vpc.tf&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# 1. VPC&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_vpc&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;vpc1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr_block&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.0.0/16&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client_name&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;-vpc&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Managed_by&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;managed_by&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# 2. Internet Gateway&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_internet_gateway&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;igw1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_vpc&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client_name&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;-igw1&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Managed_by&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;managed_by&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# 3. Public Subnet 1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_subnet&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;pub_subnet1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_vpc&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr_block&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.1.0/24&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client_name&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;-pub_subnet1&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Managed_by&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;managed_by&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# 4. Private Subnet 1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_subnet&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;pri_subnet1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_vpc&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr_block&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;10.0.2.0/24&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client_name&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;-pri_subnet1&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Managed_by&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;managed_by&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# 5. Public RT 1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_route_table&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;pub_rt1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_vpc&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;route&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr_block&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;0.0.0.0/0&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;gateway_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_internet_gateway&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;igw1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client_name&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;-pub_rt1&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Managed_by&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;managed_by&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# 6. Private RT 1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_route_table&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;pri_rt1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_vpc&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client_name&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;-pri_rt1&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Managed_by&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;managed_by&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# 7. Public subnet 1 association&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_route_table_association&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;pubsub1_rt1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;subnet_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_subnet&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pub_subnet1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;route_table_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_route_table&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pub_rt1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# 8. Private Subnet 1 association&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_route_table_association&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;prisub1_rt1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;subnet_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_subnet&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pri_subnet1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;route_table_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_route_table&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pri_rt1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# 9. Security Group 1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_security_group&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;sg1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client_name&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;-sg1&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# &amp;nbsp; description = &quot;Allow TLS inbound traffic and all outbound traffic&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_vpc&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ingress&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;from_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;to_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;-1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr_blocks&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;115.99.14.198/32&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_vpc&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr_block&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ingress&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;from_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;80&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;to_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;80&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;tcp&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr_blocks&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;0.0.0.0/0&quot;&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;egress&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;from_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;to_port&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;-1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cidr_blocks&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;0.0.0.0/0&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ipv6_cidr_blocks&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;::/0&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client_name&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;-sg1&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Managed_by&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;managed_by&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# 10. Ec2 - web1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_instance&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;web1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ami&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ami-0e86e20dae9224db8&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_type&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;my-instance-type&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;subnet_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_subnet&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pub_subnet1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;demov1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;associate_public_ip_address&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_security_group_ids&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_security_group&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sg1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client_name&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;-web1&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Managed_by&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;managed_by&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# 11. Ec2 - DB1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;resource&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws_instance&quot;&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;db1&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ami&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ami-0e86e20dae9224db8&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_type&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;my-instance-type&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;subnet_id&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_subnet&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pri_subnet1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;demov1&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;vpc_security_group_ids&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_security_group&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sg1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;id&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Name&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client_name&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;-db1&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Managed_by&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;var&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;managed_by&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;output&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;my_web1_public_ip&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_instance&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;web1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;public_ip&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;output&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;my_web1_private_ip&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_instance&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;web1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;private_ip&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;output&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;my_db1_private_ip&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;aws_instance&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;db1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;private_ip&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Above vpc.tf manifest file is provided each resources and blocks to create all AWS VPC resources that is listed earlier.&lt;/p&gt;&lt;p&gt;Also I have used the advatanges of variables and updated the variable.tf and terraform.tfvars accordingly.&lt;/p&gt;&lt;p&gt;&lt;b&gt;provider.tf&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;provider&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;aws&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;region&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;us-east-1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;variable.tf&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;variable&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;my-instance-type&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;string&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;t2.micro&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;variable&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;client_name&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;my-default&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;variable&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;&quot;managed_by&quot;&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;devops&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;terraform.tfvars&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;my-instance-type&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;t2.micro&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client_name&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;coke&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;managed_by&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;=&lt;span style=&quot;color: #9cdcfe;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;terraform&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Once all these terraform manifests files are ready, we can plan and apply the terraform codes as below.&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;blockquote&gt;terraform plan&lt;br /&gt;terraform apply --auto-approve&lt;/blockquote&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;After terraform apply is completed, you can see the output of IP address as we have used output blocks in vpc.tf. Also you can login into AWS Cloud and verify all the resources are created as expected.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/6928012253971953309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2024/09/create-aws-vpc-using-terraform.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/6928012253971953309'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/6928012253971953309'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2024/09/create-aws-vpc-using-terraform.html' title='Create AWS VPC using Terraform - AWS Cloud Provisioning'/><author><name>Admin</name><uri>http://www.blogger.com/profile/03660103809536814792</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ0a_pUNiAx3NkYZ22McMq3EzK_KBTQK8GLyL3eWcRRlM0zWWpAyMBMb3jxggX19ha0-I8Ufqh2oZ2jdgjItlM9Mv4Q5hgfbEeSBHqKdKSOMU-8RSlnGIgmm8pgO45QffZSNad-WWVgKu0NZgz6zxOxIqcpOpvdWMfSqdlWQ8ejdsmuGYiNnNe1VUJ2aRX/s72-w640-h360-c/how%20to%20create%20aws%20vpc%20using%20terraform.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-4623366191611458967</id><published>2024-08-31T10:06:00.000-07:00</published><updated>2024-09-23T23:42:28.865-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="AWS EC2"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>What is Terraform Resources, Variables &amp; Outputs</title><content type='html'>&lt;p style=&quot;text-align: center;&quot;&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt-aF1noCCDOQ0xjhvKnkDmGlmUgXW6AHfJL7Zr27X07URXAwtnDZszoKlaPeNyAGgTGnfbuuGLsBVDXiRwZxRbRYm_yAxYROxEawRBE0Koj5c_9DX5fazJ0uCdrZG-V5Lfq2u87RbC2w4z9frr-vUn5UJfH9YLR3w4FSTmYn-55Q1y8Hhgf6iQX6JwGXz/s1920/What%20is%20Terraform%20Resources,%20Terraform%20Variables%20&amp;amp;%20Output.webp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;What is Terraform Resources, Terraform Variables &amp;amp; Output&quot; border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1920&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt-aF1noCCDOQ0xjhvKnkDmGlmUgXW6AHfJL7Zr27X07URXAwtnDZszoKlaPeNyAGgTGnfbuuGLsBVDXiRwZxRbRYm_yAxYROxEawRBE0Koj5c_9DX5fazJ0uCdrZG-V5Lfq2u87RbC2w4z9frr-vUn5UJfH9YLR3w4FSTmYn-55Q1y8Hhgf6iQX6JwGXz/w640-h360/What%20is%20Terraform%20Resources,%20Terraform%20Variables%20&amp;amp;%20Output.webp&quot; title=&quot;What is Terraform Resources, Terraform Variables &amp;amp; Output&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This post will help you to understand what is terraform resources, terraform variables and terraform outputs. Each topic is explained with examples. In the previous post, we have already covered&amp;nbsp;&lt;a href=&quot;https://www.learnitguide.net/2024/07/introduction-to-terraform.html&quot; target=&quot;_blank&quot;&gt;Introduction to Terraform&lt;/a&gt; and&amp;nbsp;&lt;a href=&quot;https://www.learnitguide.net/2024/08/terraform-basics-initial-configuration.html&quot; target=&quot;_blank&quot;&gt;Terraform Basics and Initial Configuration&lt;/a&gt;.&lt;p&gt;&lt;/p&gt;&lt;div&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;div&gt;Let&#39;s Get Started.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;Watch this tutorial demo on our YouTube Channel&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; src=&quot;https://www.youtube.com/embed/iornVj2NZ_s?si=VHs19NT6UzMs6l-2&quot; title=&quot;What is Terraform Resources, Variables &amp;amp; Outputs&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;What is Terraform Resources?&lt;/h2&gt;&lt;div&gt;Terraform resources are the important section that we define in terraform manifest files. These terraform resources will be used to manage specific services or applications.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;resource &quot;resource_name&quot; &quot;name1&quot; {&lt;/div&gt;&lt;div&gt;&amp;nbsp;key1 = value1&lt;/div&gt;&lt;div&gt;&amp;nbsp;key2 = value2&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Lets take an example. If we want to create EC2 instance in AWS cloud.&amp;nbsp; Then we have to use the terraform resources which will help us to manage AWS EC2 on AWS along with attributes like AMI ID, Instance type, Subnet ID, Security Group and so on.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;resource &quot;&lt;b&gt;aws_instance&lt;/b&gt;&quot; &quot;&lt;b&gt;web1&lt;/b&gt;&quot; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; ami&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;ami-0e86e20dae9224db8&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; instance_type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;t2.micro&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; subnet_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;subnet-0105b1aef1e7755cd&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; key_name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &quot;demov1&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; associate_public_ip_address = &quot;true&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; vpc_security_group_ids&amp;nbsp; &amp;nbsp; &amp;nbsp; = [&quot;sg-04dd813e22c5a0b2f&quot;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; tags = {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; Name = &quot;Web Server1&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Where,&amp;nbsp;&lt;/div&gt;&lt;div&gt;1. &quot;&lt;b&gt;aws_instance&lt;/b&gt;&quot; is the resource type provided by terraform to manage AWS EC2 instance. Similarly we may have more resources types to manage different resources like AWS S3, AWS EBS, AWS VPC, etc,.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We have to find the correct resource types that is suitable to create the terraform resources as per the request. These resources can be find in &lt;a href=&quot;https://registry.terraform.io/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;terraform registry&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2. &quot;&lt;b&gt;web1&lt;/b&gt;&quot; is the unique resource name should be used, this will be useful for terraform to manage the resources. For example, if we want to create multiple AWS EC2 instance, we cannot provide name like just &quot;&lt;b&gt;web&lt;/b&gt;&quot;. We have to call each resource with unique names like web1, web2, user1, user2.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3. Within resource section, lot of attributes are defined that are required to create the specific resources.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets say, we want to create AWS S3 bucket. On this case, we have to use the terraform resources called &quot;&lt;b&gt;aws_s3_bucket&lt;/b&gt;&quot;. We found these resource name from terraform registry and its supporting attributes.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;resource &quot;&lt;b&gt;aws_s3_bucket&lt;/b&gt;&quot; &quot;&lt;b&gt;my_bucket1&lt;/b&gt;&quot; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; bucket = &quot;my-unique-bucket-name-123456&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; acl&amp;nbsp; &amp;nbsp; = &quot;private&quot;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; tags = {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; Name = &quot;MyBucket&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Once we have defined all resources that we need to manage, then we can go for &quot;terraform plan&quot; or &quot;terraform apply&quot; command to proceed further.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets move on to Terraform Variables.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Terraform Variables&lt;/h2&gt;&lt;div&gt;Generally, variables are used to define a key value pair that will make our codes more flexible and reusable. Once variable is defined, we can refer the variable many times in all the terraform manifests files whereever we want.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For example, if i create 10 AWS ec2 instances with multiple resource sections with different EBS volume size and AMI ID for our applications. And all our instance types are same type like t2.micro. On this case, we dont want to specify t2.micro in all resource section. Instead. we can refer the variable name that we create for instance type.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Even this will help us to change the instance type only on variable if we want to modify it. If we dont have such variable option. We have to modify in all resource sections.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets see how to define terraform variables. In order to define variables in terraform, we have to create a variable section in any manifests file or create a dedicated variable.tf file.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;variable &quot;instance_type&quot; {&lt;/div&gt;&lt;div&gt;&lt;div&gt;&amp;nbsp; description = &quot;Our basic AWS EC2 instance type&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = string&lt;/div&gt;&lt;div&gt;&amp;nbsp; default&amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;t2.micro&quot;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Where,&lt;/div&gt;&lt;div&gt;&quot;instance_type&quot; is the variable name. This can be used in any resources sections whereever we want.&lt;/div&gt;&lt;div&gt;description is used to provide some information about the variable.&lt;/div&gt;&lt;div&gt;type is used to define the type of the resources. Eg, it may be string, integer, number, boolean, list, tuples.&lt;/div&gt;&lt;div&gt;default is the actual value where we define the value for the variable. This will be default value used for the variable, if no variable values is overridden. because, we can override variables using multiple ways, will talk about this in later section.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;resource &quot;aws_instance&quot; &quot;web1&quot; {&lt;/div&gt;&lt;div&gt;&lt;div&gt;&amp;nbsp; ami&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;ami-0e86e20dae9224db8&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; instance_type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &lt;b&gt;var.instance_type&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; subnet_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;subnet-0105b1aef1e7755cd&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; key_name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &quot;demov1&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; associate_public_ip_address = &quot;true&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; vpc_security_group_ids&amp;nbsp; &amp;nbsp; &amp;nbsp; = [&quot;sg-04dd813e22c5a0b2f&quot;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; tags = {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; Name = &quot;Web Server1&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;In the above example, if you see the instance_type attribute value, we used &quot;&lt;b&gt;var.instance_type&lt;/b&gt;&quot;. If you want to refer variable names, then we have to use the format like &quot;var.&quot; then variable name.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As I said before, variable section that we specify in manifest file is the default value will be used. There are different ways to define variables also it has priority in order to override the variables. I will list the same in ascending order.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;1. Command-Line Flags: &lt;/b&gt;We can pass terraform variables while running the terraform commands like below. This has the high priority.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;terraform apply -var=&quot;instance_type=t2.micro&quot;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2. Environment Variables: &lt;/b&gt;We can set values for variables using environment variables like below. As we use environment variables features of operating system, we have to use the prefix like TF_VAR to differentiate the terraform variables from other environment variables.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;export TF_VAR_instance_type=&quot;t2.micro&quot;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;3. Terraform variables (.tfvars): &lt;/b&gt;We can create dedicated file with extension .tfvars where we can define variables in key value pair format like below.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;instance_type = &quot;t2.micro&quot;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Lets move on to Terraform output.&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Terraform Output&lt;/h2&gt;&lt;div&gt;Terraform outputs are used to display the attribute value of any resource after it is created or updated. For example, if we create AWS EC2 isntance using terraform. We are not aware of the the attributes like public ip, private ip before creating the resources. These values will be created on AWS provider. So these values will be issued to terraform only after it is applied. So I want to know the such attributes, we have to login into AWS console and get the information. Instead we can use terraform output block to get the attribute.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;div&gt;output &quot;instance_id&quot; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; value = aws_instance.web1.id&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;output &quot;instance_public_ip&quot; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; value = aws_instance.web1.public_ip&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;Above output block will just display the instance ID and Public IP of the resources on the terminal itself.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/4623366191611458967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2024/08/what-is-terraform-resources-variables.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/4623366191611458967'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/4623366191611458967'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2024/08/what-is-terraform-resources-variables.html' title='What is Terraform Resources, Variables &amp; Outputs'/><author><name>Admin</name><uri>http://www.blogger.com/profile/03660103809536814792</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt-aF1noCCDOQ0xjhvKnkDmGlmUgXW6AHfJL7Zr27X07URXAwtnDZszoKlaPeNyAGgTGnfbuuGLsBVDXiRwZxRbRYm_yAxYROxEawRBE0Koj5c_9DX5fazJ0uCdrZG-V5Lfq2u87RbC2w4z9frr-vUn5UJfH9YLR3w4FSTmYn-55Q1y8Hhgf6iQX6JwGXz/s72-w640-h360-c/What%20is%20Terraform%20Resources,%20Terraform%20Variables%20&amp;%20Output.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-727193153563869644</id><published>2024-08-07T20:23:00.000-07:00</published><updated>2024-09-23T23:40:35.414-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Terraform Basics and Initial Configuration</title><content type='html'>&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzDXabdxQd7GrDoeAztDx0CyGpl270Y3pipkTsx5NSbyA5l0I3Vscwiq0GKP_IRZi4su2FaO1knAKYxXjDTYS92VP5ZkJIwqxCIy-btJ_0tIlnBFIyLXml14MXFy6sipnihBI58IAcslRVLtkPgV15HPWjGG3gpDfGgqtXi45amxkbAO2D5riKIRT3x05I/s1920/terraform%20basics%20and%20initial%20configuration.webp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Terraform Basics and Initial Configuration&quot; border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1920&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzDXabdxQd7GrDoeAztDx0CyGpl270Y3pipkTsx5NSbyA5l0I3Vscwiq0GKP_IRZi4su2FaO1knAKYxXjDTYS92VP5ZkJIwqxCIy-btJ_0tIlnBFIyLXml14MXFy6sipnihBI58IAcslRVLtkPgV15HPWjGG3gpDfGgqtXi45amxkbAO2D5riKIRT3x05I/w640-h360/terraform%20basics%20and%20initial%20configuration.webp&quot; title=&quot;Terraform Basics and Initial Configuration&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This post will help you to understand the terraform basics and how to do the terraform initial configurations. In the previous post, we have covered the terraform introduction, you can refer it if you want to start from&amp;nbsp;&lt;a href=&quot;/2024/07/introduction-to-terraform.html&quot; target=&quot;_blank&quot;&gt;terraform introduction&lt;/a&gt;?&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Topics Covered:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Terraform Basic Files&lt;/li&gt;&lt;li&gt;Terraform Providers&lt;/li&gt;&lt;li&gt;How Terraform Works?&lt;/li&gt;&lt;li&gt;Terraform Workflow with Commands&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;div&gt;Let&#39;s Get Started.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;You can also watch this entire tutorial on our Youtube channel with demo.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/6hazdZ340gA?si=_rGB17yC8jAVhvE7&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Terraform Basic Files&lt;/h2&gt;&lt;div&gt;In terraform, we do everything through files. So we should have knowledge on what are the types of terraform files we have and its purpose. Lets understand the terraform files first.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;TF files (.tf)&lt;/h3&gt;&lt;div&gt;Terraform files are created with .tf extension. Filename can be anything but .tf extension is must. Terraform will read only .tf files and other terraform files, It won&#39;t read any other file types.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Examples:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;main.tf&lt;/div&gt;&lt;div&gt;ec2.tf&lt;/div&gt;&lt;div&gt;vpc.tf&lt;/div&gt;&lt;div&gt;busapp_vpc.tf&lt;/div&gt;&lt;div&gt;iam_developer.tf&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;State files (.tfstate)&lt;/h3&gt;&lt;div&gt;Terraform always maintains a state file called terraform.tfstate whenever you apply your changes. This file will track the current state of your target infrastructure resources and store it in terraform.tfstate fille.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;terraform.tfstate&lt;/div&gt;&lt;div&gt;terraform.tfstate.backup (This file is backup of previous terraform.tfstate file.)&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Variable files (.tfvars)&lt;/h3&gt;&lt;div&gt;Terraform provides a dedicated files to define any variables that is needed for our infrastructure. These variables can be called in any of our terraform files wherever needed. We can create our variables files with extension .tfvars.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Examples:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;variables.tfvars&lt;/div&gt;&lt;div&gt;dev_env.tfvars&lt;/div&gt;&lt;div&gt;production.tfvars&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Terraform Providers&lt;/h2&gt;&lt;div&gt;Terraform providers are the most important component that tells the terraform to interact with cloud providers, API&#39;s, services. So providers are responsible to manage the resources on the target infrastructure.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Obviously we will write terraform files to manage some target infrastructure. That infrastructure is providers. We need to specify the providers (eg. AWS, Google Cloud, Azure, VMware) in the terraform files.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Terraform supports lot of providers.&amp;nbsp; That is why terraform is so popular.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is the link to find all supported terraform providers -&amp;nbsp;&lt;a href=&quot;https://registry.terraform.io/browse/providers&quot;&gt;Browse Providers | Terraform Registry&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets say, you have decided to manage your AWS infrastructure. In that case, your provider is AWS.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If we define the below provider section in terraform files, terraform will make sure to download all the necessary plugins and codes to talk to aws cloud api&#39;s so that we would be able to create or manage any resources within the AWS cloud environment. Also we have to create CLI based token on AWS like aws_access_key and aws_secret_key to manage resource through terraform tools. For any providers you choose, it should support such authentication, then only you can manage through cli.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;provider &quot;aws&quot; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; region&amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;us-west-2&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; access_key = &quot;my-access-key&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; secret_key = &quot;my-secret-key&quot;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Once terraform provider is defined, we can start writing further terraform files to create or manage any resources of the infrastructure. We will talk about how to create terraform resources in the next post.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;How Terraform Works?&lt;/h2&gt;&lt;div&gt;Terraform reads all your terraform files, starting with provider block, followed by all resources blocks.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then it builds a plan to create, update or delete resources based on the terraform configurations.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We need to provide instructions to terraform for the workflow. Lets understand the terraform workflow with commands.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Terraform Workflow&lt;/h2&gt;&lt;div&gt;1. First, Write terraform files.&lt;/div&gt;&lt;div&gt;2. Initialize terraform directory - &quot;terraform init&quot;&lt;/div&gt;&lt;div&gt;3. Validate terraform configuration - &quot;terraform validate&quot;&lt;/div&gt;&lt;div&gt;4. Generate execution plan and identify the changes - &quot;terraform plan&quot;&lt;/div&gt;&lt;div&gt;5. Apply terraform changes - &quot;terraform apply&quot;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Terraform Commands&lt;/h2&gt;&lt;div&gt;&lt;b&gt;terraform init&lt;/b&gt; - This command will initialize the current terraform directory and will download all necessary plugins, source codes that are needed to manage the infrastructure. It is based on the provider block you have defined in terraform files.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Once if you initialize your terraform directory, terraform will recognize all the terraform files.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;terraform validate&lt;/b&gt; - This terraform validate command helps you to validate for syntax errors in your terraform files.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;terraform plan&lt;/b&gt; - This command will be like a dry run. It will generate the execution plan and will show you the list of resources that are going to be affected if we apply the changes. So before applying any changes, its good to run the terraform plan command to understand the impact.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;terraform apply&lt;/b&gt; - This terraform apply command will be the main command that will apply the changes to your infrastructure based on the terraform configuration files you have created.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;terraform destroy&lt;/b&gt; - This command will delete all your resources on your infrastructure that is created through your terraform files.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/727193153563869644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2024/08/terraform-basics-initial-configuration.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/727193153563869644'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/727193153563869644'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2024/08/terraform-basics-initial-configuration.html' title='Terraform Basics and Initial Configuration'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzDXabdxQd7GrDoeAztDx0CyGpl270Y3pipkTsx5NSbyA5l0I3Vscwiq0GKP_IRZi4su2FaO1knAKYxXjDTYS92VP5ZkJIwqxCIy-btJ_0tIlnBFIyLXml14MXFy6sipnihBI58IAcslRVLtkPgV15HPWjGG3gpDfGgqtXi45amxkbAO2D5riKIRT3x05I/s72-w640-h360-c/terraform%20basics%20and%20initial%20configuration.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-5440232438554523799</id><published>2024-07-29T22:51:00.000-07:00</published><updated>2024-09-23T23:40:41.276-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform"/><category scheme="http://www.blogger.com/atom/ns#" term="Terraform Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Introduction to Terraform - Terraform Tutorial for Beginners</title><content type='html'>&lt;a aria-label=&quot;Introduction to Terraform - Terraform Tutorial for Beginners&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6UIxJUvuQFY0hwBUbp8580kzZzZfhrlFxvLLDYwpbeRjBI2eusHA4_PVjp3i6R5H5xyLO5s6tVnBROGvnxwheryNoeCx97MDihm4RzqQRPiBx574vYh5UJZzfv3mKUwMMjOTkZVXPMAjHfVjWk3oU4Nyks5e0ftYVbo-4T71sJZY7drq7GRGNcRo633bg/s1920/introduction%20to%20terraform.webp&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img alt=&quot;Introduction to Terraform - Terraform Tutorial for Beginners&quot; border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1920&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6UIxJUvuQFY0hwBUbp8580kzZzZfhrlFxvLLDYwpbeRjBI2eusHA4_PVjp3i6R5H5xyLO5s6tVnBROGvnxwheryNoeCx97MDihm4RzqQRPiBx574vYh5UJZzfv3mKUwMMjOTkZVXPMAjHfVjWk3oU4Nyks5e0ftYVbo-4T71sJZY7drq7GRGNcRo633bg/w640-h360/introduction%20to%20terraform.webp&quot; title=&quot;Introduction to Terraform - Terraform Tutorial for Beginners&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;In this post, we will take you through the Introduction to Terraform. This post will help you to understand the below topics.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Topics Covered:&lt;/h2&gt;&lt;div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;What is Infrastructure as a Code (IaC)?&lt;/li&gt;&lt;li&gt;List of IaC Tools&lt;/li&gt;&lt;li&gt;Introduction to Terraform&lt;/li&gt;&lt;li&gt;Why should we use Terraform and Its Benefits?&lt;/li&gt;&lt;li&gt;How Terraform works with Key Concepts&lt;/li&gt;&lt;li&gt;Terraform Installation on Windows &amp;amp; Linux&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;div&gt;Let&#39;s Get Started.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;You can also watch this entire tutorial on our youtube channel with demo.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; src=&quot;https://www.youtube.com/embed/CHpUUo_PSRI?si=jyOBe3lk0181RQNk&quot; title=&quot;YouTube video player&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;What is Infrastructure as a Code (IaC)?&lt;/h2&gt;&lt;div&gt;&lt;div&gt;Infrastructure as Code (IaC) helps us to automates the infrastructure provisioning by using codes, scripts or any tools instead of creating the infrastructure manually. Anything you create with codes, files, scripts or using any tools, those will be considered as Infrastructure as Code (IaC).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We can provision, manage or destroy our entire infrastructure using Infrastructure as code (IaC). It enables our organization to completely develop, deploy and scale cloud applications with greater speed, less risk and reduced cost.&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;List of IaC Tools&lt;/h2&gt;&lt;div&gt;Here are some of the most popular IaC Tools:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Terraform&lt;/li&gt;&lt;li&gt;AWS CloudFormation&lt;/li&gt;&lt;li&gt;Azure Resource Manager&lt;/li&gt;&lt;li&gt;Google Cloud Deployment Manager&lt;/li&gt;&lt;li&gt;Ansible&lt;/li&gt;&lt;li&gt;Chef&lt;/li&gt;&lt;li&gt;Puppet&lt;/li&gt;&lt;li&gt;SaltStack&lt;/li&gt;&lt;li&gt;Vagrant&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Introduction to Terraform?&lt;/h2&gt;&lt;div&gt;Terraform is an open-source infrastructure as code (IaC) tool created by HashiCorp for automating or provisioning infrastructure easily.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Users has to create files, define resources, modules and provision entire data center infrastructure easily, securely and efficiently using declarative configuration language known as HashiCorp Configuration Language (HCL), or optionally JSON.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Even Terraform can manage our existing and any popular service providers as well as custom in house solutions.&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Why should we use Terraform and Its Benefits?&lt;/h2&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;Infrastructure as Code (IaC)&lt;/b&gt; - Terraform Manages our entire infrastructure through codes, making our task easier to create, update and destroy it.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Consistency&lt;/b&gt; - Terraform ensure the same configuration defined in terraform files are applied across multiple environments like development, staging and production.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Automation&lt;/b&gt; - Terraform reduces human errors, syntax related issues and manual setup by automating infrastructure provisioning.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Version Control&lt;/b&gt; - Terraform has its inbuilt code tracking feature, so our infrastructure changes will be tracked in code, making easier to review and revert changes at any time.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Collaboration&lt;/b&gt; - Team members can work together on the same infrastructure configurations that improves collaboration from every team members and it increases the productivity.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Scalability&lt;/b&gt; - Using Terraform, We can easily scale our entire infrastructure up or down based on our project requirements.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Multi-Cloud&lt;/b&gt; - Terraform can manage the resources available across any different cloud providers from single terraform configuration.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;How Terraform works with Key Concepts&lt;/h2&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;Create files&lt;/b&gt;: Firstly, Create our infrastructure resources in .tf files using HashiCorp Configuration Language (HCL).&lt;/li&gt;&lt;li&gt;&lt;b&gt;Terraform Init&lt;/b&gt;: Execute the command &#39;terraform init&#39; to initialize the working directory and download the required providers plugins to connect with providers using API.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Terraform Plan&lt;/b&gt;: Execute the command &#39;terraform plan&#39; to validate and review the changes that is going to be affected before applying any changes. Its like a dry run.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Terraform Apply&lt;/b&gt;: Execute the command &#39;terraform apply&#39; to apply the desired changes to the infrastructure.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Review State&lt;/b&gt;: Once applied, state files will be created for tracking the desired state. It will hold the current configuration state of the infrastructure.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Terraform Destroy&lt;/b&gt;: Execute the command &#39;terraform destroy&#39; to completely remove the infrastructure managed by Terraform codes.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Terraform Installation on Windows &amp;amp; Linux&lt;/h2&gt;&lt;div&gt;Installing terraform is a straight forward procedure. We have to update the terraform official repository and we can install the terraform packages. I have provided the commands and instruction on how to install terraform on specific platforms.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;How to Install Terraform on Ubuntu?&lt;/h3&gt;&lt;div&gt;Download terraform gpg key, add terraform repository for the respective ubuntu releases and install terraform.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg&lt;/div&gt;&lt;div&gt;echo &quot;deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main&quot; | sudo tee /etc/apt/sources.list.d/hashicorp.list&lt;/div&gt;&lt;div&gt;sudo apt update &amp;amp;&amp;amp; sudo apt install terraform&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;How to Install Terraform on RHEL / CentOS?&lt;/h3&gt;&lt;div&gt;Install required dependency packages and update terraform repository to install terraform.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;sudo yum install -y yum-utils&lt;/div&gt;&lt;div&gt;sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo&lt;/div&gt;&lt;div&gt;sudo yum -y install terraform&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;How to Install Terraform on Windows?&lt;/h3&gt;&lt;div&gt;&lt;b&gt;Step 1: &lt;/b&gt;Use the below official links to download the respective binary files based on your windows platform.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;for i386 -&amp;nbsp;&lt;a href=&quot;https://releases.hashicorp.com/terraform/1.9.3/terraform_1.9.3_windows_386.zip&quot;&gt;https://releases.hashicorp.com/terraform/1.9.3/terraform_1.9.3_windows_386.zip&lt;/a&gt;&lt;/div&gt;&lt;div&gt;for amd64 -&amp;nbsp;&lt;a href=&quot;https://releases.hashicorp.com/terraform/1.9.3/terraform_1.9.3_windows_amd64.zip&quot;&gt;https://releases.hashicorp.com/terraform/1.9.3/terraform_1.9.3_windows_amd64.zip&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;If link not worked, go to Terraform official website and download the respective binary file from the link directly.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://www.terraform.io/downloads.html&quot;&gt;https://www.terraform.io/downloads.html&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Step 2: &lt;/b&gt;Unzip the downloaded zip file and copy the executable file to binary locations.&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;blockquote&gt;C:\Windows\System32&lt;/blockquote&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/5440232438554523799/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2024/07/introduction-to-terraform.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/5440232438554523799'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/5440232438554523799'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2024/07/introduction-to-terraform.html' title='Introduction to Terraform - Terraform Tutorial for Beginners'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6UIxJUvuQFY0hwBUbp8580kzZzZfhrlFxvLLDYwpbeRjBI2eusHA4_PVjp3i6R5H5xyLO5s6tVnBROGvnxwheryNoeCx97MDihm4RzqQRPiBx574vYh5UJZzfv3mKUwMMjOTkZVXPMAjHfVjWk3oU4Nyks5e0ftYVbo-4T71sJZY7drq7GRGNcRo633bg/s72-w640-h360-c/introduction%20to%20terraform.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-3283042436391956884</id><published>2024-06-06T06:26:00.000-07:00</published><updated>2024-06-06T21:09:00.129-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Docker"/><category scheme="http://www.blogger.com/atom/ns#" term="Docker Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Jenkins"/><category scheme="http://www.blogger.com/atom/ns#" term="Jenkins Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><title type='text'>How to Configure Docker Containers as Jenkins Build Agents?</title><content type='html'>&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCq4A3sF3ZvvHye-jYtLtsvjc-9oar-N2bVCCGhSboWEjgI3IzfA0SftciATmC-IT5fy3XV0_rIxxeEYAIDGb7xuvf4V5p8oMqrfxCO7wcXnUD6Z4Z1Krnt659me1Hk39od_8tb_KtHRAkOny4dSyXcfUo9_QQQMkcKoqSaHPBKCiSAeLWoiwwJ1OWqhw9/s1920/Configure%20Docker%20Containers%20as%20Jenkins%20Build%20Agents.webp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;How to Configure Docker Containers as Jenkins Build Agents&quot; border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1920&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCq4A3sF3ZvvHye-jYtLtsvjc-9oar-N2bVCCGhSboWEjgI3IzfA0SftciATmC-IT5fy3XV0_rIxxeEYAIDGb7xuvf4V5p8oMqrfxCO7wcXnUD6Z4Z1Krnt659me1Hk39od_8tb_KtHRAkOny4dSyXcfUo9_QQQMkcKoqSaHPBKCiSAeLWoiwwJ1OWqhw9/w640-h360/Configure%20Docker%20Containers%20as%20Jenkins%20Build%20Agents.webp&quot; title=&quot;How to Configure Docker Containers as Jenkins Build Agents?&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div&gt;This tutorial will show you the entire step by step procedure to configure docker containers as jenkins build agents for our jenkins build.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Jenkins build agents or build slaves usually setup for distributing the jenkins jobs and also resource utilization of these jenkins slaves are very less, These jenkins slave agents will run only when builds are scheduled. Else it will be removed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets assume you have already a running jenkins server. If not please go through this link &lt;a href=&quot;https://www.learnitguide.net/2023/10/install-and-configure-jenkins-on-ubuntu.html&quot; target=&quot;_blank&quot;&gt;How to install jenkins on Ubuntu?&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Server Specification:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Operating System: Ubuntu 20.04&lt;/div&gt;&lt;div&gt;Jenkins Server IP: 192.168.2.21&lt;/div&gt;&lt;div&gt;Docker Server IP: 192.168.2.22&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As we are going to setup the agent on docker. We need to install docker on server. For this purpose, I use the server (192.168.2.22)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First, lets install and configure the docker server ready for jenkins..&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Install Docker on Ubuntu 20.04:&lt;/h3&gt;&lt;div&gt;Use apt command to update the repository and install it as below.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;sudo apt-get update&lt;/div&gt;&lt;div&gt;sudo apt-get install docker.io&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Configure Docker Remote Host:&lt;/h3&gt;&lt;div&gt;Edit the docker service file and change the line to allow the remote API for Docker host.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Search for ExecStart and replace that line with given line.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock&lt;/blockquote&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Reload and restart docker service:&lt;/h3&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;sudo systemctl daemon-reload&lt;/div&gt;&lt;div&gt;sudo service docker restart&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Validate Docker Remote Host API&lt;/h3&gt;&lt;div&gt;Use curl command to easily validate the docker remote host API from localhost.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;curl http://localhost:4243/version&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Output:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;{&quot;Platform&quot;:{&quot;Name&quot;:&quot;&quot;},&quot;Components&quot;:[{&quot;Name&quot;:&quot;Engine&quot;,&quot;Version&quot;:&quot;24.0.5&quot;,&quot;Details&quot;:{&quot;ApiVersion&quot;:&quot;1.43&quot;,&quot;Arch&quot;:&quot;amd64&quot;,&quot;BuildTime&quot;:&quot;2023-08-21T19:50:14.000000000+00:00&quot;,&quot;Experimental&quot;:&quot;false&quot;,&quot;GitCommit&quot;:&quot;24.0.5-0ubuntu1~20.04.1&quot;,&quot;GoVersion&quot;:&quot;go1.20.3&quot;,&quot;KernelVersion&quot;:&quot;5.4.0-163-generic&quot;,&quot;MinAPIVersion&quot;:&quot;1.12&quot;,&quot;Os&quot;:&quot;linux&quot;}},{&quot;Name&quot;:&quot;containerd&quot;,&quot;Version&quot;:&quot;1.7.2&quot;,&quot;Details&quot;:{&quot;GitCommit&quot;:&quot;&quot;}},{&quot;Name&quot;:&quot;runc&quot;,&quot;Version&quot;:&quot;1.1.7-0ubuntu1~20.04.2&quot;,&quot;Details&quot;:{&quot;GitCommit&quot;:&quot;&quot;}},{&quot;Name&quot;:&quot;docker-init&quot;,&quot;Version&quot;:&quot;0.19.0&quot;,&quot;Details&quot;:{&quot;GitCommit&quot;:&quot;&quot;}}],&quot;Version&quot;:&quot;24.0.5&quot;,&quot;ApiVersion&quot;:&quot;1.43&quot;,&quot;MinAPIVersion&quot;:&quot;1.12&quot;,&quot;GitCommit&quot;:&quot;24.0.5-0ubuntu1~20.04.1&quot;,&quot;GoVersion&quot;:&quot;go1.20.3&quot;,&quot;Os&quot;:&quot;linux&quot;,&quot;Arch&quot;:&quot;amd64&quot;,&quot;KernelVersion&quot;:&quot;5.4.0-163-generic&quot;,&quot;BuildTime&quot;:&quot;2023-08-21T19:50:14.000000000+00:00&quot;}&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Login into the Jenkins server and validate the docker remote host to make sure there is a connection between jenkins and docker host.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;curl http://192.168.2.22:4243/version&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Output:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;{&quot;Platform&quot;:{&quot;Name&quot;:&quot;&quot;},&quot;Components&quot;:[{&quot;Name&quot;:&quot;Engine&quot;,&quot;Version&quot;:&quot;24.0.5&quot;,&quot;Details&quot;:{&quot;ApiVersion&quot;:&quot;1.43&quot;,&quot;Arch&quot;:&quot;amd64&quot;,&quot;BuildTime&quot;:&quot;2023-08-21T19:50:14.000000000+00:00&quot;,&quot;Experimental&quot;:&quot;false&quot;,&quot;GitCommit&quot;:&quot;24.0.5-0ubuntu1~20.04.1&quot;,&quot;GoVersion&quot;:&quot;go1.20.3&quot;,&quot;KernelVersion&quot;:&quot;5.4.0-163-generic&quot;,&quot;MinAPIVersion&quot;:&quot;1.12&quot;,&quot;Os&quot;:&quot;linux&quot;}},{&quot;Name&quot;:&quot;containerd&quot;,&quot;Version&quot;:&quot;1.7.2&quot;,&quot;Details&quot;:{&quot;GitCommit&quot;:&quot;&quot;}},{&quot;Name&quot;:&quot;runc&quot;,&quot;Version&quot;:&quot;1.1.7-0ubuntu1~20.04.2&quot;,&quot;Details&quot;:{&quot;GitCommit&quot;:&quot;&quot;}},{&quot;Name&quot;:&quot;docker-init&quot;,&quot;Version&quot;:&quot;0.19.0&quot;,&quot;Details&quot;:{&quot;GitCommit&quot;:&quot;&quot;}}],&quot;Version&quot;:&quot;24.0.5&quot;,&quot;ApiVersion&quot;:&quot;1.43&quot;,&quot;MinAPIVersion&quot;:&quot;1.12&quot;,&quot;GitCommit&quot;:&quot;24.0.5-0ubuntu1~20.04.1&quot;,&quot;GoVersion&quot;:&quot;go1.20.3&quot;,&quot;Os&quot;:&quot;linux&quot;,&quot;Arch&quot;:&quot;amd64&quot;,&quot;KernelVersion&quot;:&quot;5.4.0-163-generic&quot;,&quot;BuildTime&quot;:&quot;2023-08-21T19:50:14.000000000+00:00&quot;}&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;At this point, docker host is ready.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In order to run docker container as jenkins build agent, we need to create our docker images for jenkins build agents.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This docker image should be ready with all required packages for jenkins projects. For example, if our projects depends on git, maven, ant, artifactory. On that case, we have to install everything along with docker images.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So here is my basic dockerfile that I use for jenkins build agents.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;FROM ubuntu:20.04&lt;/div&gt;&lt;div&gt;RUN apt-get update &amp;amp;&amp;amp; \&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; apt-get install -qy openjdk-13-jdk &amp;amp;&amp;amp; \&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; apt-get install -qy git &amp;amp;&amp;amp; \&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; apt-get install -qy maven &amp;amp;&amp;amp; \&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; apt-get install -qy openssh-server &amp;amp;&amp;amp; \&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; mkdir -p /var/run/sshd &amp;amp;&amp;amp; \&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; apt-get -qy autoremove &amp;amp;&amp;amp; \&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; useradd -m jenkins -s /bin/bash &amp;amp;&amp;amp; \&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; mkdir -p /home/jenkins/.ssh/&lt;/div&gt;&lt;div&gt;COPY id_rsa.pub /home/jenkins/.ssh/authorized_keys&lt;/div&gt;&lt;div&gt;RUN chown -R jenkins:jenkins /home/jenkins/.ssh/&lt;/div&gt;&lt;div&gt;EXPOSE 22&lt;/div&gt;&lt;div&gt;CMD [&quot;/usr/sbin/sshd&quot;, &quot;-D&quot;]&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Above dockerfile will build the docker image from Ubuntu 20 and will install required packages, user creations and other configurations required.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Also there is a line mentioned to copy SSH public key to a SSH folder. This key will be used by jenkins while launching the docker container to login and perform actions as per the jenkins build. So lets create SSH key.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;selva@docker-host:~$ ssh-keygen&lt;/div&gt;&lt;div&gt;Generating public/private rsa key pair.&lt;/div&gt;&lt;div&gt;Enter file in which to save the key (/home/selva/.ssh/id_rsa): Enter passphrase (empty for no passphrase):&lt;/div&gt;&lt;div&gt;Enter same passphrase again:&lt;/div&gt;&lt;div&gt;Your identification has been saved in /home/selva/.ssh/id_rsa&lt;/div&gt;&lt;div&gt;Your public key has been saved in /home/selva/.ssh/id_rsa.pub&lt;/div&gt;&lt;div&gt;The key fingerprint is:&lt;/div&gt;&lt;div&gt;SHA256:1lEHdHxUMF8rJDdfky9wsrMXQTcLkPrh4AsAtL+eyec selva@docker-host&lt;/div&gt;&lt;div&gt;The key&#39;s randomart image is:&lt;/div&gt;&lt;div&gt;+---[RSA 3072]----+&lt;/div&gt;&lt;div&gt;|&amp;nbsp; ..&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;+*O*=O|&lt;/div&gt;&lt;div&gt;|&amp;nbsp; &amp;nbsp;..&amp;nbsp; &amp;nbsp; &amp;nbsp; o*oB=O|&lt;/div&gt;&lt;div&gt;|&amp;nbsp; &amp;nbsp;..&amp;nbsp; &amp;nbsp; &amp;nbsp;o&amp;nbsp; * *o|&lt;/div&gt;&lt;div&gt;|&amp;nbsp; &amp;nbsp; ..&amp;nbsp; &amp;nbsp;+ oo + .|&lt;/div&gt;&lt;div&gt;|&amp;nbsp; &amp;nbsp; &amp;nbsp;.. S = .o o |&lt;/div&gt;&lt;div&gt;|&amp;nbsp; &amp;nbsp; &amp;nbsp; .o . o. .&amp;nbsp; |&lt;/div&gt;&lt;div&gt;|&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; . .&amp;nbsp; .&amp;nbsp; &amp;nbsp;|&lt;/div&gt;&lt;div&gt;|&amp;nbsp; &amp;nbsp; o o. .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/div&gt;&lt;div&gt;|&amp;nbsp; &amp;nbsp; &amp;nbsp;=oE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/div&gt;&lt;div&gt;+----[SHA256]-----+&lt;/div&gt;&lt;div&gt;selva@docker-host:~$&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;At this point, we will have both public and privay key in the same directory. So we can build the docker images.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Build Docker Image for Jenkins Build Agents:&lt;/h3&gt;&lt;div&gt;As you are in the same directory, we can build the docker image using the below command.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo docker build -t learnitguide/jenkins-slave-agent:1.0 .&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Replace with your docker hub repository name (learnitguide/jenkins-slave-agent) and tag (1.0) as per your need.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Our docker image is ready.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Push Docker Image to Docker Registry:&lt;/h3&gt;&lt;div&gt;Login into docker hub registry using below command and push the image to docker hub. Then only our image will be pulled from jenkins to launch the docker container.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo docker login&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Use &quot;docker push&quot; command to push the docker image to docker hub registry.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo docker push learnitguide/jenkins-slave-agent:1.0&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Now the jenkins build agent docker image is pushed to our docker image registry. This image will be used on jenkins to build the agents.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets go to jenkins and configure the Jenkins Build agents.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Configure Jenkins Build Agents:&lt;/h3&gt;&lt;div&gt;It required more steps to be done, so you can refer the below youtube video.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe class=&#39;lazy&#39; width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/-b4KssJg6qg?si=Sff5_y5SPKt8HEPW&quot; title=&quot;How to Configure Docker Containers as Jenkins Build Agents?&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/p&gt;&lt;div&gt;&lt;p&gt;&lt;b&gt;Related Searches and Questions asked:&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;li&gt;&lt;a aria-label=&quot;Accessing Kubernetes Service from Localhost&quot; href=&quot;https://www.learnitguide.net/2023/05/accessing-kubernetes-service-from.html&quot; target=&quot;_blank&quot;&gt;Accessing Kubernetes Service from Localhost&lt;/a&gt;&lt;a aria-label=&quot;&quot; href=&quot;https://www.learnitguide.net/2023/05/it-seems-like-you-have-entered-word-dum.html&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;Helm: Render Chart Templates Locally&quot; href=&quot;https://www.learnitguide.net/2023/05/helm-render-chart-templates-locally.html&quot; target=&quot;_blank&quot;&gt;Helm: Render Chart Templates Locally&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;How to Configure DNS for Applications Deployed on Kubernetes?&quot; href=&quot;https://www.learnitguide.net/2023/05/how-to-configure-dns-for-applications.html&quot; target=&quot;_blank&quot;&gt;How to Configure DNS for Applications Deployed on Kubernetes?&lt;/a&gt;&lt;/li&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/3283042436391956884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2024/06/configure-docker-containers-jenkins-build-agents.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/3283042436391956884'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/3283042436391956884'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2024/06/configure-docker-containers-jenkins-build-agents.html' title='How to Configure Docker Containers as Jenkins Build Agents?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCq4A3sF3ZvvHye-jYtLtsvjc-9oar-N2bVCCGhSboWEjgI3IzfA0SftciATmC-IT5fy3XV0_rIxxeEYAIDGb7xuvf4V5p8oMqrfxCO7wcXnUD6Z4Z1Krnt659me1Hk39od_8tb_KtHRAkOny4dSyXcfUo9_QQQMkcKoqSaHPBKCiSAeLWoiwwJ1OWqhw9/s72-w640-h360-c/Configure%20Docker%20Containers%20as%20Jenkins%20Build%20Agents.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-6863521592385433225</id><published>2023-10-17T19:36:00.003-07:00</published><updated>2023-10-17T22:01:07.163-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CentOS"/><category scheme="http://www.blogger.com/atom/ns#" term="CentOS 8"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Jenkins"/><category scheme="http://www.blogger.com/atom/ns#" term="Jenkins Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Howto"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Server"/><title type='text'>How to Install Jenkins on CentOS 8?</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a aria-label=&quot;How to Install Jenkins on CentOS 8&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrc_rKOOJIu5RWE7R4VSZrgptVHMLK9vKC9QlNChuf2PxEGOMXfy2yFw5bNDGPzneZIxN4Pq4bD2kIjCMnCZZCdc5F9zGsB5raWdLenWFs53lT3xnebYPXs5_oEIwp5Gns3_yWzfndcno7Mcfyvm1awAy4zmJocMIpWXIvTf-_eiYX2GbUN_wJx4gHdcDv/s1280/install%20and%20configure%20jenkins%20on%20centos%208.webp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;How to Install Jenkins on CentOS 8&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrc_rKOOJIu5RWE7R4VSZrgptVHMLK9vKC9QlNChuf2PxEGOMXfy2yFw5bNDGPzneZIxN4Pq4bD2kIjCMnCZZCdc5F9zGsB5raWdLenWFs53lT3xnebYPXs5_oEIwp5Gns3_yWzfndcno7Mcfyvm1awAy4zmJocMIpWXIvTf-_eiYX2GbUN_wJx4gHdcDv/s16000/install%20and%20configure%20jenkins%20on%20centos%208.webp&quot; title=&quot;How to Install Jenkins on CentOS 8&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;This article will provide you the step-by-step guide on how to install Jenkins on CentOS 8:&lt;/p&gt;&lt;div&gt;In the previous post, We have covered below topics on Jenkins.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1.&amp;nbsp;&lt;a href=&quot;https://www.learnitguide.net/2023/10/jenkins-introduction-advantages-cicd.html&quot; target=&quot;_blank&quot;&gt;Jenkins Introduction, Advantages, CI/CD Workflow Explained&lt;/a&gt;&lt;/div&gt;&lt;div&gt;2.&amp;nbsp;&lt;a href=&quot;https://www.learnitguide.net/2023/10/install-and-configure-jenkins-on-ubuntu.html&quot; target=&quot;_blank&quot;&gt;How to Install and Configure Jenkins on Ubuntu 20.04?&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;div&gt;Let&#39;s Get Started.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Prerequisites:&lt;/h2&gt;&lt;div&gt;1. Centos 8 or CentOS 8 Steam Installed Server&lt;/div&gt;&lt;div&gt;2. Internet must be enabled to fetch and install required packages.&lt;/div&gt;&lt;div&gt;3. Admin privileges (root or sudo access)&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Steps to Install Jenkins on CentOS 8&lt;/h2&gt;&lt;div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 1: Update the System&lt;/h3&gt;Before installing Jenkins, it&#39;s essential to ensure your CentOS system is up to date. Open your terminal and run the following commands:&lt;br /&gt;&lt;blockquote&gt;sudo yum update&lt;/blockquote&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 2: Install Java&lt;/h3&gt;Jenkins requires Java to run. You can install OpenJDK, which is open-source and compatible with Jenkins:&lt;br /&gt;&lt;blockquote&gt;sudo yum -y install java-11-openjdk-devel&lt;/blockquote&gt;After the installation is complete, verify the Java version:&lt;br /&gt;&lt;blockquote&gt;java -version&lt;/blockquote&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 3: Add Jenkins Repository&lt;/h3&gt;To install the latest version of Jenkins, add the Jenkins repository:&lt;br /&gt;&lt;blockquote&gt;sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo&lt;br /&gt;sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io-2023.key&lt;/blockquote&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 4: Install Jenkins&lt;/h3&gt;Now, you can install Jenkins using the following command:&lt;br /&gt;&lt;blockquote&gt;sudo yum -y install jenkins&lt;/blockquote&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 5: Start and Enable Jenkins&lt;/h3&gt;Once Jenkins is installed, start the service and enable it to start on boot:&lt;br /&gt;&lt;blockquote&gt;sudo systemctl start jenkins&lt;br /&gt;sudo systemctl enable jenkins&lt;/blockquote&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 6: Check Jenkins Status&lt;/h3&gt;To verify that Jenkins is running, use the following command:&lt;br /&gt;&lt;blockquote&gt;sudo systemctl status jenkins&lt;/blockquote&gt;You should see a message indicating that Jenkins is active and running.&lt;/div&gt;&lt;div&gt;&lt;h3&gt;Step 7. Allow Port 8080 on Firewall:&lt;/h3&gt;If you have firewalld enabled on your server, then we must allow our Jenkins default port 8080 to make it accessible from network, if not we can ignore this step.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To allow incoming traffic on port 8080, run:&lt;br /&gt;&lt;blockquote&gt;sudo firewall-cmd --permanent --add-port=8080/tcp&lt;br /&gt;sudo firewall-cmd --reload&lt;/blockquote&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 8: Unlock Jenkins&lt;/h3&gt;Jenkins is initially locked, and you need to retrieve the initial admin password to unlock it. Run this command to get the password:&lt;br /&gt;&lt;blockquote&gt;sudo cat /var/lib/jenkins/secrets/initialAdminPassword&lt;/blockquote&gt;This command will display the password you need to unlock Jenkins. Copy it.&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 9: Access Jenkins Web Interface&lt;/h3&gt;Open a web browser and enter your server&#39;s IP address followed by port 8080, like this: http://your_server_ip:8080.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;You will be prompted to enter the initial admin password obtained in Step 7. Paste the password and click &quot;Continue.&quot;&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 10: Install Recommended Plugins&lt;/h3&gt;Select the &quot;Install suggested plugins&quot; option. Jenkins will begin downloading and installing the required plugins.&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 11: Create an Admin User&lt;/h3&gt;After the plugins are installed, you&#39;ll be prompted to create an admin user. Fill in the required details.&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 12: Start Using Jenkins&lt;/h3&gt;Once you&#39;ve completed the setup, Jenkins is ready to use. You can start creating and managing your Jenkins jobs to automate your development workflows.&lt;br /&gt;&lt;br /&gt;By following these steps, you&#39;ve successfully installed Jenkins on your CentOS 8 server, and you&#39;re now ready to harness its automation capabilities for your projects.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2&gt;Additional Configurations on Jenkins:&lt;/h2&gt;&lt;div&gt;Any Users created in jenkins console are only to manage jenkins through web browser. Bydefault, user &#39;jenkins&#39; only runs everything in background even if you have loggedin using any users on portal and this user &quot;jenkins&quot; is created during the installation at the Operating system level, but it is a non-root user.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;cat /etc/passwd | grep -i jenkins&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;jenkins:x:114:118:Jenkins,,,:/var/lib/jenkins:/bin/bash&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;So When user &quot;jenkins&quot; doesnt have sufficient previleges at the Operating system level, this user cannot perform all administrative level tasks. So we must configure sudo to gain the administrative level access.&lt;/div&gt;&lt;h3&gt;SUDO Access:&lt;/h3&gt;&lt;div&gt;Edit /etc/sudoers file and add below entry to allow user &quot;jenkins&quot; to use sudo with nopasswd prompt and also disable requiretty option.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;jenkins ALL=(ALL) NOPASSWD: ALL&lt;/div&gt;&lt;div&gt;Defaults !requiretty&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;h3&gt;Change Jenkins user shell:&lt;/h3&gt;&lt;div&gt;Verify the &quot;jenkins&quot; user shell. If it is already specified with &quot;/bin/bash&quot;, You can ignore this. If not, we must change the user shell, this would help us to perform any tasks using CLI.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;cat /etc/passwd | grep -i jenkins&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;jenkins:x:995:992:Jenkins Automation Server:/var/lib/jenkins:&lt;b&gt;/bin/bash&lt;/b&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;h3&gt;Restart Service:&lt;/h3&gt;&lt;div&gt;&lt;blockquote&gt;sudo systemctl restart jenkins&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;b&gt;Related Searches and Questions asked:&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;a aria-label=&quot;How to Configure Jenkins Mail Notification on Build Failures&quot; href=&quot;https://www.learnitguide.net/2018/08/how-to-configure-jenkins-mail.html&quot; target=&quot;_blank&quot;&gt;How to Configure Jenkins Mail Notification on Build Failures&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;a aria-label=&quot;How to Configure Jenkins behind Proxy to Install Plugins&quot; href=&quot;https://www.learnitguide.net/2018/08/how-to-configure-jenkins-behind-proxy.html&quot; target=&quot;_blank&quot;&gt;How to Configure Jenkins behind Proxy to Install Plugins&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a aria-label=&quot;How to Reset Forgotten Jenkins Admin User Password&quot; href=&quot;https://www.learnitguide.net/2018/08/how-to-reset-forgotten-jenkins-admin.html&quot; target=&quot;_blank&quot;&gt;How to Reset Forgotten Jenkins Admin User&#39;s Password&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a aria-label=&quot;How to Install &amp;amp; Configure Jenkins on Linux Easily&quot; href=&quot;https://www.learnitguide.net/2018/05/how-to-install-configure-jenkins-on.html&quot; target=&quot;_blank&quot;&gt;How to Install &amp;amp; Configure Jenkins on Linux Easily&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/6863521592385433225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2023/10/how-to-install-jenkins-on-centos-8.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/6863521592385433225'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/6863521592385433225'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2023/10/how-to-install-jenkins-on-centos-8.html' title='How to Install Jenkins on CentOS 8?'/><author><name>Admin</name><uri>http://www.blogger.com/profile/03660103809536814792</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrc_rKOOJIu5RWE7R4VSZrgptVHMLK9vKC9QlNChuf2PxEGOMXfy2yFw5bNDGPzneZIxN4Pq4bD2kIjCMnCZZCdc5F9zGsB5raWdLenWFs53lT3xnebYPXs5_oEIwp5Gns3_yWzfndcno7Mcfyvm1awAy4zmJocMIpWXIvTf-_eiYX2GbUN_wJx4gHdcDv/s72-c/install%20and%20configure%20jenkins%20on%20centos%208.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-9101458297419497738</id><published>2023-10-17T02:09:00.005-07:00</published><updated>2023-10-17T19:34:37.502-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Jenkins"/><category scheme="http://www.blogger.com/atom/ns#" term="Jenkins Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Howto"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Videos"/><category scheme="http://www.blogger.com/atom/ns#" term="Ubuntu"/><category scheme="http://www.blogger.com/atom/ns#" term="Ubuntu 20"/><category scheme="http://www.blogger.com/atom/ns#" term="Ubuntu Howto"/><title type='text'>How to Install and Configure Jenkins on Ubuntu 20.04?</title><content type='html'>&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a aria-label=&quot;Install and Configure Jenkins on Ubuntu 20.04&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTuDsgSMGN5as4e-EAGw4m86Dt9B7rQpLoxKi12uRLFQ17DovLUHhjXTQNZcC2K2IPDfv8bpOE0rtcHYGDfUAE1VvGiTcR6HdlV7xmEyn1xjQGEeR82zuONX_oqGz4qQlG43Sz1nL8WBPpJd9q0oOl1dr6pfhTTL8Rp1XTQ_ReEmmBSRL4NEW-uWc_CEJX/s1280/install%20and%20configure%20jenkins%20on%20ubuntu%2020.webp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Install and Configure Jenkins on Ubuntu 20.04&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTuDsgSMGN5as4e-EAGw4m86Dt9B7rQpLoxKi12uRLFQ17DovLUHhjXTQNZcC2K2IPDfv8bpOE0rtcHYGDfUAE1VvGiTcR6HdlV7xmEyn1xjQGEeR82zuONX_oqGz4qQlG43Sz1nL8WBPpJd9q0oOl1dr6pfhTTL8Rp1XTQ_ReEmmBSRL4NEW-uWc_CEJX/s16000/install%20and%20configure%20jenkins%20on%20ubuntu%2020.webp&quot; title=&quot;Install and Configure Jenkins on Ubuntu 20.04&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;If you&#39;re running Ubuntu 20.04 and want to install Jenkins easily, you&#39;re in the right place. In this guide, we&#39;ll walk you through the process of How to Install and Configure Jenkins on Ubuntu 20.04, step by step, along with commands and examples to make the journey smoother.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the previous post, We have covered below topics, You can refer the link &quot;&lt;a href=&quot;https://www.learnitguide.net/2023/10/jenkins-introduction-advantages-cicd.html&quot; target=&quot;_blank&quot;&gt;Jenkins Introduction, Advantages, CI/CD Workflow Explained&lt;/a&gt;&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. Introduction to Jenkins&lt;/div&gt;&lt;div&gt;2. Advantages of Jenkins&lt;/div&gt;&lt;div&gt;3. CI/CD Workflow Explained with Examples.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Let&#39;s Get Started.&lt;/p&gt;&lt;h2&gt;Prerequisites:&lt;/h2&gt;&lt;div&gt;1. Ubuntu 20.04 Installed Server&lt;/div&gt;&lt;div&gt;2. Internet must be enabled to fetch and install required packages.&lt;/div&gt;&lt;div&gt;3. Admin privileges (root or sudo access)&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Steps to Install Jenkins on Ubuntu 20.04&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 1: Update the System&lt;/h3&gt;&lt;div&gt;The first step is to ensure your Ubuntu system is up to date. Open a terminal and run the following commands:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo apt-get update&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;This will update the package lists and upgrade the installed packages to their latest versions.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 2: Install Java&lt;/h3&gt;&lt;div&gt;Jenkins requires Java to run. You can install OpenJDK, which is open-source and compatible with Jenkins:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo apt-get -y install openjdk-11-jdk&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;After the installation is complete, verify the Java version:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;java -version&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;openjdk version &quot;11.0.20.1&quot; 2023-08-24&lt;/div&gt;&lt;div&gt;OpenJDK Runtime Environment (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04)&lt;/div&gt;&lt;div&gt;OpenJDK 64-Bit Server VM (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 3: Add Jenkins Repository&lt;/h3&gt;&lt;div&gt;You need to add the Jenkins repository to your system to install the latest version. Import the GPG key and add the Jenkins repository:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -&lt;/div&gt;&lt;div&gt;sudo sh -c &#39;echo deb http://pkg.jenkins.io/debian-stable binary/ &amp;gt; /etc/apt/sources.list.d/jenkins.list&#39;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 4: Install Jenkins&lt;/h3&gt;&lt;div&gt;Now, you can update the repositories to fetch latest packages:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo apt-get update&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;If you noticed below GPG error, We must add the key manually to make it work. If not, Ignore this step.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;Reading package lists... Done&lt;/div&gt;&lt;div&gt;W: GPG error: https://pkg.jenkins.io/debian-stable binary/ Release: The following signatures couldn&#39;t be verified because the public key is not available: NO_PUBKEY 5BA31D57EF5975CA&lt;/div&gt;&lt;div&gt;E: The repository &#39;http://pkg.jenkins.io/debian-stable binary/ Release&#39; is not signed.&lt;/div&gt;&lt;div&gt;N: Updating from such a repository can&#39;t be done securely, and is therefore disabled by default.&lt;/div&gt;&lt;div&gt;N: See apt-secure(8) manpage for repository creation and user configuration details.&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Resolve the above GPG error using below command.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5BA31D57EF5975CA&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;Executing: /tmp/apt-key-gpghome.uLnySvtJYM/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 5BA31D57EF5975CA&lt;/div&gt;&lt;div&gt;gpg: key 5BA31D57EF5975CA: public key &quot;Jenkins Project &amp;lt;jenkinsci-board@googlegroups.com&amp;gt;&quot; imported&lt;/div&gt;&lt;div&gt;gpg: Total number processed: 1&lt;/div&gt;&lt;div&gt;gpg:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;imported: 1&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Now try installing Jenkins using apt-get command.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo apt-get -y install jenkins&lt;/blockquote&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 5: Start and Enable Jenkins&lt;/h3&gt;&lt;div&gt;Once Jenkins is installed, start the service and enable it to start on boot:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;sudo systemctl start jenkins&lt;/div&gt;&lt;div&gt;sudo systemctl enable jenkins&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 6: Check Jenkins Status&lt;/h3&gt;&lt;div&gt;To verify that Jenkins is running, use the following command:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo systemctl status jenkins&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;You should see a message indicating that Jenkins is active and running.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 7: Unlock Jenkins&lt;/h3&gt;&lt;div&gt;Jenkins is initially locked, and you need to retrieve the initial admin password to unlock it. Run this command to get the password:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;sudo cat /var/lib/jenkins/secrets/initialAdminPassword&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;This command will display the password you need to unlock Jenkins. Copy it.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 8: Access Jenkins Web Interface&lt;/h3&gt;&lt;div&gt;Open a web browser and enter your server&#39;s IP address followed by port 8080, like this: http://your_server_ip:8080.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You will be prompted to enter the initial admin password obtained in Step 7. Paste the password and click &quot;Continue.&quot;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 9: Install Recommended Plugins&lt;/h3&gt;&lt;div&gt;Select the &quot;Install suggested plugins&quot; option. Jenkins will begin downloading and installing the required plugins.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 10: Create an Admin User&lt;/h3&gt;&lt;div&gt;After the plugins are installed, you&#39;ll be prompted to create an admin user. Fill in the required details.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 11: Start Using Jenkins&lt;/h3&gt;&lt;div&gt;Once you&#39;ve completed the setup, Jenkins is ready to use. You can start creating and managing your Jenkins jobs to automate your development workflows.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Additional Configurations on Jenkins:&lt;/h2&gt;&lt;div&gt;Any Users created in jenkins console are only to manage jenkins through web browser. Bydefault, user &#39;jenkins&#39; only runs everything in background even if you have loggedin using any users on portal and this user &quot;jenkins&quot; is created during the installation at the Operating system level, but it is a non-root user.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;cat /etc/passwd | grep -i jenkins&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;jenkins:x:114:118:Jenkins,,,:/var/lib/jenkins:/bin/bash&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;So When user &quot;jenkins&quot; doesnt have sufficient previleges at the Operating system level, this user cannot perform all administrative level tasks. So we must configure sudo to gain the administrative level access.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;SUDO Access:&lt;/h3&gt;&lt;div&gt;Edit /etc/sudoers file and add below entry to allow user &quot;jenkins&quot; to use sudo with nopasswd prompt and also disable requiretty option.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;jenkins ALL=(ALL) NOPASSWD: ALL&lt;/div&gt;&lt;div&gt;Defaults !requiretty&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Change Jenkins user shell:&lt;/h3&gt;&lt;div&gt;Verify the &quot;jenkins&quot; user shell. If it is already specified with &quot;/bin/bash&quot;, You can ignore this. If not, we must change the user shell, this would help us to perform any tasks using CLI.&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;cat /etc/passwd | grep -i jenkins&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;jenkins:x:995:992:Jenkins Automation Server:/var/lib/jenkins:&lt;b&gt;/bin/bash&lt;/b&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Restart Service:&lt;/h3&gt;&lt;div&gt;&lt;blockquote&gt;sudo systemctl restart jenkins&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;b&gt;Related Searches and Questions asked:&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;a aria-label=&quot;How to Configure Jenkins Mail Notification on Build Failures&quot; href=&quot;https://www.learnitguide.net/2018/08/how-to-configure-jenkins-mail.html&quot; target=&quot;_blank&quot;&gt;How to Configure Jenkins Mail Notification on Build Failures&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;a aria-label=&quot;How to Configure Jenkins behind Proxy to Install Plugins&quot; href=&quot;https://www.learnitguide.net/2018/08/how-to-configure-jenkins-behind-proxy.html&quot; target=&quot;_blank&quot;&gt;How to Configure Jenkins behind Proxy to Install Plugins&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a aria-label=&quot;How to Reset Forgotten Jenkins Admin User Password&quot; href=&quot;https://www.learnitguide.net/2018/08/how-to-reset-forgotten-jenkins-admin.html&quot; target=&quot;_blank&quot;&gt;How to Reset Forgotten Jenkins Admin User&#39;s Password&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a aria-label=&quot;How to Install &amp;amp; Configure Jenkins on Linux Easily&quot; href=&quot;https://www.learnitguide.net/2018/05/how-to-install-configure-jenkins-on.html&quot; target=&quot;_blank&quot;&gt;How to Install &amp;amp; Configure Jenkins on Linux Easily&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/9101458297419497738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2023/10/install-and-configure-jenkins-on-ubuntu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/9101458297419497738'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/9101458297419497738'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2023/10/install-and-configure-jenkins-on-ubuntu.html' title='How to Install and Configure Jenkins on Ubuntu 20.04?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTuDsgSMGN5as4e-EAGw4m86Dt9B7rQpLoxKi12uRLFQ17DovLUHhjXTQNZcC2K2IPDfv8bpOE0rtcHYGDfUAE1VvGiTcR6HdlV7xmEyn1xjQGEeR82zuONX_oqGz4qQlG43Sz1nL8WBPpJd9q0oOl1dr6pfhTTL8Rp1XTQ_ReEmmBSRL4NEW-uWc_CEJX/s72-c/install%20and%20configure%20jenkins%20on%20ubuntu%2020.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-4815087281592652292</id><published>2023-10-16T08:52:00.001-07:00</published><updated>2024-01-03T05:52:11.555-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Jenkins"/><category scheme="http://www.blogger.com/atom/ns#" term="Trending"/><title type='text'>Jenkins Introduction, Advantages, CI/CD Workflow Explained</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;a aria-label=&quot;Jenkins Introduction, Advantages, CI CD Workflow Explained&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKhWoQmOPvHY_B8dKfwN9nf4ByVBukCJ80aOcaCR6QSaXkq-Ath1Fak5mBZyCXcewJ4vGrgwxEnlOVP2bjOLIbvFspthtim8uvLyjOSEsoYhYJWh0MLFyZeDhRxM2C5yiiFlk6PcQ5_BWkQZpRD-Ez9OeZsqO_sPpK9fqr04EXRn4ilEZEAZTOuN9zH2C0/s1280/Jenkins%20Introduction,%20Advantages,%20CI%20CD%20Workflow%20Explained.webp&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img alt=&quot;Jenkins Introduction, Advantages, CI CD Workflow Explained&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKhWoQmOPvHY_B8dKfwN9nf4ByVBukCJ80aOcaCR6QSaXkq-Ath1Fak5mBZyCXcewJ4vGrgwxEnlOVP2bjOLIbvFspthtim8uvLyjOSEsoYhYJWh0MLFyZeDhRxM2C5yiiFlk6PcQ5_BWkQZpRD-Ez9OeZsqO_sPpK9fqr04EXRn4ilEZEAZTOuN9zH2C0/s16000/Jenkins%20Introduction,%20Advantages,%20CI%20CD%20Workflow%20Explained.webp&quot; title=&quot;Jenkins Introduction, Advantages, CI CD Workflow Explained&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Introduction to Jenkins:&lt;/h3&gt;&lt;div&gt;Jenkins is an open-source automation server and integration tool that helps us for continuous integration and continuous delivery (CI/CD) processes in software development. It is widely used in the software industry to automate various aspects of the software development lifecycle, from building and testing code to deploying applications.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It is not only can be used in software delivery, it can be used in any other automation like system administration tasks, infrastructure provisioning. And it is written on java so it can be installed and used from any operating system where java is installed. So it supports multiple platforms.&lt;/div&gt;&lt;div&gt;&lt;p&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;You can also watch this tutorial video on our youtube channel.&lt;/span&gt;&lt;/p&gt;

  &lt;div class=&quot;ytShdw&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;videoYt&quot;&gt;&lt;iframe allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot; class=&quot;lazy&quot; data-src=&quot;//www.youtube.com/embed/ByfFK-bAg-0&quot; title=&quot;Lazy Iframe&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 style=&quot;text-align: left;&quot;&gt;Advantages of Jenkins:&lt;/h3&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Continuous Integration (CI):&lt;/h4&gt;&lt;div&gt;Jenkins automates the process of integrating code changes into a shared repository, allowing for frequent and automated testing of code. It detects and reports integration issues early in the development process, improving software quality. CI in Jenkins reduces the risk of integration problems during later stages of development.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Continuous Delivery (CD):&lt;/h4&gt;&lt;div&gt;In addition to CI, Jenkins can be extended to support CD. CD involves automating the deployment of code changes to various environments, such as development, staging, and production, in a consistent and reliable manner. Jenkins can help manage and orchestrate the entire CD pipeline.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Open Source and Community:&lt;/h4&gt;&lt;div&gt;Jenkins is an open-source project with a strong community of contributors and users. This community continuously develops and maintains plugins and extensions, offering support through forums, documentation, and third-party resources.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Automation:&lt;/h4&gt;&lt;div&gt;Jenkins enables the automation of repetitive and time-consuming tasks in the software development process. It allows developers to define and execute jobs, which can include building applications, running tests, and deploying to different environments, all without manual intervention.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Plugin Architecture:&lt;/h4&gt;&lt;div&gt;A huge ecosystem of plugins is available from Jenkins to increase its capability. These plugins help integrate Jenkins with various tools, technologies, and platforms. The plugin architecture allows you to tailor Jenkins to your specific project requirements.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Easy to Use:&lt;/h4&gt;&lt;div&gt;Jenkins provides a user-friendly web-based interface that simplifies configuration and job management. It has a low learning curve, making it accessible to both developers and non-technical team members.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Supports Multiple Platforms:&lt;/h4&gt;&lt;div&gt;Jenkins is platform-agnostic and can run on various operating systems, including Windows, Linux, macOS, and more. This cross-platform compatibility ensures flexibility in choosing your development and deployment environment.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Distributed Builds:&lt;/h4&gt;&lt;div&gt;Jenkins can be set up with a master-slave architecture, allowing you to distribute build and testing workloads across multiple machines. Distributed builds improve performance, reduce build times, and enhance scalability.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Customizable:&lt;/h4&gt;&lt;div&gt;Jenkins is highly customizable, allowing you to define and configure build and deployment pipelines as code using Jenkinsfiles or Pipeline DSL. You can tailor Jenkins to meet your specific project requirements and workflows.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Robust Security:&lt;/h4&gt;&lt;div&gt;Jenkins offers security features to protect your CI/CD pipelines and sensitive data. It supports user authentication, role-based access control, and integration with external security systems. This ensures that your CI/CD processes remain secure.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Comprehensive Testing:&lt;/h4&gt;&lt;div&gt;Jenkins integrates seamlessly with various testing tools and frameworks, allowing you to perform a wide range of tests, including unit tests, integration tests, and functional tests.&lt;/div&gt;&lt;div&gt;Comprehensive testing helps identify and fix issues early, ensuring software quality.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Scalability:&lt;/h4&gt;&lt;div&gt;Jenkins is highly scalable and can handle the needs of both small and large organizations. With distributed builds, you can scale horizontally by adding more build agents as your projects grow.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Web Interface:&lt;/h4&gt;&lt;div&gt;Jenkins provides a web-based user interface for configuration, job management, and monitoring. This makes it accessible to both developers and operations teams, with support for role-based access control.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;CI/CD workflow Example:&lt;/h3&gt;&lt;div&gt;Here&#39;s a simple example of a CI/CD workflow, from code development to deployment stage that involves various stages.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a aria-label=&quot;Jenkins CI CD Workflow Explained&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicc0NyolOG2Z68MaEr7pcpe13EXVjOdPOGGe8D7YGHLAneX1Hvdnc8gKShkOqJiMxyjNaXjUbYeJ7h_zZOWYHDDfEaKqbPAZYwcbPSvhY6UL03Cc_xhPObfZDg3i4F6ZocrUN_MqmYDb9RrR9sWJybUoIz-v_uSkwvpZ_TfgohqiwMfUJx07ab76_OLJQO/s960/Jenkins%20CI%20CD%20Workflow%20Explained.webp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Jenkins CI CD Workflow Explained&quot; border=&quot;0&quot; data-original-height=&quot;540&quot; data-original-width=&quot;960&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicc0NyolOG2Z68MaEr7pcpe13EXVjOdPOGGe8D7YGHLAneX1Hvdnc8gKShkOqJiMxyjNaXjUbYeJ7h_zZOWYHDDfEaKqbPAZYwcbPSvhY6UL03Cc_xhPObfZDg3i4F6ZocrUN_MqmYDb9RrR9sWJybUoIz-v_uSkwvpZ_TfgohqiwMfUJx07ab76_OLJQO/w640-h360/Jenkins%20CI%20CD%20Workflow%20Explained.webp&quot; title=&quot;Jenkins CI CD Workflow Explained&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Code Development:&lt;/h4&gt;&lt;div&gt;Developers write and commit code to a version control system (e.g., Git). Code changes are typically made on feature branches.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Continuous Integration (CI) Phase:&lt;/h4&gt;&lt;div&gt;When code is committed, the CI server (e.g., Jenkins) detects the changes. The CI server automatically triggers a build process.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Build Stage:&amp;nbsp;&lt;/h4&gt;&lt;div&gt;The CI server checks out the latest code from the repository. It compiles the code and creates an executable or artifact. The build may include unit tests to ensure code quality. If the build or tests fail, the team is notified.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Continuous Delivery (CD) Phase:&lt;/h4&gt;&lt;div&gt;In a CD setup, the CI server automatically moves to the deployment phase.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Deployment Stage:&lt;/h4&gt;&lt;div&gt;The CI/CD pipeline deploys the artifact to a staging environment. In the staging environment, more extensive testing (integration, performance, etc.) may occur. If the staging tests fail, the team is alerted.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Automated Testing:&lt;/h4&gt;&lt;div&gt;Automated testing scripts are executed in the staging environment. These tests ensure that the application works as expected and performs well.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Manual Testing (if required):&lt;/h4&gt;&lt;div&gt;Some organizations might have a manual testing step where the QA team performs additional tests.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Approval (if required):&lt;/h4&gt;&lt;div&gt;In some cases, manual approval may be needed before proceeding to production.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Deployment to Production:&lt;/h4&gt;&lt;div&gt;Once all tests pass and any required approvals are obtained, the CI/CD pipeline deploys the artifact to the production environment.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Continuous Monitoring:&lt;/h4&gt;&lt;div&gt;After deployment, the application is continuously monitored for performance, security, and other metrics. Any issues detected trigger alerts for the operations team.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Rollback (if necessary):&lt;/h4&gt;&lt;div&gt;If issues arise in production, an automated or manual rollback process may be initiated to revert to the previous stable version.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Logging and Reporting:&lt;/h4&gt;&lt;div&gt;The CI/CD pipeline logs all activities and results, providing a record for auditing and analysis.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is a simplified overview of a CI/CD workflow, and the actual implementation can vary depending on the organization, tools used, and specific requirements. CI/CD promotes a streamlined and automated process from code development to deployment, enabling rapid and reliable software releases while maintaining high quality and reducing manual intervention.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;b&gt;Related Searches and Questions asked:&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a aria-label=&quot;How to Configure Jenkins Mail Notification on Build Failures&quot; href=&quot;https://www.learnitguide.net/2018/08/how-to-configure-jenkins-mail.html&quot; target=&quot;_blank&quot;&gt;How to Configure Jenkins Mail Notification on Build Failures&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a aria-label=&quot;How to Configure Jenkins behind Proxy to Install Plugins&quot; href=&quot;https://www.learnitguide.net/2018/08/how-to-configure-jenkins-behind-proxy.html&quot; target=&quot;_blank&quot;&gt;How to Configure Jenkins behind Proxy to Install Plugins&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a aria-label=&quot;How to Reset Forgotten Jenkins Admin User Password&quot; href=&quot;https://www.learnitguide.net/2018/08/how-to-reset-forgotten-jenkins-admin.html&quot; target=&quot;_blank&quot;&gt;How to Reset Forgotten Jenkins Admin User&#39;s Password&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a aria-label=&quot;How to Install &amp;amp; Configure Jenkins on Linux Easily&quot; href=&quot;https://www.learnitguide.net/2018/05/how-to-install-configure-jenkins-on.html&quot; target=&quot;_blank&quot;&gt;How to Install &amp;amp; Configure Jenkins on Linux Easily&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/4815087281592652292/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2023/10/jenkins-introduction-advantages-cicd.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/4815087281592652292'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/4815087281592652292'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2023/10/jenkins-introduction-advantages-cicd.html' title='Jenkins Introduction, Advantages, CI/CD Workflow Explained'/><author><name>Admin</name><uri>http://www.blogger.com/profile/03660103809536814792</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKhWoQmOPvHY_B8dKfwN9nf4ByVBukCJ80aOcaCR6QSaXkq-Ath1Fak5mBZyCXcewJ4vGrgwxEnlOVP2bjOLIbvFspthtim8uvLyjOSEsoYhYJWh0MLFyZeDhRxM2C5yiiFlk6PcQ5_BWkQZpRD-Ez9OeZsqO_sPpK9fqr04EXRn4ilEZEAZTOuN9zH2C0/s72-c/Jenkins%20Introduction,%20Advantages,%20CI%20CD%20Workflow%20Explained.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-2750636854604926660</id><published>2023-10-12T00:44:00.006-07:00</published><updated>2024-06-06T21:10:34.942-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Commands"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux FAQs"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux Tutorials"/><title type='text'>10 Practical Examples of Rsync Command in Linux</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj9LJYhvkvJGFCw5MCKvrzccRUAd_i4YS9SoEbc7m4GqZdObzPhEMrvYf8ibh5_cZVbT-LKTOCzI1SL6mvCuyQL1gObE5EtdVBVX8Ga3oyD4gJCp8A0t1siW0zJz6avEr5x1njtRxh8YTUkzbHdbVIaA88g-96L0jh9veAPFRjP39ivorjyRfMF-iVV9Ny/s1280/10%20practical%20examples%20of%20rsync%20command%20in%20linux.webp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;10 practical examples of rsync command in linux&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj9LJYhvkvJGFCw5MCKvrzccRUAd_i4YS9SoEbc7m4GqZdObzPhEMrvYf8ibh5_cZVbT-LKTOCzI1SL6mvCuyQL1gObE5EtdVBVX8Ga3oyD4gJCp8A0t1siW0zJz6avEr5x1njtRxh8YTUkzbHdbVIaA88g-96L0jh9veAPFRjP39ivorjyRfMF-iVV9Ny/s16000/10%20practical%20examples%20of%20rsync%20command%20in%20linux.webp&quot; title=&quot;10 practical examples of rsync command in linux&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Rsync Command in Linux:&lt;/h2&gt;&lt;p&gt;&#39;Rsync&#39; Command is a powerful and versatile tool for file synchronization in Linux. It is not only efficiently copies files and directories but also synchronizes them in various scenarios. Whether you&#39;re looking to backup your data, mirror directories, or maintain remote server synchronization, rsync can do all of that.&lt;/p&gt;&lt;p&gt;These 10 practical commands provide you with a solid foundation for efficiently managing your data, whether it&#39;s for backups, remote synchronization, or data mirroring.&lt;/p&gt;&lt;p&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Let&#39;s Get Started.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;You can also watch this tutorial video on our youtube channel.&lt;/span&gt;&lt;/p&gt;

&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe class=&#39;lazy&#39; width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/DRt42AGs84s?si=Sff5_y5SPKt8HEPW&quot; title=&quot;10 Practical Examples of Rsync Command in Linux&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;/div&gt;
  
&lt;h3 style=&quot;text-align: left;&quot;&gt;1. Basic Local Directory Synchronization:&lt;/h3&gt;&lt;p&gt;The most basic use of rsync involves synchronizing the contents of one directory with another on the same system. The -av options enable archive mode and verbose output, ensuring that file attributes are preserved during synchronization.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av /source/directory/ /destination/directory/&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;This command efficiently copies and synchronizes the contents of the source directory with the destination directory.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av /usr/local/app-data /backup/app-data&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;2. Synchronize with a Remote Server over SSH:&lt;/h3&gt;&lt;p&gt;One of the standout features of rsync is its ability to synchronize data between local and remote systems securely. Using SSH for secure communication, you can sync a local directory with a remote directory on a different server.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -avz -e ssh /local/source/ user@remote-server:/remote/destination/&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;The -e ssh option specifies the use of SSH for secure data transfer, making it ideal for remote server synchronization.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -avz -e ssh /usr/local/app-data congo@remote-server:/usr/local/app-data&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;3. Dry Run (Preview) Mode:&lt;/h3&gt;&lt;p&gt;Before making actual changes, it&#39;s often a good practice to perform a dry run or preview of the synchronization to see what changes would be made. This is helpful in avoiding unexpected results.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --dry-run /source/directory/ /destination/directory/&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;The --dry-run flag shows you what changes rsync would make without actually applying them.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --dry-run /usr/local/app-data /backup/app-data&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;4. Synchronize and Delete Extra Files on the Destination:&lt;/h3&gt;&lt;p&gt;Sometimes, you may want to ensure that the destination directory exactly mirrors the source, including removing any extra files not present in the source. The --delete option comes to the rescue.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --delete /source/directory/ /destination/directory/&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;With this command, rsync will synchronize the source with the destination and remove any files in the destination that are not in the source.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --delete /usr/local/app-data /backup/app-data&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;5. Exclude Files and Directories:&lt;/h3&gt;&lt;p&gt;There might be situations where you need to exclude specific files or directories from the synchronization process. You can achieve this using the --exclude option.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --exclude &#39;file.txt&#39; /source/directory/ /destination/directory/&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;The --exclude option allows you to specify files or directories that should be skipped during synchronization.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --exclude &#39;file.txt&#39; /usr/local/app-data /backup/app-data&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;6. Show Progress and Transfer Speed:&lt;/h3&gt;&lt;p&gt;If you want to keep an eye on the progress of your synchronization, as well as the transfer speed, use the --progress option.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --progress /source/directory/ /destination/directory/&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;This command provides you with real-time updates on the progress of your rsync operation and the speed at which data is being transferred.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --progress /usr/local/app-data /backup/app-data&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;7. Preserve File Permissions and Ownership:&lt;/h3&gt;&lt;p&gt;Preserving file permissions and ownership is crucial in many scenarios, especially when working with system files. The --chown option allows you to set the ownership of the copied files.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --chown=USER:GROUP /source/directory/ /destination/directory/&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;With this command, you can ensure that file permissions and ownership are retained in the destination directory.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --chown=congo:administrator /usr/local/app-data /backup/app-data&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;8. Use Rsync Daemon for Remote Sync:&lt;/h3&gt;&lt;p&gt;rsync can also operate in daemon mode, allowing for remote synchronization through a custom port. This is particularly useful when working with remote servers.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -avz /source/directory/ rsync://remote-server:8873/destination/&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;In this example, we use rsync&#39;s daemon mode to synchronize data with a remote server over port 6262.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -avz /usr/local/app-data rsync://remote-server:6262/backup/app-data&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;9. Backup Rotation with Hard Links:&lt;/h3&gt;&lt;p&gt;Creating backups with rsync can be optimized for efficiency and storage space. By using hard links, you can create incremental backups while preserving disk space.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --link-dest=/backup/prev-backup /source/directory/ /backup/new-backup/&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;This command creates a new backup while linking to the previous one, saving space by only copying changes.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --link-dest=/backup/app-data-old /usr/local/app-data /backup/app-data&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;10. Exclude Multiple Patterns from Sync:&lt;/h3&gt;&lt;p&gt;When you need to exclude multiple files or patterns from synchronization, you can utilize an exclude file (e.g., exclude.txt) that lists the items to be excluded.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --exclude-from=exclude.txt /source/directory/ /destination/directory/&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;This approach allows you to maintain a list of excluded files and patterns for easy management.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;rsync -av --exclude-from=exclude.txt /usr/local/app-data /backup/app-data&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/p&gt;&lt;div&gt;&lt;p&gt;&lt;b&gt;Related Searches and Questions asked:&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;li&gt;&lt;a aria-label=&quot;Accessing Kubernetes Service from Localhost&quot; href=&quot;https://www.learnitguide.net/2023/05/accessing-kubernetes-service-from.html&quot; target=&quot;_blank&quot;&gt;Accessing Kubernetes Service from Localhost&lt;/a&gt;&lt;a aria-label=&quot;&quot; href=&quot;https://www.learnitguide.net/2023/05/it-seems-like-you-have-entered-word-dum.html&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;Helm: Render Chart Templates Locally&quot; href=&quot;https://www.learnitguide.net/2023/05/helm-render-chart-templates-locally.html&quot; target=&quot;_blank&quot;&gt;Helm: Render Chart Templates Locally&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;How to Configure DNS for Applications Deployed on Kubernetes?&quot; href=&quot;https://www.learnitguide.net/2023/05/how-to-configure-dns-for-applications.html&quot; target=&quot;_blank&quot;&gt;How to Configure DNS for Applications Deployed on Kubernetes?&lt;/a&gt;&lt;/li&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/2750636854604926660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2023/10/10-practical-examples-of-rsync-command.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/2750636854604926660'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/2750636854604926660'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2023/10/10-practical-examples-of-rsync-command.html' title='10 Practical Examples of Rsync Command in Linux'/><author><name>Admin</name><uri>http://www.blogger.com/profile/03660103809536814792</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj9LJYhvkvJGFCw5MCKvrzccRUAd_i4YS9SoEbc7m4GqZdObzPhEMrvYf8ibh5_cZVbT-LKTOCzI1SL6mvCuyQL1gObE5EtdVBVX8Ga3oyD4gJCp8A0t1siW0zJz6avEr5x1njtRxh8YTUkzbHdbVIaA88g-96L0jh9veAPFRjP39ivorjyRfMF-iVV9Ny/s72-c/10%20practical%20examples%20of%20rsync%20command%20in%20linux.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-3639617157038330379</id><published>2023-05-17T20:36:00.002-07:00</published><updated>2024-07-29T07:08:41.359-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Containerization"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Kubernetes"/><category scheme="http://www.blogger.com/atom/ns#" term="Orchestration"/><title type='text'>How to Expose Single REST API in Kubernetes Cluster?</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;a aria-label=&quot;How to Expose a Single REST API in Kubernetes to the Outside Cluster&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilTVKssW-DrtdyTEct0k1qF-7l3vBR4kpS6wlwKXHiha5EHLkpjciKkma6GBM9n1Rw9fvM0ukyg0sdQY5AU-BXyXiB3BKTy4VRx03NPyPwArEh_ezJrS88CFryOwaHAao7f4WH_pItBNll7-TYo6EU0f5hDYYqJaBEIvmQJxmg-at6vZTr6seHxOu2/s1600/How_to_Expose_a_Single_REST_API_in_Kubernetes_to_the_Outside_Cluster.webp&quot; style=&quot;display: block; padding: 1em 0px; text-align: center;&quot;&gt;&lt;img alt=&quot;How to Expose a Single REST API in Kubernetes to the Outside Cluster&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;720&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilTVKssW-DrtdyTEct0k1qF-7l3vBR4kpS6wlwKXHiha5EHLkpjciKkma6GBM9n1Rw9fvM0ukyg0sdQY5AU-BXyXiB3BKTy4VRx03NPyPwArEh_ezJrS88CFryOwaHAao7f4WH_pItBNll7-TYo6EU0f5hDYYqJaBEIvmQJxmg-at6vZTr6seHxOu2/s1600/How_to_Expose_a_Single_REST_API_in_Kubernetes_to_the_Outside_Cluster.webp&quot; width=&quot;1280&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;This post will help you to understand different methods is to expose single REST API in Kubernetes Cluster to the outside world and will provide step by step instructions. Because this is one common requirement for us to expose single REST API to allow external access to specific services within Kubernetes Cluster.&lt;/p&gt;&lt;div&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;div&gt;Let&#39;s Get Started.&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;Topics:&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;Using NodePort Service&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Using LoadBalancer Service&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Using Ingress Controller&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Choosing the Right Method&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Step by Step Instructions&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Using NodePort Service:&lt;/h2&gt;NodePort service type helps us to expose services on specific port on each node in kubernetes cluster. With this NodePort Service, Our service can be accessed from externally by using respective node&#39;s IP address and allocated port. This NodePort Service is a basic and straight inbuilt feature available in kubernetes cluster, But it may not best for realtime production scenarios as it requires managing port mappings manually.&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Using LoadBalancer Service:&lt;/h2&gt;LoadBalancer service type is another feature that uses cloud provider and it supports external load balancers. Kubernetes will automatically create one loadbalancer and will assign one external IP address or CNAME record. This will route or forward the network traffic to the service. This Loadbalancer service method is more suitable for production realtime environments with high availability and automatic load balancing.&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Using Ingress Controller:&lt;/h2&gt;Ingress controller is a additional controller to be installed on kubernetes cluster. This load balancer operates at the application layer (Layer 7) and it provides more advanced routing capabilities. It uses kubernetes ingress resources to define or create rules for routing incoming requests to different services based on paths, hostnames or patterns. This Ingress controller method is highly stuitable and it allows for sophisticated routing configurations on kubernetes cluster.&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Choosing the Right Method:&lt;/h2&gt;When selecting right method to expose single REST API in Kubernetes cluster, consider the application, deployments and environment requirements. NodePort is the easiest and simple method but it doesnt have automation and scalability. LoadBalancer is a good option for cloud-based environemtn but may have additional costs involved. Ingress Controller is the most advanced features but it requires additional configuration and supported Ingress controller implementation.&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step by Step Instructions:&lt;/h2&gt;Let&#39;s see the step by step instructions for exposing single REST API using NodePort service type:&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 1: Create Kubernetes deployment and service using Kubectl command:&lt;/h3&gt;&lt;pre&gt;&lt;div&gt;&lt;div&gt;&lt;code&gt;$ kubectl create deployment my-api &lt;span&gt;--image&lt;/span&gt;=my-api-image&lt;br /&gt;$ kubectl expose deployment my-api &lt;span&gt;--port&lt;/span&gt;=&lt;span&gt;80&lt;/span&gt; &lt;span&gt;--target-port&lt;/span&gt;=&lt;span&gt;8080&lt;/span&gt; &lt;span&gt;--type&lt;/span&gt;=NodePort&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 2: Find NodePort IP assigned to service:&lt;/h3&gt;&lt;pre&gt;&lt;div&gt;&lt;div&gt;&lt;code&gt;$ kubectl get service my-api&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 3: Access REST API externally using node&#39;s IP address and NodePort number:&lt;/h3&gt;&lt;pre&gt;&lt;div&gt;&lt;div&gt;&lt;code&gt;&lt;span&gt;http://&lt;span&gt;&amp;lt;&lt;span&gt;node-ip&lt;/span&gt;&amp;gt;&lt;/span&gt;:&lt;span&gt;&amp;lt;&lt;span&gt;node-port&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: medium; font-weight: 400;&quot;&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Searches and Questions asked:&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;li&gt;&lt;a aria-label=&quot;Accessing Kubernetes Service from Localhost&quot; href=&quot;https://www.learnitguide.net/2023/05/accessing-kubernetes-service-from.html&quot; target=&quot;_blank&quot;&gt;Accessing Kubernetes Service from Localhost&lt;/a&gt;&lt;a aria-label=&quot;&quot; href=&quot;https://www.learnitguide.net/2023/05/it-seems-like-you-have-entered-word-dum.html&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;Helm: Render Chart Templates Locally&quot; href=&quot;https://www.learnitguide.net/2023/05/helm-render-chart-templates-locally.html&quot; target=&quot;_blank&quot;&gt;Helm: Render Chart Templates Locally&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;How to Configure DNS for Applications Deployed on Kubernetes?&quot; href=&quot;https://www.learnitguide.net/2023/05/how-to-configure-dns-for-applications.html&quot; target=&quot;_blank&quot;&gt;How to Configure DNS for Applications Deployed on Kubernetes?&lt;/a&gt;&lt;/li&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/3639617157038330379/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2023/05/how-to-expose-single-rest-api-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/3639617157038330379'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/3639617157038330379'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2023/05/how-to-expose-single-rest-api-in.html' title='How to Expose Single REST API in Kubernetes Cluster?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilTVKssW-DrtdyTEct0k1qF-7l3vBR4kpS6wlwKXHiha5EHLkpjciKkma6GBM9n1Rw9fvM0ukyg0sdQY5AU-BXyXiB3BKTy4VRx03NPyPwArEh_ezJrS88CFryOwaHAao7f4WH_pItBNll7-TYo6EU0f5hDYYqJaBEIvmQJxmg-at6vZTr6seHxOu2/s72-c/How_to_Expose_a_Single_REST_API_in_Kubernetes_to_the_Outside_Cluster.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-4671629369396097951</id><published>2023-05-17T20:06:00.001-07:00</published><updated>2024-07-29T07:25:03.841-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Containerization"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Kubernetes"/><category scheme="http://www.blogger.com/atom/ns#" term="Orchestration"/><title type='text'>Accessing Kubernetes Service from Localhost</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;a aria-label=&quot;Accessing Kubernetes Service from Localhost&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFCstqeHn1EXWqDy3uREISkwJ5pIkp11chNfyTNddsCIh5kCOX_JIZquwn9e4CvTUv3HpWq5AACo0IskaQaV5nuAzWC7IfVxksQMdz4UA91hKCRO_d_RgIHOvmBcw_D7Tb_9eqebarEi-fAu8synmqe_omsaGhxnMZFnhGpq8UnLvM8Cc5NRBTMb3-/s1600/Accessing_Kubernetes_Service_from_Localhost.webp&quot; style=&quot;display: block; padding: 1em 0px; text-align: center;&quot;&gt;&lt;img alt=&quot;Accessing Kubernetes Service from Localhost&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;720&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFCstqeHn1EXWqDy3uREISkwJ5pIkp11chNfyTNddsCIh5kCOX_JIZquwn9e4CvTUv3HpWq5AACo0IskaQaV5nuAzWC7IfVxksQMdz4UA91hKCRO_d_RgIHOvmBcw_D7Tb_9eqebarEi-fAu8synmqe_omsaGhxnMZFnhGpq8UnLvM8Cc5NRBTMb3-/s1600/Accessing_Kubernetes_Service_from_Localhost.webp&quot; width=&quot;1280&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;This post will help you with accessing kubernetes service from localhost.&lt;/p&gt;&lt;div&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;div&gt;Let&#39;s Get Started.&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Hope you have running Kubernetes cluster and kubectl is already installed on your local to manage your kubernetes cluster. if you dont have existing kubernetes cluster, please refer this link&amp;nbsp;&lt;a href=&quot;https://www.learnitguide.net/2018/08/install-and-configure-kubernetes-cluster.html&quot; target=&quot;_blank&quot;&gt;How to Install &amp;amp; Configure Kubernetes Cluster on CentOS 7 / RHEL 7&lt;/a&gt; or&amp;nbsp;&lt;a href=&quot;https://www.learnitguide.net/2020/01/how-to-install-kubernetes-on-ubuntu.html&quot; target=&quot;_blank&quot;&gt;How to Install &amp;amp; Configure Kubernetes Cluster on Ubuntu&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 1: Find Kubernetes Service IP Address&lt;/h2&gt;&lt;p&gt;Firstly, we need to find the IP address allocated to your kubernetes services that you want to access. Use default kubectl command with service option to find service IP address.&lt;/p&gt;&lt;p&gt;&lt;code&gt;kubectl get services&lt;/code&gt;&lt;/p&gt;&lt;p&gt;This command will list all the running services in your Kubernetes cluster along with their IP addresses. Specifically if you want to show the service ip address of kubernetes namespace. use &#39;n&#39; option along with namespace.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: monospace;&quot;&gt;kubectl get services -n test-namespace&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 2: Create Port Forwarding&lt;/h2&gt;&lt;p&gt;Let&#39;s create port forwarding from your local machine to Kubernetes service. Use kubectl command with port-forward option.&lt;/p&gt;&lt;p&gt;&lt;code&gt;kubectl port-forward &amp;lt;service-name&amp;gt; &amp;lt;local-port&amp;gt;:&amp;lt;service-port&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Where, Replace &lt;code&gt;&amp;lt;service-name&amp;gt;&lt;/code&gt; with the name of your Kubernetes service that you want to access, &lt;code&gt;&amp;lt;local-port&amp;gt;&lt;/code&gt; with the port number on your local machine &amp;amp;&amp;nbsp;&lt;code&gt;&amp;lt;service-port&amp;gt;&lt;/code&gt; with the port number of the Kubernetes service.&lt;/p&gt;&lt;p&gt;For example, if your service name is &lt;i&gt;my-service&lt;/i&gt; and running on port &lt;i&gt;8080&lt;/i&gt; and you want to access the Kubernetes service, Use the below kubectl command with port forward command option to create port forwarding to port &lt;code&gt;8081&lt;/code&gt; on your local machine.&lt;/p&gt;&lt;p&gt;&lt;code&gt;kubectl port-forward my-service 8081:8080&lt;/code&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step 3: Access Kubernetes Service&lt;/h2&gt;&lt;p&gt;Once the port forwarding is created, it will start listening. So you can access your Kubernetes service from your local machine by just visiting the URL&amp;nbsp;&lt;code&gt;http://localhost:&amp;lt;local-port&amp;gt;&lt;/code&gt; in any of your web browser.&lt;/p&gt;&lt;p&gt;For example, if port-forwarding is created for port 8081. Then you can access Kubernetes service from localhost with the URL&amp;nbsp;&lt;code&gt;http://localhost:8081.&lt;/code&gt;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Searches and Questions asked:&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;li&gt;&lt;a aria-label=&quot;How to Configure DNS for Applications Deployed on Kubernetes?&quot; href=&quot;https://www.learnitguide.net/2023/05/how-to-configure-dns-for-applications.html&quot; target=&quot;_blank&quot;&gt;How to Configure DNS for Applications Deployed on Kubernetes?&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;Helm: List Installed Charts&quot; href=&quot;https://www.learnitguide.net/2023/05/helm-list-installed-charts.html&quot; target=&quot;_blank&quot;&gt;Helm: List Installed Charts&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;Helm: Render Chart Templates Locally&quot; href=&quot;https://www.learnitguide.net/2023/05/helm-render-chart-templates-locally.html&quot; target=&quot;_blank&quot;&gt;Helm: Render Chart Templates Locally&lt;/a&gt;&lt;/li&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/4671629369396097951/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2023/05/accessing-kubernetes-service-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/4671629369396097951'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/4671629369396097951'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2023/05/accessing-kubernetes-service-from.html' title='Accessing Kubernetes Service from Localhost'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFCstqeHn1EXWqDy3uREISkwJ5pIkp11chNfyTNddsCIh5kCOX_JIZquwn9e4CvTUv3HpWq5AACo0IskaQaV5nuAzWC7IfVxksQMdz4UA91hKCRO_d_RgIHOvmBcw_D7Tb_9eqebarEi-fAu8synmqe_omsaGhxnMZFnhGpq8UnLvM8Cc5NRBTMb3-/s72-c/Accessing_Kubernetes_Service_from_Localhost.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-5958520491132033939</id><published>2023-05-17T18:19:00.002-07:00</published><updated>2024-07-29T07:42:38.990-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Containerization"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Kubernetes"/><category scheme="http://www.blogger.com/atom/ns#" term="Orchestration"/><title type='text'>How to Configure DNS for Applications Deployed on Kubernetes?</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;a aria-label=&quot;How to Configure DNS for Applications Deployed on Kubernetes&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjB8_S0pR0Mrn45y-THQBQ2trvdpiHjGjCpIW1efMj6R5V3icp5vMuP_Qfwj-Q-Y3PstPUCUeq6k_qGa80-aMmO0FBfg4Cu2dnuVSXJNomli7fd2V0IWzfK-7wtIhIisy8zDhnwlLdjiKB32hvBhKGGQv6rIYRu0ptXivw158w6tdcLd8c3_MTBjYts/s1600/How_to_Configure_DNS_for_Applications_Deployed_on_Kubernetes.webp&quot; style=&quot;display: block; padding: 1em 0px; text-align: center;&quot;&gt;&lt;img alt=&quot;How to Configure DNS for Applications Deployed on Kubernetes&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;720&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjB8_S0pR0Mrn45y-THQBQ2trvdpiHjGjCpIW1efMj6R5V3icp5vMuP_Qfwj-Q-Y3PstPUCUeq6k_qGa80-aMmO0FBfg4Cu2dnuVSXJNomli7fd2V0IWzfK-7wtIhIisy8zDhnwlLdjiKB32hvBhKGGQv6rIYRu0ptXivw158w6tdcLd8c3_MTBjYts/s1600/How_to_Configure_DNS_for_Applications_Deployed_on_Kubernetes.webp&quot; width=&quot;1280&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;This post will help you with How to configure DNS for Applications deployed on Kubernetes. DNS configuration on Kubernetes is very important to make sure the applications can be accessed through DNS names. So the other part of resolution will be taken care by DNS or Domain Name System, because it is responsible for resolving domain names to IP addresses.&lt;/p&gt;&lt;div&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;div&gt;Let&#39;s Get Started.&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Prerequisites:&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;A Kubernetes cluster with one or more nodes.&lt;/li&gt;&lt;li&gt;kubectl command-line tool installed on your local machine.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Hope you have running Kubernetes cluster and kubectl is already installed on your local to manage your kubernetes cluster. if you dont have existing kubernetes cluster, please refer this link&amp;nbsp;&lt;a href=&quot;https://www.learnitguide.net/2018/08/install-and-configure-kubernetes-cluster.html&quot; target=&quot;_blank&quot;&gt;How to Install &amp;amp; Configure Kubernetes Cluster on CentOS 7 / RHEL 7&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href=&quot;https://www.learnitguide.net/2020/01/how-to-install-kubernetes-on-ubuntu.html&quot; target=&quot;_blank&quot;&gt;How to Install &amp;amp; Configure Kubernetes Cluster on Ubuntu&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets jump into the step by step instruction to configure DNS on Kubernetes cluster.&lt;/div&gt;&lt;h2&gt;Step 1: Create Namespace on Kubernetes Cluster&lt;/h2&gt;&lt;p&gt;I assume, you may have already a dedicated kubernetes namespace created for your application. If not, use kubectl command with namespace option to create namespace on kubernetes cluster for your application. Because, Kubernetes Namespace will help our application by organizing and isolating resources within Kubernetes cluster.&lt;/p&gt;&lt;pre&gt;&lt;div&gt;&lt;div&gt;&lt;code&gt;$ kubectl create &lt;span&gt;namespace&lt;/span&gt; &amp;lt;&lt;span&gt;namespace&lt;/span&gt;-name&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;p&gt;Replace &amp;lt;namespace-name&amp;gt; with your preferred name.&lt;/p&gt;&lt;h2&gt;Step 2: Deploy Application on Kubernetes Cluster&lt;/h2&gt;&lt;p&gt;I assume again, you already have application deployed on kubernetes cluster. If not, create deployment resource to deploy the application using the below command easily.&lt;/p&gt;&lt;pre&gt;&lt;div&gt;&lt;div&gt;&lt;code&gt;$ kubectl create deployment &amp;lt;deployment-name&amp;gt; --image=&amp;lt;image-name&amp;gt; --&lt;span&gt;namespace&lt;/span&gt;=&amp;lt;&lt;span&gt;namespace&lt;/span&gt;-name&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;p&gt;Replace &amp;lt;deployment-name&amp;gt; with the preferred name, &amp;lt;image-name&amp;gt; with the name of the Docker image that you need to deploy and &amp;lt;namespace-name&amp;gt; with the name of the namespace you created in Step 1.&lt;/p&gt;&lt;h2&gt;Step 3: Expose Deployment&lt;/h2&gt;&lt;p&gt;Once application is deployed and running in state, we need to expose the application. So users can access it from outside the kubernetes cluster. Use the below command to expose deployment.&lt;/p&gt;&lt;pre&gt;&lt;div&gt;&lt;div&gt;&lt;code&gt;$ kubectl expose deployment &amp;lt;deployment-name&amp;gt; --&lt;span&gt;type&lt;/span&gt;=&lt;span&gt;LoadBalancer&lt;/span&gt; --port=&amp;lt;port-&lt;span&gt;number&lt;/span&gt;&amp;gt; --&lt;span&gt;namespace&lt;/span&gt;=&amp;lt;&lt;span&gt;namespace&lt;/span&gt;-name&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;p&gt;Replace &amp;lt;deployment-name&amp;gt; with the name of the deployment you created in Step 2, &amp;lt;port-number&amp;gt; with the port number your application is listening on and &amp;lt;namespace-name&amp;gt; with the name of the namespace you created in Step 1.&lt;/p&gt;&lt;h2&gt;Step 4: Configure DNS&lt;/h2&gt;&lt;p&gt;Here is the the final step to configure DNS for your application. You can use Kubernetes ingress to configure DNS as follows: Just create a kubernetes ingress yaml file and apply it.&lt;/p&gt;&lt;p&gt;Make sure the domain name record is created and mapped with correct CNAME record.&amp;nbsp;&lt;/p&gt;&lt;pre&gt;&lt;div&gt;&lt;div&gt;&lt;code&gt;&lt;span&gt;apiVersion:&lt;/span&gt; &lt;span&gt;networking.k8s.io/v1beta1&lt;/span&gt;&lt;br /&gt;&lt;span&gt;kind:&lt;/span&gt; &lt;span&gt;Ingress&lt;/span&gt;&lt;br /&gt;&lt;span&gt;metadata:&lt;/span&gt;&lt;br /&gt;  &lt;span&gt;name:&lt;/span&gt; &lt;span&gt;&amp;lt;ingress-name&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span&gt;namespace:&lt;/span&gt; &lt;span&gt;&amp;lt;namespace-name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;spec:&lt;/span&gt;&lt;br /&gt;  &lt;span&gt;rules:&lt;/span&gt;&lt;br /&gt;  &lt;span&gt;-&lt;/span&gt; &lt;span&gt;host:&lt;/span&gt; &lt;span&gt;&amp;lt;domain-name&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span&gt;http:&lt;/span&gt;&lt;br /&gt;      &lt;span&gt;paths:&lt;/span&gt;&lt;br /&gt;      &lt;span&gt;-&lt;/span&gt; &lt;span&gt;backend:&lt;/span&gt;&lt;br /&gt;          &lt;span&gt;serviceName:&lt;/span&gt; &lt;span&gt;&amp;lt;service-name&amp;gt;&lt;/span&gt;&lt;br /&gt;          &lt;span&gt;servicePort:&lt;/span&gt; &lt;span&gt;&amp;lt;port-number&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;p&gt;Replace &amp;lt;ingress-name&amp;gt; with the name you want to give your ingress, &amp;lt;domain-name&amp;gt; with the domain name you want to use to access your application, &amp;lt;service-name&amp;gt; with the name of the service you created in Step 3 and &amp;lt;port-number&amp;gt; with the port number your application is listening on.&lt;/p&gt;&lt;p&gt;After configuring DNS, you should be able to access the application running on the kubernetes cluster using the domain name you specified in the ingress.&lt;/p&gt;&lt;p&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Searches and Questions asked:&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;li&gt;&lt;a aria-label=&quot;Helm: List Installed Charts&quot; href=&quot;https://www.learnitguide.net/2023/05/helm-list-installed-charts.html&quot; target=&quot;_blank&quot;&gt;Helm: List Installed Charts&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;Helm: Render Chart Templates Locally&quot; href=&quot;https://www.learnitguide.net/2023/05/helm-render-chart-templates-locally.html&quot; target=&quot;_blank&quot;&gt;Helm: Render Chart Templates Locally&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;Helm Upgrade: Update Chart Values with Examples&quot; href=&quot;https://www.learnitguide.net/2023/05/helm-upgrade-update-chart-values-with.html&quot; target=&quot;_blank&quot;&gt;Helm Upgrade: Update Chart Values with Examples&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;Kubectl: Force Delete Namespace Stuck in Terminating&quot; href=&quot;https://www.learnitguide.net/2023/05/kubectl-force-delete-namespace-stuck-in.html&quot; target=&quot;_blank&quot;&gt;Kubectl: Force Delete Namespace Stuck in Terminating&lt;/a&gt;&lt;/li&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/5958520491132033939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2023/05/how-to-configure-dns-for-applications.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/5958520491132033939'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/5958520491132033939'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2023/05/how-to-configure-dns-for-applications.html' title='How to Configure DNS for Applications Deployed on Kubernetes?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjB8_S0pR0Mrn45y-THQBQ2trvdpiHjGjCpIW1efMj6R5V3icp5vMuP_Qfwj-Q-Y3PstPUCUeq6k_qGa80-aMmO0FBfg4Cu2dnuVSXJNomli7fd2V0IWzfK-7wtIhIisy8zDhnwlLdjiKB32hvBhKGGQv6rIYRu0ptXivw158w6tdcLd8c3_MTBjYts/s72-c/How_to_Configure_DNS_for_Applications_Deployed_on_Kubernetes.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1562474106701642442.post-9110714405338945190</id><published>2023-05-17T10:46:00.001-07:00</published><updated>2024-07-31T18:51:14.710-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Containerization"/><category scheme="http://www.blogger.com/atom/ns#" term="Devops"/><category scheme="http://www.blogger.com/atom/ns#" term="Helm"/><category scheme="http://www.blogger.com/atom/ns#" term="Helm Charts"/><category scheme="http://www.blogger.com/atom/ns#" term="Kubernetes"/><category scheme="http://www.blogger.com/atom/ns#" term="Orchestration"/><title type='text'>Helm: List Repos &amp;amp; Charts in Repo</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;a aria-label=&quot;Helm List Repos &amp;lt;a amp; Charts in Repo&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyttbnDj_CyiifbqEWr8CiVovP7Cq2Itxeh9J3RD9lQq5eFL9IQ-HOmlxsLvGXx68g7c_Jq0CBEYwTtopto07wyKFI1Vm3YxYkZpCPeV9tktesN9Qwn5KrHbqa9fJmr7RO4fyZHCoFzEC0qp8dzCCg97PFlZj_MbNf80DWzWJX1r-prt5tYJozW4rX/s1600/Helm_List_Repos_&amp;amp;amp;_Charts_in_Repo.webp&quot; style=&quot;display: block; padding: 1em 0px; text-align: center;&quot;&gt;&lt;img alt=&quot;Helm List Repos alt=&quot; amp=&quot;&quot; border=&quot;0&quot; charts=&quot;&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;720&quot; in=&quot;&quot; repo=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyttbnDj_CyiifbqEWr8CiVovP7Cq2Itxeh9J3RD9lQq5eFL9IQ-HOmlxsLvGXx68g7c_Jq0CBEYwTtopto07wyKFI1Vm3YxYkZpCPeV9tktesN9Qwn5KrHbqa9fJmr7RO4fyZHCoFzEC0qp8dzCCg97PFlZj_MbNf80DWzWJX1r-prt5tYJozW4rX/s1600/Helm_List_Repos_&amp;amp;amp;_Charts_in_Repo.webp&quot; width=&quot;1280&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;This post will help you to understand how to use Helm command to list repositories and how to list charts from repositories with step by step instruction along with helm command example.&lt;/p&gt;&lt;p&gt;Helm has the inbuild feature to list repositories and helm charts available in the repositories. This functionality helps users to go through the available charts and install it easily if they find that suits for them.&lt;/p&gt;&lt;p&gt;If you are interested in learning, Request you to go through the below recommended tutorial.&lt;/p&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/02/devops-tutorial-for-beginners-devops.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;DevOps Full Course Tutorial for Beginners - DevOps Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/09/docker-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Docker Full Course Tutorial for Beginners - Docker Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/10/kubernetes-tutorial-for-beginners-full.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2018/06/ansible-tutorial-for-beginners-online.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Ansible Full Course Tutorial for Beginners - Ansible Free Training Online&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://www.learnitguide.net/2017/09/openstack-tutorial-for-beginners.html&quot; rel=&quot;noreferrer noopener&quot; target=&quot;_blank&quot;&gt;Openstack Full Course Tutorial for Beginners - Openstack Free Training Online&lt;/a&gt;&lt;/p&gt;&lt;div&gt;Let&#39;s Get Started.&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Listing Repositories:&lt;/h2&gt;Lets see, how to list repositories using Helm. Basically, Repositories holds all the collection of charts that are already packaged completely and made publicly available for installation.&lt;p&gt;&lt;/p&gt;&lt;p&gt;Use the below Helm command to list helm repositories.&lt;/p&gt;&lt;pre&gt;&lt;div&gt;&lt;div&gt;&lt;code&gt;helm repo list&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step-by-Step Instructions:&lt;/h2&gt;Here is the steps to list repositories in Helm:&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Step 1: Open terminal or command prompt.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Step 2: Hope you have Helm installed already and properly configured.&lt;/div&gt;&lt;p&gt;Step 3: Run &lt;code&gt;helm repo list&amp;nbsp;&lt;/code&gt;command&lt;/p&gt;&lt;p&gt;Step 4: Helm command will fetch the repositories list configured and will display the results on the screen as helm command output.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;pre&gt;&lt;div&gt;&lt;div&gt;&lt;code&gt;&lt;span&gt;$ &lt;/span&gt;&lt;span&gt;helm repo list&lt;/span&gt;&lt;br /&gt;NAME        	URL                                             &lt;br /&gt;stable      	https://charts.helm.sh/stable&lt;br /&gt;local       	http://localhost:8080/charts&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;p&gt;Above output shows the list of repositories available in your Helm environment along with the repository name and URL of repositories configured.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Listing Charts in Repository:&lt;/h2&gt;Once you have listed repositories from the Helm environment, now we have to find the helm charts available in specific repositories. Helm command provides a search option to list the helm charts within repository.&lt;p&gt;Use the below helm command to list helm charts within repository.&lt;/p&gt;&lt;pre&gt;&lt;div&gt;&lt;div&gt;&lt;code&gt;helm search repo &amp;lt;repository-name&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Step-by-Step Instructions:&lt;/h2&gt;Here is the steps to list helm charts within repository:&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Step 1: Open terminal or command prompt.&lt;/div&gt;&lt;p&gt;Step 2: Run helm command &lt;code&gt;helm search repo &amp;lt;repository-name&amp;gt;&lt;/code&gt;, where replace&amp;nbsp;&lt;code&gt;&amp;lt;repository-name&amp;gt;&lt;/code&gt; with the repository name that you want to list.&lt;/p&gt;&lt;p&gt;Step 3: Now, Helm command will search the mentioned repository and will display all the available helm charts along with helm chart versions and helm chart descriptions.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;&lt;pre&gt;&lt;div&gt;&lt;div&gt;&lt;code&gt;&lt;span&gt;$ &lt;/span&gt;&lt;span&gt;helm search repo stable&lt;/span&gt;&lt;br /&gt;NAME                           	CHART VERSION	APP VERSION	DESCRIPTION                                   &lt;br /&gt;stable/wordpress               	10.2.3       	5.4.1      	Web publishing platform for building blogs a...&lt;br /&gt;stable/mysql                   	1.6.8        	5.7.34     	Fast, reliable, scalable, and easy to use op...&lt;br /&gt;stable/nginx-ingress           	1.41.3       	0.48.1     	An nginx Ingress controller that uses ConfigM...&lt;br /&gt;...&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;p&gt;Above output shows helm chart name, helm chart version, helm app version and description of helm charts of specified repository.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: medium; font-weight: 400;&quot;&gt;That&#39;s it for this post. Keep practicing and have fun. Leave your comments if any.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Searches and Questions asked:&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;li&gt;&lt;a aria-label=&quot;Helm: List Installed Charts&quot; href=&quot;https://www.learnitguide.net/2023/05/helm-list-installed-charts.html&quot; target=&quot;_blank&quot;&gt;Helm: List Installed Charts&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;Helm: Render Chart Templates Locally&quot; href=&quot;https://www.learnitguide.net/2023/05/helm-render-chart-templates-locally.html&quot; target=&quot;_blank&quot;&gt;Helm: Render Chart Templates Locally&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;Helm Upgrade: Update Chart Values with Examples&quot; href=&quot;https://www.learnitguide.net/2023/05/helm-upgrade-update-chart-values-with.html&quot; target=&quot;_blank&quot;&gt;Helm Upgrade: Update Chart Values with Examples&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a aria-label=&quot;Kubectl: Force Delete Namespace Stuck in Terminating&quot; href=&quot;https://www.learnitguide.net/2023/05/kubectl-force-delete-namespace-stuck-in.html&quot; target=&quot;_blank&quot;&gt;Kubectl: Force Delete Namespace Stuck in Terminating&lt;/a&gt;&lt;/li&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
</content><link rel='replies' type='application/atom+xml' href='https://www.learnitguide.net/feeds/9110714405338945190/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.learnitguide.net/2023/05/helm-list-repos-charts-in-repo.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/9110714405338945190'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/1562474106701642442/posts/default/9110714405338945190'/><link rel='alternate' type='text/html' href='https://www.learnitguide.net/2023/05/helm-list-repos-charts-in-repo.html' title='Helm: List Repos &amp;amp; Charts in Repo'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyttbnDj_CyiifbqEWr8CiVovP7Cq2Itxeh9J3RD9lQq5eFL9IQ-HOmlxsLvGXx68g7c_Jq0CBEYwTtopto07wyKFI1Vm3YxYkZpCPeV9tktesN9Qwn5KrHbqa9fJmr7RO4fyZHCoFzEC0qp8dzCCg97PFlZj_MbNf80DWzWJX1r-prt5tYJozW4rX/s72-c/Helm_List_Repos_&amp;amp;_Charts_in_Repo.webp" height="72" width="72"/><thr:total>0</thr:total></entry></feed>