Last active
September 27, 2022 04:14
-
-
Save immma/04068c5300d6ff0adbfd2f86a1cdb889 to your computer and use it in GitHub Desktop.
EC2 Bootstrap with Bootstrap CSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum update -y | |
yum install -y httpd | |
ipv4=$(curl -s "http://169.254.169.254/latest/meta-data/local-ipv4") | |
hostname=$(curl http://169.254.169.254/latest/meta-data/local-hostname) | |
cat > /var/www/html/index.html << _EOF_ | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<!-- CSS only --> | |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" | |
integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous"> | |
<title>$ipv4 | Hello world</title> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Hello world</h1> | |
<h3>This is ardih</h3> | |
<div class="row"> | |
<div class="col"> | |
<table class="table"> | |
<tr> | |
<td><b>IP</b></td> | |
<td><a href="http://$ipv4" target="_blank" rel="noopener noreferrer">$ipv4</a></td> | |
</tr> | |
<tr> | |
<td><b>Public hostname</b></td> | |
<td><a href="http://$hostname" target="_blank" rel="noopener noreferrer">$hostname</a></td> | |
</tr> | |
<tr> | |
<td><b>Version</b></td> | |
<td>v.1.1</td> | |
</tr> | |
</table> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> | |
_EOF_ | |
systemctl start httpd | |
systemctl enable httpd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum update -y | |
yum install -y httpd | |
public_ipv4=$(curl -s "http://169.254.169.254/latest/meta-data/public-ipv4") | |
hostname=$(curl http://169.254.169.254/latest/meta-data/public-hostname) | |
mkdir /var/www/html/v2 | |
cat > /var/www/html/v2/index.html << _EOF_ | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<!-- CSS only --> | |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" | |
integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous"> | |
<title>$public_ipv4 | Hello world</title> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Hello world</h1> | |
<h3>This is ardih</h3> | |
<div class="row"> | |
<div class="col"> | |
<table class="table"> | |
<tr> | |
<td><b>IP</b></td> | |
<td><a href="http://$public_ipv4" target="_blank" rel="noopener noreferrer">$public_ipv4</a></td> | |
</tr> | |
<tr> | |
<td><b>Public hostname</b></td> | |
<td><a href="http://$hostname" target="_blank" rel="noopener noreferrer">$hostname</a></td> | |
</tr> | |
<tr> | |
<td><b>Version</b></td> | |
<td>v.1.2</td> | |
</tr> | |
</table> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> | |
_EOF_ | |
systemctl start httpd | |
systemctl enable httpd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum update -y | |
yum install -y httpd | |
public_ipv4=$(curl -s "http://169.254.169.254/latest/meta-data/public-ipv4") | |
hostname=$(curl http://169.254.169.254/latest/meta-data/public-hostname) | |
cat > /var/www/html/index.html << _EOF_ | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<!-- CSS only --> | |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" | |
integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous"> | |
<title>$public_ipv4 | Hello world</title> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Hello world</h1> | |
<h3>This is ardih</h3> | |
<div class="row"> | |
<div class="col"> | |
<table class="table"> | |
<tr> | |
<td><b>IP</b></td> | |
<td><a href="http://$public_ipv4" target="_blank" rel="noopener noreferrer">$public_ipv4</a></td> | |
</tr> | |
<tr> | |
<td><b>Public hostname</b></td> | |
<td><a href="http://$hostname" target="_blank" rel="noopener noreferrer">$hostname</a></td> | |
</tr> | |
<tr> | |
<td><b>Version</b></td> | |
<td>v.1.1</td> | |
</tr> | |
</table> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> | |
_EOF_ | |
systemctl start httpd | |
systemctl enable httpd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For testing only
Use this user data to EC2 Amazon Linux 2 with public subnet to connect with Bootstrap CSS.
To use ec2-bootstrap-private.sh please place NAT gateway to install Apache and CSS Boostrap.
Expected result
![image](https://user-images.githubusercontent.com/15191922/192430465-e03a3d3e-1667-482e-81e7-7135825f9f49.png)