Deadline: Thursday, December 12, @23:59 pm Scenario Overview
You are tasked with creating a serverless architecture on AWS. Host a professional resume website on AWS and add a real-time visitor counter that updates with each page load. You can use S3 to host a static website, AWS Lambda to update the number of visitors in a DynamoDB table, and API Gateway to expose the Lambda function as an endpoint.
AWS Services Involved:
General Requirements:
Implementation: Two codes snippets are provided to you: one for the resume HTML and one for the Lambda function. You just need to replace some placeholders, understand what is happening in the code in general and do tweaks if needed. You need to:
o Attribute: count (stores the number of visitors). The value will be incremented with each page load.
Ensure that the Lambda function is configured to trigger through API Gateway and returns the visitor count correctly.
Evaluation Criteria:
traditional server-based structures.
Rubric
Key points | Grade (%) |
Technical Analysis (Components and infrastructure analysis and design) | 40 |
Deployment | 40 |
Documentation and Content (Clarity and quality of the documentation, format, etc.) | 10 |
Creativity | 10 |
Good Luck!
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>Your Name – Resume</title>
<style> body { font-family: Arial, sans-serif; line-height: 1.6; margin: 0; padding: 0; background-color: #f4f4f4; color: #333; }
.container { max-width: 800px; margin: 20px auto; background-color: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
} h1 { text-align: center; color: #4CAF50;
} h2 {
color: #333;
} p { font-size: 1.1em;
} .section {
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class=”container”>
<h1>Your Name</h1>
<p><strong>Contact Information:</strong> Email | Phone | LinkedIn</p>
<div class=”section”>
<h2>Objective</h2>
<p>Brief objective about your career goals and aspirations.</p>
</div>
<div class=”section”>
<h2>Experience</h2>
<p><strong>Job Title – Company Name</strong> (Year – Year)</p>
<ul>
<li>Responsibility/achievement 1</li>
<li>Responsibility/achievement 2</li>
</ul>
</div>
<div class=”section”>
<h2>Education</h2>
<p><strong>Degree – University Name</strong> (Year – Year)</p>
</div>
<div class=”section”>
<h2>Skills</h2>
<p>List your key skills, such as programming languages, tools, etc.</p>
</div>
<div class=”section”>
<h2>Projects</h2>
<p>Highlight relevant personal or professional projects.</p>
</div>
<div class=”section”>
<h2>Visitor Count</h2>
<p><strong>Visitors:</strong> <span id=”visitorcount”>Loading…</span></p>
</div>
</div>
<script>
async function updateVisitorCount() { try {
// Fetch data from the API
const response = await fetch(‘https://yqpbsv9z7j.execute-api.useast-1.amazonaws.com/prod/count’);
// Ensure the response is OK if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); }
// Parse JSON response const jsonResponse = await response.json();
// Access the count value from the response body const count = jsonResponse.body.count;
// Update the webpage if count exists if (count !== undefined) { document.getElementById(‘visitor-count’).textContent = count;
} else { throw new Error(‘Count not found in response body’);
}
} catch (error) { console.error(‘Error fetching visitor count:’, error); document.getElementById(‘visitor-count’).textContent = ‘Error:
Invalid response.’;
}
}
// Call the function when the page loads updateVisitorCount();
</script>
</body>
</html>
import json import boto3 from decimal import Decimal
dynamodb = boto3.resource(‘dynamodb’) table = dynamodb.Table(‘VisitorCounter’)
def lambda_handler(event, context): # Increment the visit count in DynamoDB response = table.update_item(
Key={‘VisitorId’: ‘visit_count’},
UpdateExpression=’ADD #count :increment’,
ExpressionAttributeNames={‘#count’: ‘count’},
ExpressionAttributeValues={‘:increment’: Decimal(1)},
ReturnValues=’UPDATED_NEW’
) count = response[‘Attributes’][‘count’]
# Return the response as a JSON object, NOT as a string return {
“statusCode”: 200,
“headers”: {
“Content-Type”: “application/json”,
“Access-Control-Allow-Origin”: “*”
},
“body”: {“count”: int(count)} # Do NOT serialize this with json.dumps()
}
Enjoy 24/7 customer support for any queries or concerns you have.
Phone: +1 213 3772458
Email: support@gradeessays.com