Để đảm bảo an toàn khi triển khai hệ, ta không sử dụng tài khoản Root. Hãy tạo một tài khoản IAM User mới và cấp quyền truy cập AWS Management Console.
Các bước tạo IAM User:

bk-sync-deployer).


{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAWSLoginAction",
"Effect": "Allow",
"Action": [
"signin:AuthorizeOAuth2Access",
"signin:CreateOAuth2Token"
],
"Resource": "*"
},
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"sns:TagResource",
"iam:UntagRole",
"sns:DeleteTopic",
"iam:TagRole",
"iam:CreateRole",
"iam:AttachRolePolicy",
"sns:SetTopicAttributes",
"cloudformation:DescribeStackResource",
"iam:PutRolePolicy",
"sns:UntagResource",
"cloudformation:CreateChangeSet",
"cloudformation:DeleteChangeSet",
"iam:DetachRolePolicy",
"cloudformation:DescribeStackEvents",
"iam:ListAttachedRolePolicies",
"iam:DeleteRolePolicy",
"cloudformation:UpdateStack",
"iam:ListRolePolicies",
"cloudformation:DescribeChangeSet",
"cloudformation:ExecuteChangeSet",
"cloudformation:ListStackResources",
"iam:GetRole",
"sns:GetTopicAttributes",
"sns:CreateTopic",
"cloudformation:DescribeStackResources",
"iam:DeleteRole",
"cloudformation:DescribeStacks",
"cloudformation:CreateStack",
"cloudformation:DeleteStack",
"cloudformation:GetTemplate",
"iam:UpdateRole",
"iam:GetRolePolicy",
"cloudformation:ListChangeSets"
],
"Resource": [
"arn:aws:iam::*:role/qr-attendance-backend-dev-*",
"arn:aws:iam::*:role/*-qr-attendance-backend-dev-*",
"arn:aws:sns:*:*:QRAttendanceAlarmTopic*",
"arn:aws:cloudformation:*:aws:transform/Serverless-2016-10-31",
"arn:aws:cloudformation:*:*:stack/qr-attendance-backend-dev*/*",
"arn:aws:cloudformation:*:*:stack/aws-sam-cli-managed-default/*"
]
},
{
"Sid": "ScopedResources",
"Effect": "Allow",
"Action": [
"s3:*",
"dynamodb:*",
"secretsmanager:*",
"lambda:*",
"logs:DeleteLogGroup",
"logs:PutRetentionPolicy",
"logs:CreateLogDelivery",
"cloudwatch:PutMetricAlarm",
"cloudwatch:DeleteAlarms"
],
"Resource": [
"arn:aws:s3:::aws-sam-cli-managed-default-*",
"arn:aws:dynamodb:*:*:table/qr-attendance-backend-dev-*",
"arn:aws:secretsmanager:*:*:secret:*",
"arn:aws:lambda:*:*:function:qr-attendance-backend-dev-*",
"arn:aws:lambda:*:*:layer:*",
"arn:aws:logs:*:*:log-group:/aws/lambda/qr-attendance-backend-dev-*",
"arn:aws:cloudwatch:*:*:alarm:qr-attendance-backend-dev-*"
]
},
{
"Sid": "GlobalResources",
"Effect": "Allow",
"Action": [
"cloudformation:ListStacks",
"cloudformation:GetTemplateSummary",
"cloudformation:ValidateTemplate",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams",
"logs:FilterLogEvents",
"logs:GetLogEvents",
"logs:CreateLogGroup",
"cloudwatch:DescribeAlarms",
"cloudwatch:DescribeAlarmsForMetric",
"cloudwatch:GetMetricData",
"cloudwatch:GetMetricStatistics",
"cloudwatch:ListMetrics",
"apigateway:*",
"cognito-idp:*",
"amplify:*",
"secretsmanager:GetRandomPassword"
],
"Resource": "*"
},
{
"Sid": "VisualEditor2",
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::*:role/qr-attendance-backend-dev-*",
"Condition": {
"StringEquals": {
"iam:PassedToService": [
"lambda.amazonaws.com",
"apigateway.amazonaws.com"
]
}
}
},
{
"Sid": "VisualEditor4",
"Effect": "Deny",
"Action": [
"rds:*",
"redshift:*",
"sagemaker:*",
"ec2:*"
],
"Resource": "*"
}
]
}
9. Bấm Next, đặt tên Policy (VD: qr-attendance-deploy-policy), kéo xuống và bấm Create policy.
10. Quay lại tab tạo User ban đầu, bấm nút Refresh (biểu tượng mũi tên xoay tròn), tìm và tích chọn Policy vừa tạo. Sau đó bấm Create user
11. Hoàn tất tạo User và lưu lại tài khoản/mật khẩu đăng nhập. Đăng nhập vào tài khoản IAM mà đã tạo. Sau khi đăng nhập cần chỉnh region về ap-southeast-1 để có thể triển khai được.
Đảm bảo máy tính của bạn đã cài đặt các công cụ sau: