Skip to content

Commit 54e2e14

Browse files
committed
configured the S3 bucket and website
1 parent 675cdfd commit 54e2e14

9 files changed

+739
-0
lines changed

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/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/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/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+

Jenkins-CICD/script.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
let usernameInput = document.querySelector('.username');
2+
let passwordInput = document.querySelector('.password');
3+
let showPasswordButton = document.querySelector('.password-button');
4+
let face = document.querySelector('.face');
5+
6+
passwordInput.addEventListener('focus', event => {
7+
document.querySelectorAll('.hand').forEach(hand => {
8+
hand.classList.add('hide');
9+
});
10+
document.querySelector('.tongue').classList.remove('breath');
11+
});
12+
13+
passwordInput.addEventListener('blur', event => {
14+
document.querySelectorAll('.hand').forEach(hand => {
15+
hand.classList.remove('hide');
16+
hand.classList.remove('peek');
17+
});
18+
document.querySelector('.tongue').classList.add('breath');
19+
});
20+
21+
usernameInput.addEventListener('focus', event => {
22+
let length = Math.min(usernameInput.value.length - 16, 19);
23+
document.querySelectorAll('.hand').forEach(hand => {
24+
hand.classList.remove('hide');
25+
hand.classList.remove('peek');
26+
});
27+
28+
face.style.setProperty('--rotate-head', `${-length}deg`);
29+
});
30+
31+
usernameInput.addEventListener('blur', event => {
32+
face.style.setProperty('--rotate-head', '0deg');
33+
});
34+
35+
usernameInput.addEventListener('input', _.throttle(event => {
36+
let length = Math.min(event.target.value.length - 16, 19);
37+
38+
face.style.setProperty('--rotate-head', `${-length}deg`);
39+
}, 100));
40+
41+
showPasswordButton.addEventListener('click', event => {
42+
if (passwordInput.type === 'text') {
43+
passwordInput.type = 'password';
44+
document.querySelectorAll('.hand').forEach(hand => {
45+
hand.classList.remove('peek');
46+
hand.classList.add('hide');
47+
});
48+
} else {
49+
passwordInput.type = 'text';
50+
document.querySelectorAll('.hand').forEach(hand => {
51+
hand.classList.remove('hide');
52+
hand.classList.add('peek');
53+
});
54+
}
55+
});

0 commit comments

Comments
 (0)