Creating EC2 instance using Terraform is relatively easier. Here below is the code:
Everything created using terraform is called a resource.
resource "aws_instance" "myFirstInstrance" {
ami = "ami-916f59f4"
ami = "ami-916f59f4"
key_name = "my_key"
instance_type = "t2.micro"
security_groups= [ "security_jenkins_port"]
instance_type = "t2.micro"
security_groups= [ "security_jenkins_port"]
tags= {
Name = "jenkins_instance"
}
Name = "jenkins_instance"
}
}
resource "aws_security_group" "security_jenkins_port" {
name = "security_jenkins_port"
description = "security group for jenkins"
ingress {
from_port = 8080
to_port = 8080
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# outbound from jenkis server
egress {
from_port = 0
to_port = 65535
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
tags= {
Name = "security_jenkins_port"
}
}
resource "aws_security_group" "security_jenkins_port" {
name = "security_jenkins_port"
description = "security group for jenkins"
ingress {
from_port = 8080
to_port = 8080
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# outbound from jenkis server
egress {
from_port = 0
to_port = 65535
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
tags= {
Name = "security_jenkins_port"
}
}
Thank you for your valuable content , Easy to understand and follow. As said, the migration to cloud is very essential for the protection of the database.
ReplyDeleteCloud Migration services
Aws Cloud Migration services
Azure Cloud Migration services
Vmware Cloud Migration services
Database Migration services
Cloud Migration Tool
Best Cloud Migration Tool
Lia Infraservices