Skip to content

Commit 0b3dcb3

Browse files
authored
Merge pull request #1 from prajbanshi443/feature
Feature
2 parents a10f01d + 54e2e14 commit 0b3dcb3

17 files changed

+812
-12
lines changed

Eks-terraform/backend.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
backend "s3" {
3-
bucket = "ajay-mrcloudbook777" # Replace with your actual S3 bucket name
4-
key = "EKS/terraform.tfstate"
5-
region = "ap-south-1"
3+
bucket = "ratmdatastore" # Replace with your actual S3 bucket name
4+
key = "Jenkins/terraform.tfstate"
5+
region = "ap-southeast-2"
66
}
77
}

Eks-terraform/provider.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ terraform {
99

1010
# Configure the AWS Provider
1111
provider "aws" {
12-
region = "ap-south-1"
12+
region = "ap-southeast-2"
1313
}

Jenkins-CICD/Jenkinsfile

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
pipeline{
2+
agent any
3+
tools{
4+
jdk 'jdk17'
5+
terraform 'terraform'
6+
}
7+
stages{
8+
stage('clean Workspace'){
9+
steps{
10+
cleanWs()
11+
}
12+
}
13+
stage('checkout from Git'){
14+
steps{
15+
git branch: 'main', url: 'https://github.com/Aj7Ay/TERRAFORM-JENKINS-CICD.git'
16+
}
17+
}
18+
stage('Terraform version'){
19+
steps{
20+
sh 'terraform --version'
21+
}
22+
}
23+
stage("Sonarqube Analysis "){
24+
steps{
25+
withSonarQubeEnv('sonar-server') {
26+
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=Terraform \
27+
-Dsonar.projectKey=Terraform '''
28+
}
29+
}
30+
}
31+
stage("quality gate"){
32+
steps {
33+
script {
34+
waitForQualityGate abortPipeline: false, credentialsId: 'Sonar-token'
35+
}
36+
}
37+
}
38+
stage('TRIVY FS SCAN') {
39+
steps {
40+
sh "trivy fs . > trivyfs.txt"
41+
}
42+
}
43+
stage('Excutable permission to userdata'){
44+
steps{
45+
sh 'chmod 777 website.sh'
46+
}
47+
}
48+
stage('Terraform init'){
49+
steps{
50+
sh 'terraform init'
51+
}
52+
}
53+
stage('Terraform plan'){
54+
steps{
55+
sh 'terraform plan'
56+
}
57+
}
58+
stage('Terraform apply'){
59+
steps{
60+
sh 'terraform ${action} --auto approve'
61+
}
62+
}
63+
}
64+
}

Jenkins-CICD/backend.tf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
terraform {
2+
backend "s3" {
3+
bucket = var.bucket_name
4+
key = "my-terraform-environment/main"
5+
region = var.aws_region
6+
dynamodb_table = var.dynamodb_table
7+
}
8+
}

Jenkins-CICD/error.html

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<html lang="en" >
3+
<head>
4+
<meta charset="UTF-8">
5+
<title> 404 page | Nothing4us </title>
6+
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'>
7+
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Arvo'><link rel="stylesheet" href="./style.css">
8+
9+
</head>
10+
<body>
11+
<!-- partial:index.partial.html -->
12+
<section class="page_404">
13+
<div class="container">
14+
<div class="row">
15+
<div class="col-sm-12 ">
16+
<div class="col-sm-10 col-sm-offset-1 text-center">
17+
<div class="four_zero_four_bg">
18+
<h1 class="text-center ">404</h1>
19+
20+
21+
</div>
22+
23+
<div class="contant_box_404">
24+
<h3 class="h2">
25+
Look like you're lost
26+
</h3>
27+
28+
<p>the page you are looking for not avaible!</p>
29+
30+
<a href="" class="link_404">Go to Home</a>
31+
</div>
32+
</div>
33+
</div>
34+
</div>
35+
</div>
36+
</section>
37+
<!-- partial -->
38+
</body>
39+
</html>

Jenkins-CICD/index.html

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
HTML CSS JSResult Skip Results Iframe
2+
<!DOCTYPE html>
3+
<html lang="en" >
4+
<head>
5+
<meta charset="UTF-8">
6+
<title> Login Page Form | Nothing4us</title>
7+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
8+
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'><link rel="stylesheet" href="./style.css">
9+
10+
</head>
11+
<body>
12+
<!-- partial:index.partial.html -->
13+
<div class="center">
14+
<div class="ear ear--left"></div>
15+
<div class="ear ear--right"></div>
16+
<div class="face">
17+
<div class="eyes">
18+
<div class="eye eye--left">
19+
<div class="glow"></div>
20+
</div>
21+
<div class="eye eye--right">
22+
<div class="glow"></div>
23+
</div>
24+
</div>
25+
<div class="nose">
26+
<svg width="38.161" height="22.03">
27+
<path d="M2.017 10.987Q-.563 7.513.157 4.754C.877 1.994 2.976.135 6.164.093 16.4-.04 22.293-.022 32.048.093c3.501.042 5.48 2.081 6.02 4.661q.54 2.579-2.051 6.233-8.612 10.979-16.664 11.043-8.053.063-17.336-11.043z" fill="#243946"></path>
28+
</svg>
29+
<div class="glow"></div>
30+
</div>
31+
<div class="mouth">
32+
<svg class="smile" viewBox="-2 -2 84 23" width="84" height="23">
33+
<path d="M0 0c3.76 9.279 9.69 18.98 26.712 19.238 17.022.258 10.72.258 28 0S75.959 9.182 79.987.161" fill="none" stroke-width="3" stroke-linecap="square" stroke-miterlimit="3"></path>
34+
</svg>
35+
<div class="mouth-hole"></div>
36+
<div class="tongue breath">
37+
<div class="tongue-top"></div>
38+
<div class="line"></div>
39+
<div class="median"></div>
40+
</div>
41+
</div>
42+
</div>
43+
<div class="hands">
44+
<div class="hand hand--left">
45+
<div class="finger">
46+
<div class="bone"></div>
47+
<div class="nail"></div>
48+
</div>
49+
<div class="finger">
50+
<div class="bone"></div>
51+
<div class="nail"></div>
52+
</div>
53+
<div class="finger">
54+
<div class="bone"></div>
55+
<div class="nail"></div>
56+
</div>
57+
</div>
58+
<div class="hand hand--right">
59+
<div class="finger">
60+
<div class="bone"></div>
61+
<div class="nail"></div>
62+
</div>
63+
<div class="finger">
64+
<div class="bone"></div>
65+
<div class="nail"></div>
66+
</div>
67+
<div class="finger">
68+
<div class="bone"></div>
69+
<div class="nail"></div>
70+
</div>
71+
</div>
72+
</div>
73+
<div class="login">
74+
<label>
75+
<div class="fa fa-phone"></div>
76+
<input class="username" type="text" autocomplete="on" placeholder="Username"/>
77+
</label>
78+
<label>
79+
<div class="fa fa-commenting"></div>
80+
<input class="password" type="password" autocomplete="off" placeholder="Password"/>
81+
<button class="password-button">Show</button>
82+
</label>
83+
<button class="login-button">Login</button>
84+
</div>
85+
<div class="social-buttons">
86+
<div class="social">
87+
<div class="fa fa-wechat"></div>
88+
</div>
89+
<div class="social">
90+
<div class="fa fa-weibo"></div>
91+
</div>
92+
<div class="social">
93+
<div class="fa fa-paw"></div>
94+
</div>
95+
</div>
96+
<div class="footer">Mr.Cloud Book</div>
97+
98+
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script><script src="./script.js"></script>
99+
100+
</body>
101+
</html>

Jenkins-CICD/main.tf

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
resource "aws_instance" "ec2_instance" {
2+
ami = var.ami_id
3+
instance_type = var.instance_type
4+
key_name = var.key_name
5+
vpc_security_group_ids = [aws_security_group.ec2_security_group.id]
6+
user_data = base64encode(file("website.sh"))
7+
tags = {
8+
Name = "aws-ec2-instance"
9+
}
10+
}
11+
12+
resource "aws_security_group" "ec2_security_group" {
13+
name = "ec2 security group"
14+
description = "allow access on ports 80 and 22 and 443"
15+
16+
ingress = [
17+
for port in [22, 80, 443] : {
18+
description = "TLS from VPC"
19+
from_port = port
20+
to_port = port
21+
protocol = "tcp"
22+
cidr_blocks = ["0.0.0.0/0"]
23+
ipv6_cidr_blocks = []
24+
prefix_list_ids = []
25+
security_groups = []
26+
self = false
27+
}
28+
]
29+
30+
egress {
31+
from_port = 0
32+
to_port = 0
33+
protocol = "-1"
34+
cidr_blocks = ["0.0.0.0/0"]
35+
ipv6_cidr_blocks = ["::/0"]
36+
}
37+
38+
tags = {
39+
Name = "ec2-sg"
40+
}
41+
}

Jenkins-CICD/outputs.tf

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "websiteendpoint" {
2+
value = aws_s3_bucket.s3storage.website_endpoint
3+
}
4+
5+
output "public_ip" {
6+
value = aws_instance.ec2_instance.public_ip
7+
}

Jenkins-CICD/provider.tf

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = "~> 4.16"
6+
}
7+
}
8+
required_version = ">= 1.2.0"
9+
}
10+
11+
provider "aws" {
12+
region = var.aws_region
13+
}

Jenkins-CICD/s3.tf

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
resource "aws_s3_bucket" "s3storage" {
2+
bucket = var.bucket_name
3+
}
4+
resource "aws_s3_bucket_ownership_controls" "s3storage" {
5+
bucket = aws_s3_bucket.s3storage.id
6+
rule {
7+
object_ownership = "BucketOwnerPreferred"
8+
}
9+
}
10+
11+
resource "aws_s3_bucket_public_access_block" "s3storage" {
12+
bucket = aws_s3_bucket.s3storage.id
13+
block_public_acls = false
14+
block_public_policy = false
15+
ignore_public_acls = false
16+
restrict_public_buckets = false
17+
}
18+
19+
resource "aws_s3_bucket_acl" "s3storage" {
20+
depends_on = [
21+
aws_s3_bucket_ownership_controls.s3storage,
22+
aws_s3_bucket_public_access_block.s3storage,
23+
]
24+
bucket = aws_s3_bucket.s3storage.id
25+
acl = "public-read"
26+
}
27+
28+
resource "aws_s3_object" "index" {
29+
bucket = aws_s3_bucket.s3storage
30+
key = "index.html"
31+
source = "index.html"
32+
acl = "public-read"
33+
content_type = "text/html"
34+
}
35+
36+
37+
resource "aws_s3_object" "error" {
38+
bucket = aws_s3_bucket.s3storage
39+
key = "error.html"
40+
source = "error.html"
41+
acl = "public-read"
42+
content_type = "text/html"
43+
}
44+
45+
46+
resource "aws_s3_object" "style" {
47+
bucket = aws_s3_bucket.s3storage.id
48+
key = "style.css"
49+
source = "style.css"
50+
acl = "public-read"
51+
content_type = "text/css"
52+
}
53+
54+
55+
resource "aws_s3_object" "script" {
56+
bucket = aws_s3_bucket.s3storage.id
57+
key = "script.js"
58+
source = "script.js"
59+
acl = "public-read"
60+
content_type = "text/javascript"
61+
}
62+
63+
64+
resource "aws_s3_bucket_website_configuration" "website" {
65+
bucket = aws_s3_bucket.s3storage.id
66+
index_document {
67+
suffix = "index.html"
68+
}
69+
70+
error_document {
71+
key = "error.html"
72+
}
73+
74+
depends_on = [aws_s3_bucket_acl.s3storage.id]
75+
}
76+

0 commit comments

Comments
 (0)