-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
64 lines (64 loc) · 3.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>AWS Test</title>
<meta name="description" content="An EC2 test page - https://github.com/tylerapplebaum/EC2IndexPage">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<link rel="apple-touch-icon" sizes="180x180" href="https://s3-us-west-2.amazonaws.com/awselb.linuxabuser.com/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://s3-us-west-2.amazonaws.com/awselb.linuxabuser.com/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="https://s3-us-west-2.amazonaws.com/awselb.linuxabuser.com/favicon/favicon-16x16.png">
<link rel="manifest" href="https://s3-us-west-2.amazonaws.com/awselb.linuxabuser.com/favicon/site.webmanifest">
<link rel="mask-icon" href="https://s3-us-west-2.amazonaws.com/awselb.linuxabuser.com/favicon/safari-pinned-tab.svg" color="#5bbad5">
<style>
body {background-color: AliceBlue;}
h1 {font-size: 3vw; font-family: 'Open Sans', sans-serif;}
p {font-size: 1vw; font-family: 'Open Sans', sans-serif;}
</style>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.509.0.min.js"></script>
</head>
<body>
<script type="text/javascript">
<!-- https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-started-browser.html -->
<!-- https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#getItem-property -->
// Initialize the Amazon Cognito credentials provider
AWS.config.region = 'us-west-2'; // Region
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-west-2:0ecd7e5d-ab2e-4ad6-abb2-0982ebafc7bf',
});
function GetEC2PublicIPv4() {
var params = {
Key: {
"InstanceId": {
S: "i-xxxxxxxxxxxxxxxxx"
}
},
TableName: "InstanceTable"
};
var dynamodb = new AWS.DynamoDB();
dynamodb.getItem(params, function(err, data) {
if (err) {
console.log(err, err.stack); // an error occurred
var ipv4 = 'NotFound'
document.getElementById("EC2PublicIPv4").innerHTML = ipv4;
}
else {
console.log(data); // successful response
var ipv4 = data.Item.IPv4Address.S;
var instancetype = data.Item.InstanceType.S;
document.getElementById("EC2PublicIPv4").innerHTML = ipv4;
document.getElementById("EC2InstanceType").innerHTML = instancetype;
}
});
}
var EC2PublicIPv4 = new GetEC2PublicIPv4()
</script>
<h1>Hello from AWS!</h1>
<br />
<p>EC2 Instance IPv4 address: <span id="EC2PublicIPv4"></span></p>
<p>EC2 Instance type: <span id="EC2InstanceType"</span></p>
</body>
</html>