Pulumi and Terraform are two popular infrastructure as code (IaC) tools that are widely used for managing cloud infrastructure. Both tools allow developers to define and manage their infrastructure using code, making it easier to automate and version control their infrastructure.
One of the main differences between Pulumi and Terraform is the programming language they use. Pulumi is written in modern programming languages such as JavaScript, TypeScript, and Python, while Terraform is written in its own domain-specific language (DSL) called HashiCorp Configuration Language (HCL). This can be a pro or a con depending on the team's proficiency with different languages.
Another difference is that Pulumi has a more object-oriented approach to infrastructure management, while Terraform uses a declarative approach. In Pulumi, you create, update, and delete resources using classes and objects, while in Terraform, you define the desired state of your resources and the tool takes care of creating, updating, or deleting them.
Pulumi also supports more cloud providers than Terraform. Pulumi supports many popular cloud providers such as AWS, Azure, GCP, and Kubernetes, while Terraform supports a wide range of providers, but not as many as Pulumi.
In terms of ease of use, Terraform is considered to be easier to learn and use compared to Pulumi, especially for users who are new to IaC. Terraform's HCL is simple and easy to understand. Pulumi, on the other hand, has a steeper learning curve, but its object-oriented approach allows for better code reuse and abstraction.
Here is an example of how to create an S3 bucket using Pulumi and Terraform:
Pulumi:
import * as aws from "@pulumi/aws";
const bucket = new aws.s3.Bucket("my-bucket", {});
Terraform:
resource "aws_s3_bucket" "my_bucket" {
bucket = "my-bucket"
}
In conclusion, both Pulumi and Terraform have their pros and cons. Pulumi's support for multiple programming languages and its object-oriented approach
Certainly, here is an example of how to create an Amazon EKS cluster with the necessary dependencies, including a new VPC and relevant resources that allow access to the Internet using both Pulumi and Terraform:
Pulumi(typescript):
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const vpc = new aws.ec2.Vpc("my-vpc", {
cidrBlock: "10.0.0.0/16",
});
const igw = new aws.ec2.InternetGateway("my-igw", {
vpcId: vpc.id,
});
const subnet = new aws.ec2.Subnet("my-subnet", {
vpcId: vpc.id,
cidrBlock: "10.0.1.0/24",
availabilityZone: "us-west-2a",
mapPublicIpOnLaunch: true,
});
const securityGroup = new aws.ec2.SecurityGroup("my-security-group", {
vpcId: vpc.id,
ingress: [{
fromPort: 22,
toPort: 22,
protocol: "tcp",
cidrBlocks: ["0.0.0.0/0"],
}],
egress: [{
fromPort: 0,
toPort: 0,
protocol: "-1",
cidrBlocks: ["0.0.0.0/0"],
}],
});
const clusterRole = new aws.iam.Role("eks-cluster-role", {
assumeRolePolicy:
});
const clusterRolePolicyAttachment = new aws.iam.RolePolicyAttachment("eks-cluster-policy-attachment", {
role: clusterRole.name,
policyArn: "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy",
});
const serviceRolePolicyAttachment = new aws.iam.RolePolicyAttachment("eks-service-policy-attachment", {
role: clusterRole.name,
policyArn: "arn:aws:iam::aws:policy/AmazonEKSServicePolicy",
});
const eksCluster = new aws.eks.Cluster("my-cluster", {
roleArn: clusterRole.arn,
vpcConfig: {
subnetIds: [subnet.id],
securityGroupIds: [securityGroup.id],
},
});
Pulumi (python):
import pulumi
import pulumi_aws as aws
vpc = aws.ec2.Vpc("my-vpc",
cidr_block="10.0.0.0/16")
igw = aws.ec2.InternetGateway("my-igw",
vpc_id=vpc.id)
One of the main differences between Pulumi and Terraform is the programming language they use. Pulumi is written in modern programming languages such as JavaScript, TypeScript, and Python, while Terraform is written in its own domain-specific language (DSL) called HashiCorp Configuration Language (HCL). This can be a pro or a con depending on the team's proficiency with different languages.
Another difference is that Pulumi has a more object-oriented approach to infrastructure management, while Terraform uses a declarative approach. In Pulumi, you create, update, and delete resources using classes and objects, while in Terraform, you define the desired state of your resources and the tool takes care of creating, updating, or deleting them.
Pulumi also supports more cloud providers than Terraform. Pulumi supports many popular cloud providers such as AWS, Azure, GCP, and Kubernetes, while Terraform supports a wide range of providers, but not as many as Pulumi.
In terms of ease of use, Terraform is considered to be easier to learn and use compared to Pulumi, especially for users who are new to IaC. Terraform's HCL is simple and easy to understand. Pulumi, on the other hand, has a steeper learning curve, but its object-oriented approach allows for better code reuse and abstraction.
Here is an example of how to create an S3 bucket using Pulumi and Terraform:
Pulumi:
import * as aws from "@pulumi/aws";
const bucket = new aws.s3.Bucket("my-bucket", {});
Terraform:
resource "aws_s3_bucket" "my_bucket" {
bucket = "my-bucket"
}
In conclusion, both Pulumi and Terraform have their pros and cons. Pulumi's support for multiple programming languages and its object-oriented approach
Certainly, here is an example of how to create an Amazon EKS cluster with the necessary dependencies, including a new VPC and relevant resources that allow access to the Internet using both Pulumi and Terraform:
Pulumi(typescript):
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const vpc = new aws.ec2.Vpc("my-vpc", {
cidrBlock: "10.0.0.0/16",
});
const igw = new aws.ec2.InternetGateway("my-igw", {
vpcId: vpc.id,
});
const subnet = new aws.ec2.Subnet("my-subnet", {
vpcId: vpc.id,
cidrBlock: "10.0.1.0/24",
availabilityZone: "us-west-2a",
mapPublicIpOnLaunch: true,
});
const securityGroup = new aws.ec2.SecurityGroup("my-security-group", {
vpcId: vpc.id,
ingress: [{
fromPort: 22,
toPort: 22,
protocol: "tcp",
cidrBlocks: ["0.0.0.0/0"],
}],
egress: [{
fromPort: 0,
toPort: 0,
protocol: "-1",
cidrBlocks: ["0.0.0.0/0"],
}],
});
const clusterRole = new aws.iam.Role("eks-cluster-role", {
assumeRolePolicy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "eks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
},});
const clusterRolePolicyAttachment = new aws.iam.RolePolicyAttachment("eks-cluster-policy-attachment", {
role: clusterRole.name,
policyArn: "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy",
});
const serviceRolePolicyAttachment = new aws.iam.RolePolicyAttachment("eks-service-policy-attachment", {
role: clusterRole.name,
policyArn: "arn:aws:iam::aws:policy/AmazonEKSServicePolicy",
});
const eksCluster = new aws.eks.Cluster("my-cluster", {
roleArn: clusterRole.arn,
vpcConfig: {
subnetIds: [subnet.id],
securityGroupIds: [securityGroup.id],
},
});
Pulumi (python):
import pulumi
import pulumi_aws as aws
vpc = aws.ec2.Vpc("my-vpc",
cidr_block="10.0.0.0/16")
igw = aws.ec2.InternetGateway("my-igw",
vpc_id=vpc.id)
subnet = aws.ec2.Subnet("my-subnet",
vpc_id=vpc.id,
cidr_block="10.0.1.0/24",
availability_zone="us-west-2a",
map_public_ip_on_launch=True)
security_group = aws.ec2.SecurityGroup("my-security-group",
vpc_id=vpc.id,
ingress=[{
"from_port": 22,
"to_port": 22,
"protocol": "tcp",
"cidr_blocks": ["0.0.0.0/0"]
}],
egress=[{
"from_port": 0,
"to_port": 0,
"protocol": "-1",
"cidr_blocks": ["0.0.0.0/0"]
}])
cluster_role = aws.iam.Role("eks-cluster-role",
assume_role_policy='''{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "eks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}''')
cluster_role_policy_attachment = aws.iam.RolePolicyAttachment("eks-cluster-policy-attachment",
role=cluster_role.name,
policy_arn="arn:aws:iam::aws:policy/AmazonEKSClusterPolicy")
service_role_policy_attachment = aws.iam.RolePolicyAttachment("eks-service-policy-attachment",
role=cluster_role.name,
policy_arn="arn:aws:iam::aws:policy/AmazonEKSServicePolicy")
eks_cluster = aws.eks.Cluster("my-cluster",
role_arn=cluster_role.arn,
vpc_config={
"subnet_ids": [subnet.id],
"security_group_ids": [security_group.id]
})
Terraform:
provider "aws" {
region = "us-west-2"
}
resource "aws_vpc" "example" {
cidr_block = "10.0.0.0/16"
}
resource "aws_internet_gateway" "example" {
resource "aws_internet_gateway" "example" {
vpc_id = aws_vpc.example.id
}
resource "aws_subnet" "example" {
vpc_id = aws_vpc.example.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-2a"
map_public_ip_on_launch = true
}
resource "aws_security_group" "example" {
vpc_id = aws_vpc.example.id
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_iam_role" "eks_cluster_role" {
name = "eks-cluster-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Princ
resource "aws_iam_role" "eks_cluster_role" {
name = "eks-cluster-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "eks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "eks_cluster_policy_attachment" {
role = aws_iam_role.eks_cluster_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
}
vpc_id=vpc.id,
cidr_block="10.0.1.0/24",
availability_zone="us-west-2a",
map_public_ip_on_launch=True)
security_group = aws.ec2.SecurityGroup("my-security-group",
vpc_id=vpc.id,
ingress=[{
"from_port": 22,
"to_port": 22,
"protocol": "tcp",
"cidr_blocks": ["0.0.0.0/0"]
}],
egress=[{
"from_port": 0,
"to_port": 0,
"protocol": "-1",
"cidr_blocks": ["0.0.0.0/0"]
}])
cluster_role = aws.iam.Role("eks-cluster-role",
assume_role_policy='''{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "eks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}''')
cluster_role_policy_attachment = aws.iam.RolePolicyAttachment("eks-cluster-policy-attachment",
role=cluster_role.name,
policy_arn="arn:aws:iam::aws:policy/AmazonEKSClusterPolicy")
service_role_policy_attachment = aws.iam.RolePolicyAttachment("eks-service-policy-attachment",
role=cluster_role.name,
policy_arn="arn:aws:iam::aws:policy/AmazonEKSServicePolicy")
eks_cluster = aws.eks.Cluster("my-cluster",
role_arn=cluster_role.arn,
vpc_config={
"subnet_ids": [subnet.id],
"security_group_ids": [security_group.id]
})
Terraform:
provider "aws" {
region = "us-west-2"
}
resource "aws_vpc" "example" {
cidr_block = "10.0.0.0/16"
}
resource "aws_internet_gateway" "example" {
resource "aws_internet_gateway" "example" {
vpc_id = aws_vpc.example.id
}
resource "aws_subnet" "example" {
vpc_id = aws_vpc.example.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-2a"
map_public_ip_on_launch = true
}
resource "aws_security_group" "example" {
vpc_id = aws_vpc.example.id
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_iam_role" "eks_cluster_role" {
name = "eks-cluster-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Princ
resource "aws_iam_role" "eks_cluster_role" {
name = "eks-cluster-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "eks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "eks_cluster_policy_attachment" {
role = aws_iam_role.eks_cluster_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
}
resource "aws_iam_role_policy_attachment" "eks_service_policy_attachment" {
role = aws_iam_role.eks_cluster_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy"
}
resource "aws_eks_cluster" "example" {
name = "my-cluster"
role_arn = aws_iam_role.eks_cluster_role.arn
vpc_config {
security_group_ids = [aws_security_group.example.id]
subnet_ids = [aws_subnet.example.id]
}
}
https://t.me/IAC1L/12
role = aws_iam_role.eks_cluster_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy"
}
resource "aws_eks_cluster" "example" {
name = "my-cluster"
role_arn = aws_iam_role.eks_cluster_role.arn
vpc_config {
security_group_ids = [aws_security_group.example.id]
subnet_ids = [aws_subnet.example.id]
}
}
https://t.me/IAC1L/12
Telegram
IaC IL
נכתב ע'י gptchat, דאגתי גם לדוגמאות מחושיות מגניבות
EKS Managed Policies Error

Save & SubmitCancel
1 / 2
The error message you received indicates that the role you are attempting to use for your Amazon Elastic Kubernetes Service (EKS) cluster does not…
EKS Managed Policies Error

Save & SubmitCancel
1 / 2
The error message you received indicates that the role you are attempting to use for your Amazon Elastic Kubernetes Service (EKS) cluster does not…
Forwarded from Easy Linux and Devops channel
בוקר טוב, שימו לב שיש מחר הדרכה מעשית ומעמיקה (workshop) על HashiCorp Vault ו- Zero Trust Security , ותהיה התייחסות גם ל- Kubernetes. הנחתי שיעניין כאן רבים, לכן מניח כאן.
מיועד למתחילים (ולא רק).
הכניסה חופשית (כמות המקומות מוגבלת) וזה יהיה באנגלית (יש גם הקלטה של הדרכה דומה בעברית). פרטים והרשמה כאן:
https://bit.ly/3xBremL
https://t.me/myeasylinux/1440
מיועד למתחילים (ולא רק).
הכניסה חופשית (כמות המקומות מוגבלת) וזה יהיה באנגלית (יש גם הקלטה של הדרכה דומה בעברית). פרטים והרשמה כאן:
https://bit.ly/3xBremL
https://t.me/myeasylinux/1440
ALMtoolbox בלוג חדשות
הזמנה להדרכה על HashiCorp Vault ו- Zero Trust Security - ALMtoolbox בלוג חדשות
מוזמנים להדרכה מעשית (workshop) ותרגול על HashiCorp Vault ו- Zero Trust Security . למעוניינים יש גם הקלטות של הדרכות קודמות (עברית / אנגלית)
לכל חובבי הTerraform
הכנתי כלי ויזואלציה לVSCode
מוזמנים לתת Star, לתרום שם קוד וכמובן שאשמח לקבל פידבק 😎❤️
https://github.com/adamiBs/vscode-terraform-live-graph
תודה לאדם, תנו לו כוכב, מגיע לו 💫
https://t.me/IAC1L/21
הכנתי כלי ויזואלציה לVSCode
מוזמנים לתת Star, לתרום שם קוד וכמובן שאשמח לקבל פידבק 😎❤️
https://github.com/adamiBs/vscode-terraform-live-graph
תודה לאדם, תנו לו כוכב, מגיע לו 💫
https://t.me/IAC1L/21
GitHub
GitHub - adamiBs/vscode-terraform-live-graph: The Terraform Live Graph Extension for Visual Studio Code is a plugin that allows…
The Terraform Live Graph Extension for Visual Studio Code is a plugin that allows you to generate a live Terraform graph as you code. - adamiBs/vscode-terraform-live-graph
👍2
היי חברים שבוע טוב.
כתבתי מאמר על הכרות עם tftest שזו בעצם דרך להריץ טסטים על terrafom/terragrunt בעזרת פייתון וpytest.
https://medium.com/saas-infra/terraform-testing-made-easy-with-python-exploring-tftest-925bb207eabd
המאמר הבא כבר בדרך שבו אבחן איך ניתן לעשות e2e tests לכמה מודולים ולבדוק שהכל עובד יפה :)
תודה לאיסר על המאמר 💪
https://t.me/IAC1L/24
כתבתי מאמר על הכרות עם tftest שזו בעצם דרך להריץ טסטים על terrafom/terragrunt בעזרת פייתון וpytest.
https://medium.com/saas-infra/terraform-testing-made-easy-with-python-exploring-tftest-925bb207eabd
המאמר הבא כבר בדרך שבו אבחן איך ניתן לעשות e2e tests לכמה מודולים ולבדוק שהכל עובד יפה :)
תודה לאיסר על המאמר 💪
https://t.me/IAC1L/24
Medium
Terraform Testing Made Easy with Python: Exploring tftest
tftest is a Python package that provides a testing framework for Terraform modules. It allows users to write automated tests to verify the…
עוד מאמר של איסר🔥
אנחנו לקראת סוף השבוע ואף אחד לא רוצה נפילות לקראת הסופש, הפעם אני בוחן end to end testing עם pytest וtftest.
https://medium.com/@isar-nasimov/put-your-terraform-to-the-test-e2e-testing-with-python-and-tftest-73deff4c468a
https://t.me/IAC1L/25
סופש אליפות לכולנו
אנחנו לקראת סוף השבוע ואף אחד לא רוצה נפילות לקראת הסופש, הפעם אני בוחן end to end testing עם pytest וtftest.
https://medium.com/@isar-nasimov/put-your-terraform-to-the-test-e2e-testing-with-python-and-tftest-73deff4c468a
https://t.me/IAC1L/25
סופש אליפות לכולנו
Medium
Put Your Terraform to the Test: E2E Testing with Python and tftest
Maximize Your Terraform Potential: Create Effortless End-to-End Tests with Python and tftest for Optimal Infrastructure Management.
https://www.pulumi.com/blog/converting-full-terraform-programs-to-pulumi/?utm_campaign=FY2023Q4_PulumiUP&utm_medium=email&_hsmi=262636686&_hsenc=p2ANqtz--R6HSUJNDkc4T1GEejke1mG6AfKaCnqEoSFEUL3ZNcSVzOvA7P0QVN-XHJeRsDFrri3_3fMjx2B40JsKTelNjxLpTMlw&utm_content=262636686&utm_source=hs_email
https://t.me/IAC1L/30
https://t.me/IAC1L/30
pulumi
Converting Full Terraform Programs to Pulumi
Learn how to convert whole Terraform programs to Pulumi using the new Terraform converter
Pulumi on github -
https://github.com/pulumi/pulumi
Pulumi blog - https://www.pulumi.com/blog/pulumi-hearts-opensource/?utm_medium=email&_hsmi=269979495&_hsenc=p2ANqtz-8RqigpnQy0Mbj5ep8WZj4uiMPF9NpkSTeBcKE-YcwAIAhrlv_NRZ3D_Rliryk6-BKlKGPyUxuVieBt0KJK3uMhSvSf5w&utm_content=269979495&utm_source=hs_email
https://t.me/IAC1L/31
https://github.com/pulumi/pulumi
Pulumi blog - https://www.pulumi.com/blog/pulumi-hearts-opensource/?utm_medium=email&_hsmi=269979495&_hsenc=p2ANqtz-8RqigpnQy0Mbj5ep8WZj4uiMPF9NpkSTeBcKE-YcwAIAhrlv_NRZ3D_Rliryk6-BKlKGPyUxuVieBt0KJK3uMhSvSf5w&utm_content=269979495&utm_source=hs_email
https://t.me/IAC1L/31
👍1
הפעם החלטתי לכתוב על crossplane, זה חלק ראשון מכמה בלוגים שאני מתכנן לכתוב, את רובן אני אכתוב מפרספקטיבה של אדם שיודע terraform.
אז הנה הבלוג הראשון שלי בנושא, להבין את הטרמינולוגיה של crossplane בעיניים של terraform engineer
https://isar-nasimov.medium.com/crossplane-101-a-terraform-enthusiasts-first-encounter-part-1-4e1637221639
תודה לאיסר
https://t.me/IAC1L/32
אז הנה הבלוג הראשון שלי בנושא, להבין את הטרמינולוגיה של crossplane בעיניים של terraform engineer
https://isar-nasimov.medium.com/crossplane-101-a-terraform-enthusiasts-first-encounter-part-1-4e1637221639
תודה לאיסר
https://t.me/IAC1L/32
Medium
Crossplane 101: A Terraform Enthusiast’s First Encounter
Are you tired of using Terraform to manage your cloud resources? If so, you need to check out Crossplane. Crossplane is a next-generation…
👍1