This project demonstrates the integration of five AWS services—Amplify, Lambda, IAM, API Gateway, and DynamoDB—to create and deploy a web application that calculates the power of a given base and exponent. The result of the calculation is stored in a DynamoDB table. https://dev.d2vzk0vjl847d4.amplifyapp.com/
Amplify : Used to deploy and host the web application.
Lambda: Contains the function that performs the power calculation (base^exponent).
IAM: Manages permissions, ensuring secure access to the DynamoDB table for storing results.
API Gateway: Creates and manages the POST API that triggers the Lambda function.
DynamoDB: Stores the results of the power calculations.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"dynamodb:PutItem",
"dynamodb:DeleteItem",
"dynamodb:GetItem",
"dynamodb:Scan",
"dynamodb:Query",
"dynamodb:UpdateItem"
],
"Resource": "YOUR-TABLE-ARN"
}
]
}
import json
import math
import boto3
from time import gmtime, strftime
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('powerofmathdb')
now = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
def lambda_handler(event, context):
mathResult = math.pow(int(event['base']), int(event['exponent']))
response = table.put_item(
Item={
'ID': str(mathResult),
'LatestGreetingTime':now
})
return {
'statusCode': 200,
'body': json.dumps('Your result is ' + str(mathResult))
}