简体   繁体   English

在AWS Elastic BeanStalk上运行的Spring Boot应用程序中配置AWS RDS

[英]Configuring AWS RDS in a Spring Boot Application running on AWS Elastic BeanStalk

I am trying to learn my way of developing a REST app via Spring Boot framework using the AWS Elastic Beanstalk infrastructure. 我正在尝试使用AWS Elastic Beanstalk基础架构学习通过Spring Boot框架开发REST应用程序的方法。 I am using the IntelliJ IDE to develop and test the app on my local box before deploying it to the AWS Elastic BeanStalk server. 在将其部署到AWS Elastic BeanStalk服务器之前,我使用IntelliJ IDE在本地盒子上开发和测试应用程序。 I am trying to talk to the AWS RDS instance in my app. 我试图在我的应用程序中与AWS RDS实例交谈。 With the following code snippets my app is able to talk to RDS instance when deployed and run against my local box but gives me http 404 when deployed on the AWS server which i guess is because the deploy failed due to failure to connect to the RDS instance from AWS. 使用以下代码片段,我的应用程序能够在部署时与RDS实例通信并在我的本地机器上运行,但在AWS服务器上部署时会给我http 404,我猜是因为部署因无法连接到RDS实例而失败来自AWS。

Project POM file 项目POM文件

Application Properties file 应用属性文件

User Repository file 用户存储库文件

I am looking for a correct way to configure these secrets so that they are not present in the git. 我正在寻找一种正确的方法来配置这些秘密,以便它们不存在于git中。 Ideally take it from AWS environment variables defined for the instance but i am not able to figure out how the spring boot application properties files can access AWS Elastic BeanStalk environment configuration variables. 理想情况下,从为实例定义的AWS环境变量中获取它,但我无法弄清楚spring引导应用程序属性文件如何访问AWS Elastic BeanStalk环境配置变量。

I have read some documents and tutorials but not exactly able to figure this out. 我已经阅读了一些文档和教程,但不能完全弄明白。 Like Spring Cloud SDK , Sample Spring Boot AWS App Spring Cloud SDK一样示例Spring Boot AWS App

[Edit 1] To provide more information, I was able to ssh into the box and observe the logs. [编辑1]为了提供更多信息,我能够进入框中并观察日志。 The point of interest is : 兴趣点是:

Caused by: com.amazonaws.AmazonServiceException: User: arn:aws:sts::486695215273:assumed-role/aws-elasticbeanstalk-ec2-role/i-dc86381f is not authorized to perform: cloudformation:DescribeStackResources (Service: AmazonCloudFormation; Status Code: 403; Error Code: AccessDenied; Request ID: 1ee8c03b-ecd4-11e5-9fe1-378ce4cb26d3) 引起:com.amazonaws.AmazonServiceException:User:arn:aws:sts :: 486695215273:assume-role / aws-elasticbeanstalk-ec2-role / i-dc86381f无权执行:cloudformation:DescribeStackResources(Service:AmazonCloudFormation; Status代码:403;错误代码:AccessDenied;请求ID:1ee8c03b-ecd4-11e5-9fe1-378ce4cb26d3)

[Edit 2] After adding AWSCloudFormationReadOnlyAccess security policy in the required policy, Stack for i-dc86381f does not exist (Service: AmazonCloudFormation; Status Code: 400; Error Code: ValidationError; Request ID: f579cc15-ecd4-11e5-a20b-114992e25084) [编辑2]在所需策略中添加AWSCloudFormationReadOnlyAccess安全策略后,不存在用于i-dc86381f的堆栈(服务:AmazonCloudFormation;状态代码:400;错误代码:ValidationError;请求ID:f579cc15-ecd4-11e5-a20b-114992e25084)

My template file as mentioned in AWSCloudFormation is My Template File 我在AWSCloudFormation中提到的模板文件是我的模板文件

Configuring Elastic Beanstalk "secrets", or environment variables, can be done via the cli or via the GUI. 配置Elastic Beanstalk“秘密”或环境变量可以通过cli或GUI完成。 For the cli use: 对于cli使用:

eb setenv ExampleVar=ExampleValue

Which is pretty straight forward. 这很直截了当。 Docs here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-setenv.html 文档: http//docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-setenv.html

To do it via the GUI you'll navigate to your application and the desired environment, click on Configuration in the left hand menu. 要通过GUI执行此操作,您将导航到您的应用程序和所需的环境,单击左侧菜单中的配置。 Click the gear icon on the "Software Configuration" panel, and you'll be taken to the the configuration page where you can set "Environment Properties", which are key/value pairs... You can set a property name and then the property value and when you click "apply" they'll be applied to your environment and then your application can access them however it would normally access environment variables in production. 单击“软件配置”面板上的齿轮图标,您将进入配置页面,您可以在其中设置“环境属性”,它们是键/值对...您可以设置属性名称,然后属性值,当您单击“应用”时,它们将应用于您的环境,然后您的应用程序可以访问它们,但它通常会访问生产中的环境变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在使用 RDS 的 AWS (Elastic Beanstalk) 上部署 Spring 引导应用程序 - 应用程序未启动 - Deploy Spring Boot application on AWS (Elastic Beanstalk) that uses RDS - Application does not start Spring Boot Application无法在AWS Elastic Beanstalk中进行一次身份验证 - Spring Boot Application not authenticating once in AWS Elastic Beanstalk AWS Elastic Beanstalk-Tomcat Java Spring Boot应用程序出现问题 - AWS Elastic Beanstalk - Problem with tomcat java spring boot application 带有RDS的AWS EB上的Spring Boot应用程序部署 - Deployment of a spring boot application on AWS EB with RDS 带有SSL / HTTPS的Spring Boot项目无法在AWS Elastic Beanstalk上运行 - Spring Boot project with SSL / HTTPS not working on AWS Elastic Beanstalk 在AWS Elastic Beanstalk上部署Spring - Deploying Spring on AWS Elastic Beanstalk 使用 AWS Elastic Beanstalk 进行应用程序日志记录 - Application logging with AWS Elastic Beanstalk 配置部署在 AWS Elastic Beanstalk 中的 Spring 应用程序以使用 SSL - Configure Spring application deployed in AWS Elastic Beanstalk to use SSL 结合使用AWS Elastic Beanstalk和Java / BlazeDS / Spring应用程序 - Using AWS Elastic Beanstalk with a Java/BlazeDS/Spring application AWS Beanstalk 中的 Spring 启动微服务 - Spring boot Microservices in AWS Beanstalk
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM