IAM role cho ứng dụng thay cho access key
Ứng dụng cần quyền để gọi dịch vụ AWS; thay vì lưu thông tin xác thực cố định (access key) trong mã nguồn, ứng dụng nên nhận quyền tạm thời thông qua một IAM role.
Ứng dụng của MFTECH chạy trên EC2 instance cần đọc dữ liệu từ một bảng DynamoDB. Phương án đơn giản nhưng rủi ro là lưu access key trong mã nguồn: khi mã nguồn bị lộ, access key cũng bị lộ. Phương án an toàn:
Nguyên tắc tương tự áp dụng cho các trường hợp khác:
Role tại account đích có trust policy tin cậy account dev. Developer sử dụng credentials tạm thời của role, không cần tạo user mới tại production.
- Ứng dụng trên AWS sử dụng IAM role, không sử dụng access key.
- Truy cập cross-account: tạo role tại account đích và assume role đó.
IAM roles for applications instead of access keys
Applications need permissions to call AWS services; instead of storing fixed credentials (access keys) in the code, they should receive temporary permissions through an IAM role.
MFTECH’s application on an EC2 instance needs to read data from a DynamoDB table. The simple but risky option is to store an access key in the source code: when the source code leaks, the access key leaks too. The secure option:
The same principle applies to other cases:
The role in the target account has a trust policy that trusts the dev account. The developer uses the role's temporary credentials, without a new user in production.
- Applications on AWS use IAM roles, not access keys.
- Cross-account access: create a role in the target account and assume it.