- AWS Infrastructure Documentation
This documentation serves as a guide for understanding and hosting a simple OTP verification service on AWS.
The architecture diagram above illustrates the components and connections needed to host this service on AWS.
- Trigger: API Gateway - POST request
- Functionality: Stores
email
andotp
in DynamoDB with attl
attribute set to expire after 5 minutes.
- Trigger: DynamoDB Stream (Filters for
INSERT
events) - Functionality: Uses SES to send an email when an OTP is generated.
- Trigger: API Gateway - POST request
- Functionality: Verifies
otp
against DynamoDB.
HTTP API Gateway with 2 routes:
- /GenerateOTP (POST - GenerateOTP Lambda Function)
- /VerifyOTP (POST - VerifyOTP Lambda Function)
- Primary Key:
email
(string) otp
(6-digit random string generated)ttl
(time to live - Number)- Stream enabled
- TTL enabled for
ttl
attribute
- Set up for static website hosting.
- Important Note: Link to SES Note
- Logs, Events, Metrics auto-configured for Lambda functions.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DynamoReadWriteAccess",
"Effect": "Allow",
"Action": ["dynamodb:PutItem", "dynamodb:GetItem"],
"Resource": "arn:aws:dynamodb:<region>:<aws-account-id>:table/EmailVerification"
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DynamoReadDeleteAccess",
"Effect": "Allow",
"Action": ["dynamodb:DeleteItem", "dynamodb:GetItem"],
"Resource": "arn:aws:dynamodb:<region>:<aws-account-id>:table/EmailVerification"
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DynamoDBStreamAccess",
"Effect": "Allow",
"Action": [
"dynamodb:GetShardIterator",
"dynamodb:DescribeStream",
"dynamodb:GetRecords",
"dynamodb:ListStreams"
],
"Resource": "arn:aws:dynamodb:<region>:<aws-account-id>:table/EmailVerification/stream/*"
},
{
"Sid": "DynamoListStreams",
"Effect": "Allow",
"Action": "dynamodb:ListStreams",
"Resource": "*"
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["ses:SendEmail", "ses:SendRawEmail"],
"Resource": "*"
}
]
}
- Terraform scripts for infrastructure provisioning