如何授予 AWS Cognito 用户池访问权限以对 AWS 资源 (SES) 执行操作



我正在使用 AWS Cognito 对应用程序中的用户进行身份验证。AWS在其文档中表示,登录用户的凭证可用于授予对AWS资源的访问权限。

我想使用 SES 允许用户从应用程序内提交联系我们表单。

我能够获得用户凭据。但是,当我将它们用于AmazonSimpleEmailServiceClient并调用sendEmail()时,我得到以下异常:

com.amazonaws.AmazonServiceException: User arn:aws:sts::xxxxxx/CognitoIdentityCredentials' is not authorized to perform ses:SendEmail' on resource 'arn:aws:ses:xxxxxx' (Service: AmazonSimpleEmailService;状态代码:403;错误代码:访问被拒绝;请求 ID: xxxxx-xx-xxxx-xx

如何允许 Cognito 用户池调用sendEmail(),以便我不需要在应用代码中存储任何机密?

要向用户授予对 AWS 资源的访问权限,除了 Cognito 用户池之外,还需要设置 Cognito 联合身份。

在 Cognito

联合身份中,连接相关的 Cognito 用户池并为经过身份验证的用户创建 IAM 角色策略,以包含 AWS SES 访问权限。

最新更新