Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
保护application.properties-spring引导应用程序中的一些密钥_Spring_Git_Amazon Web Services_Spring Boot - Fatal编程技术网

保护application.properties-spring引导应用程序中的一些密钥

保护application.properties-spring引导应用程序中的一些密钥,spring,git,amazon-web-services,spring-boot,Spring,Git,Amazon Web Services,Spring Boot,我有一个SpringBoot应用程序,我正在使用一些aws服务。 中的代码在Git中公开可用。 我不想提交属于application.properties的AWS密钥和访问密钥。我无法添加到.gitignore,因为我要提交application.properties的其他值 许多人都承诺进行回购。我们正在本地添加这些aws密钥,并确保其不会作为任何提交的一部分添加 我想确保application.properties中的aws密钥不应以任何代价提供给git。管理这些密钥的最佳方法是什么 您根本

我有一个SpringBoot应用程序,我正在使用一些aws服务。 中的代码在Git中公开可用。 我不想提交属于application.properties的AWS密钥和访问密钥。我无法添加到.gitignore,因为我要提交application.properties的其他值

许多人都承诺进行回购。我们正在本地添加这些aws密钥,并确保其不会作为任何提交的一部分添加


我想确保application.properties中的aws密钥不应以任何代价提供给git。管理这些密钥的最佳方法是什么

您根本不应该在application.properties中放置AWS API键。如果应用程序在AWS上运行,则应使用运行该应用程序的服务器的IAM角色。如果它没有在AWS上运行,那么它可能应该使用环境变量


请查看有关此主题的文档。

您根本不应该在application.properties中放置AWS API密钥。如果应用程序在AWS上运行,则应使用运行该应用程序的服务器的IAM角色。如果它没有在AWS上运行,那么它可能应该使用环境变量


请查看有关此主题的文档。

感谢@Mark B。我更喜欢使用Java系统属性,因为我们可以在应用程序级别维护它们。环境变量将处于系统级别,这不是真正需要的,可能会导致冲突

在使用mvn运行spring引导jar时,可以按如下方式完成

mvn spring引导:run-Dspring boot.run.jvmArguments=“-Daws.accessKeyId=xxxxxxxxxx-Daws.secretKey=xxxxxxxxxx”

如果为Eclipse或IntelliJ等IDE运行,则应将其添加为VM选项

-Daws.accessKeyId=xxxxxxxxxx-Daws.secretKey=xxxxxxxxxx

在此之后,可以像往常一样构建AWS客户机对象。 例如,

  • SNS客户端可以通过
  • AmazonSNS snsClient=amazonsclient.builder().withRegion(Regions.US_EAST_1).build()

  • SES客户端可以通过

  • AmazonSimpleEmailService emailClient=AmazonSimpleEmailServiceClientBuilder.standard().withRegion(Regions.US_EAST_1).build()

    感谢@Mark B。我更喜欢使用Java系统属性,因为我们可以在应用程序级别维护它们。环境变量将处于系统级别,这不是真正需要的,可能会导致冲突

    在使用mvn运行spring引导jar时,可以按如下方式完成

    mvn spring引导:run-Dspring boot.run.jvmArguments=“-Daws.accessKeyId=xxxxxxxxxx-Daws.secretKey=xxxxxxxxxx”

    如果为Eclipse或IntelliJ等IDE运行,则应将其添加为VM选项

    -Daws.accessKeyId=xxxxxxxxxx-Daws.secretKey=xxxxxxxxxx

    在此之后,可以像往常一样构建AWS客户机对象。 例如,

  • SNS客户端可以通过
  • AmazonSNS snsClient=amazonsclient.builder().withRegion(Regions.US_EAST_1).build()

  • SES客户端可以通过

  • AmazonSimpleEmailService emailClient=AmazonSimpleEmailServiceClientBuilder.standard().withRegion(Regions.US_EAST_1).build()

    您应该使用凭证文件进行aws身份验证!您应该使用凭据文件进行aws身份验证!