如何在Elastic Beanstalk上为Amazon SES传递AWS_ACCESS_KEY_ID? [英] How do I pass AWS_ACCESS_KEY_ID for Amazon SES on Elastic Beanstalk?

查看:104
本文介绍了如何在Elastic Beanstalk上为Amazon SES传递AWS_ACCESS_KEY_ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地计算机中将AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY设置为环境变量,并且工作正常.当我部署到Elastic Beanstalk时,我设置了环境属性",但是它们作为-D Java系统属性而不是设置为环境变量进行传递,并且会生成错误.

I set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables in my local computer and it works fine. When I deploy to Elastic Beanstalk, I set the "Environment properties", but they are passed as -D Java system properties, not set as environment variables, and it generates an error.

https://docs .aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-softwaresettings.html?icmpid = docs_elasticbeanstalk_console

而Tomcat平台设置您使用System.getProperty检索的Java系统属性.

while the Tomcat platform sets Java system properties that you retrieve with System.getProperty.

错误

2018-08-03 02:34:37.001信息32073 --- [nio-8080-exec-9] c.s.xxxxx.apis.XxxxxxxApiController:未发送电子邮件.错误:用户'arn:aws:sts :: 849611986161:assumed-role/aws-elasticbeanstalk-ec2-role/i-0f447c52c84e1fd93'无权对资源'arn:aws:ses:us-执行'ses:SendEmail' east-1:849611986161:identity/xxxxxx@xxxxx.com'(服务:AmazonSimpleEmailService;状态代码:403;错误代码:AccessDenied;请求ID:c3835dda-96c5-11e8-8a21-67774160691b)

2018-08-03 02:34:37.001 INFO 32073 --- [nio-8080-exec-9] c.s.xxxxx.apis.XxxxxxxApiController : The email was not sent. Error: User 'arn:aws:sts::849611986161:assumed-role/aws-elasticbeanstalk-ec2-role/i-0f447c52c84e1fd93' is not authorized to perform 'ses:SendEmail' on resource 'arn:aws:ses:us-east-1:849611986161:identity/xxxxxx@xxxxx.com' (Service: AmazonSimpleEmailService; Status Code: 403; Error Code: AccessDenied; Request ID: c3835dda-96c5-11e8-8a21-67774160691b)

Amazon SES仅期望环境变量(或主目录中的共享凭证文件").那么,如何使用该环境将AWS密钥传递给用于Java Spring Boot应用程序的Elastic Beanstalk中的Amazon SES?

Amazon SES is expecting environment variables only (or a 'shared credential file' in your home directory). So how do I pass AWS keys to Amazon SES in Elastic Beanstalk for a Java Spring Boot application using the environment?

推荐答案

根据

Java系统属性-aws.accessKeyId和aws.secretKey.适用于Java的AWS开发工具包使用SystemPropertiesCredentialsProvider加载这些凭据.

Java system properties–aws.accessKeyId and aws.secretKey. The AWS SDK for Java uses the SystemPropertiesCredentialsProvider to load these credentials.

因此,将aws.accessKeyId设置为aws.accessKeyId,而不是AWS_ACCESS_KEY_ID,然后在命令行上将其设置为Java系统属性,该属性由Amazon SES SDK获取.

So instead of AWS_ACCESS_KEY_ID, set aws.accessKeyId, which is then set as a Java system property on the command line, which is picked up by Amazon SES SDK.

这篇关于如何在Elastic Beanstalk上为Amazon SES传递AWS_ACCESS_KEY_ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆