【问题标题】:Creating RDS Datasource fails with "AmazonRDSException: The security token included in the request is invalid"创建 RDS 数据源失败并显示“AmazonRDSException:请求中包含的安全令牌无效”
【发布时间】:2017-06-24 12:34:12
【问题描述】:

我无法使用

启动应用程序
@EnableRdsInstance(databaseName = "test",
        dbInstanceIdentifier = "test",
        password = "password",
        username = "username",
        readReplicaSupport = true
)

我得到的例外是:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'test': Invocation of init method failed; nested exception is com.amazonaws.services.rds.model.AmazonRDSException: The security token included in the request is invalid. (Service: AmazonRDS; Status Code: 403; Error Code: InvalidClientTokenId; Request ID: 925519ec-582e-11e7-8ca6-8159eafdc3e8)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    ...
Caused by: com.amazonaws.services.rds.model.AmazonRDSException: The security token included in the request is invalid. (Service: AmazonRDS; Status Code: 403; Error Code: InvalidClientTokenId; Request ID: 925519ec-582e-11e7-8ca6-8159eafdc3e8)
    at ...

尝试了Spring Cloud AWS Docs 中建议的所有配置,包括 ENV 变量、System.setProperties() 和 application.yml,如下所示

cloud:
  aws:
    credentials:
      accessKey: XXXXXXX
      secretKey: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    region:
      static: us-east-2

还尝试在 aws-beans 中进行硬编码

<beans ...>

    <aws-context:context-credentials>
        <aws-context:simple-credentials access-key="XXXXXXXXXX" secret-key="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"/>
    </aws-context:context-credentials>

    <aws-context:context-resource-loader/>

    <aws-context:context-region region="us-east-2" />

</beans>

没有任何效果,感谢您的帮助....

【问题讨论】:

  • 你还记得你想出的解决方案吗?谢谢!

标签: spring spring-boot spring-cloud spring-cloud-aws


【解决方案1】:

获得此异常的可能原因:

  • 确保为 RDS 实例启用公共访问,并允许安全组中您的计算机的传入流量。
  • 确保互联网网关与 VPC 连接,非常重要的是,您必须使用公共子网而不是私有子网。

【讨论】:

  • 我能够从我机器上的工作台访问 thr db,唯一的问题是 spring-cloud-aws 由于某些可能的配置错误而无法发送 accesskey/secretkey。
  • 不,我说的问题在于获取访问权限和密钥的框架,我不确定下一步是否继续
  • 你能粘贴 pom.xml 文件吗?所以我可以找出问题所在。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-12-12
  • 2018-04-09
  • 2021-06-22
  • 1970-01-01
  • 2021-11-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多