Objective: Create the IAM role DynamoDBBackupRole for the Lambda function
BackupDynamoDBAndSendEmail
, granting permissions to read and write data to the DynamoDB tablestudentData
, store backup files in S3, send emails via SES, log data to CloudWatch, and support potential interactions with CloudFront.
The function BackupDynamoDBAndSendEmail performs:
studentData
via the Scan operation.student-backup-20250706
).nguyentribaothang@gmail.com
).This role needs:
AmazonDynamoDBFullAccess
).AmazonS3FullAccess
).AmazonSESFullAccess
).AWSLambdaBasicExecutionRole
).CloudFrontFullAccess
) for potential future features.Note:
CloudFrontFullAccess
is not currently used but is retained for future functionalities (e.g., managing CloudFront distributions).
Below are the detailed steps to create the IAM role DynamoDBBackupRole:
Open your browser and log in to the AWS Management Console with your AWS account.
In the search bar, type IAM and select Identity and Access Management (IAM).
Ensure you are in the correct AWS region (e.g., us-east-1
), check in the top right corner.
Figure 1: AWS Console interface with the IAM search bar.
In the IAM interface, find the left-hand navigation menu.
Select Roles to view the list of IAM roles. If no roles exist, the list will be empty.
Figure 2: Navigation menu with the Roles option.
In the Roles interface, click the Create Role button in the top-right corner.
Figure 3: Create Role button in the Roles interface.
In the Select trusted entity section, choose AWS Service to specify that the role is for an AWS service.
In the Use case section, select Lambda from the list of services.
Click Next to move to the permission configuration step.
Figure 4: Choosing AWS Service and Lambda in Use case.
In the Permissions section, add the following five policies:
AmazonDynamoDBFullAccess:
AmazonDynamoDBFullAccess
in the search bar.Description: Grants read and write access to DynamoDB, supporting operations like Scan and other operations if needed.
Figure 5: Selecting the AmazonDynamoDBFullAccess policy.
AmazonS3FullAccess:
AmazonS3FullAccess
in the search bar.Description: Grants permissions to store backup files in S3 (
PutObject
) and create pre-signed URLs (GeneratePresignedUrl
).
Figure 6: Selecting the AmazonS3FullAccess policy.
AmazonSESFullAccess:
AmazonSESFullAccess
in the search bar.Description: Grants permission to send emails via SES to notify users with a backup download link (e.g., to
nguyentribaothang@gmail.com
).
Figure 7: Selecting the AmazonSESFullAccess policy.
AWSLambdaBasicExecutionRole:
AWSLambdaBasicExecutionRole
in the search bar.Description: Allows the Lambda function to log to CloudWatch for monitoring and debugging.
Figure 8: Selecting the AWSLambdaBasicExecutionRole policy.
CloudFrontFullAccess:
CloudFrontFullAccess
in the search bar.Description: Grants permission to manage CloudFront distributions for potential future features.
Figure 9: Selecting the CloudFrontFullAccess policy.
Verify the list of Permissions policies to ensure it includes:
AmazonDynamoDBFullAccess
AmazonS3FullAccess
AmazonSESFullAccess
AWSLambdaBasicExecutionRole
CloudFrontFullAccess
Click Next.
In the Role details section:
DynamoDBBackupRole
.
Note: The name must match exactly with the Lambda function configuration for
BackupDynamoDBAndSendEmail
.
Figure 10: Enter role name and description.
Double-check:
AmazonDynamoDBFullAccess
, AmazonS3FullAccess
, AmazonSESFullAccess
, AWSLambdaBasicExecutionRole
, CloudFrontFullAccess
.Click Create Role.
Figure 11: Create Role button to finalize the creation.