Capstone Project - Banking and Finance Project
Capstone Project - Banking and Finance Project
# apt-get update
# apt-get install awscli -y
# aws configure
Give the valid access key
Give the valid secret key
- Press enter, no need to give any region and format
option.
}
resource "aws_vpc" "my-vpc" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "my-vpc"
}
vpc_id = aws_vpc.my-vpc.id
cidr_block = "10.0.1.0/24"
depends_on = [aws_vpc.my-vpc]
map_public_ip_on_launch = true
tags = {
Name = "my-subnet"
}
}
route_table_id = aws_route_table.my-route-table.id
destination_cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.gw.id
}
variable "sg_ports" {
type = list(number)
default = [8080,80,22,443]
}
resource "aws_security_group" "my-sg" {
name = "sg_rule"
vpc_id = aws_vpc.my-vpc.id
dynamic "ingress" {
for_each = var.sg_ports
iterator = port
content{
from_port = port.value
to_port = port.value
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_instance" "myec2" {
ami = "ami-0166fe664262f664c"
instance_type = "t2.medium"
key_name = "web-key"
subnet_id = aws_subnet.subnet-1.id
security_groups = [aws_security_group.my-sg.id]
tags = {
Name = "Terrafrom-EC2"
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = "ubuntu"
private_key =
tls_private_key.mykey.private_key_pem
host = self.public_ip
}
inline = [
"sudo apt update",
"sudo apt install software-properties-common",
"sudo add-apt-repository --yes --update
ppa:ansible/ansible",
"sudo apt install ansible -y"
]
}
}
pipeline{
agent any
tools{
maven 'mymvn'
}
stages{
stage('Clone repo')
{
steps{
git 'https://github.com/saransh-vijayvargiya/banking-
finance-Project1.git'
}
}
stage('Test Code')
{
steps{
sh 'mvn test'
}
}
stage('Build Code')
{
steps{
sh 'mvn package'
}
}
}
}
stage('Build Image')
{
steps{
sh 'docker build -t banking-finance-Project1 .'
}
}
- Now build the code.
# wget
https://github.com/prometheus/prometheus/release
s/download/v3.0.0/prometheus-3.0.0.linux-
amd64.tar.gz
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--
web.console.libraries=/etc/prometheus/console_libra
ries
[Install]
WantedBy=multi-user.target
- Reload systemd:
#sudo systemctl daemon-reload
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
scrape_interval: 5s
static_configs:
- targets:
['<Server_IP_of_Node_Exporter_Machine>:9100']
- After changes any configuration file we need to
restart our prometheus
#sudo systemctl restart prometheus.service